我有在3d空间中旋转的绘图(带有x和y坐标的点阵列): http://www.motiondraw.com/md/as_samples/Testing/_mindreader/main.html
就像现在一样,这幅画看起来好像缠绕在一个立方体上,角落里有一个令人讨厌的90度。相反,它应该看起来好像是围绕着一个圆柱体。 在开始旋转之前,我调用一个函数(在ActionScript中)'bendDrawing',为每个点设置一个初始z值:
for(var j = 0; j< numPoints; j ++){
//图纸居中 - 中心左边的点是< 0
var distFromCenter = Math.abs(shape [i] .points [j] .x);
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);
}
我无法绕过这个;-) 任何指针都非常赞赏!
安德烈亚斯韦伯答案 0 :(得分:2)
试试这个:
shape[i].points[j].z =
wid * Math.cos((shape[i].points[j].x / wid) * (0.5 * Math.PI));