Actionscript 3 二维到三维-如何围绕圆柱体包裹图形

Actionscript 3 二维到三维-如何围绕圆柱体包裹图形,actionscript-3,3d,projective-geometry,Actionscript 3,3d,Projective Geometry,我绘制了在三维空间中旋转的具有x和y坐标的点阵列: 就像现在一样,这幅画看起来像是包裹在一个立方体周围,角落里有一个令人讨厌的90度角。相反,它应该看起来像是包裹在一个圆柱体上。 在开始旋转之前,我在ActionScript“bendDrawing”中调用一个函数,为每个点设置一个初始z值: 对于var j=0;j

我绘制了在三维空间中旋转的具有x和y坐标的点阵列:

就像现在一样,这幅画看起来像是包裹在一个立方体周围,角落里有一个令人讨厌的90度角。相反,它应该看起来像是包裹在一个圆柱体上。 在开始旋转之前,我在ActionScript“bendDrawing”中调用一个函数,为每个点设置一个初始z值:

对于var j=0;j
var wid = 350;// this could be the radius of the cylinder

// NOTE: suboptimal, as the image gets a 90° corner in the center, at its highest point
// what it should look like: as if the image was wrapped around a cylinder, i.e. in a circular shape
// is that pythagoras? draw triangle, calc distance from base, add to this to c?
var z = wid - distFromCenter;

shape[i].points[j].z =  Math.abs( z);
}

我就是不能把我的头绕在这上面- 非常感谢任何指点

安德烈亚斯·韦伯

试试这个:

shape[i].points[j].z  = 
    wid * Math.cos((shape[i].points[j].x / wid) * (0.5 * Math.PI));

您可能需要查找圆柱坐标系及其投影。形状[i]。点[j]。z=wid*Math.cosshape[i]。点[j]。x/wid*0.5*Math.PI;就像一个咒语-这正是我需要的。谢谢!