2d 到 3d - 如何将绘图包裹在圆柱体上

发布于 2024-11-07 01:13:49 字数 1065 浏览 0 评论 0原文

我有在3D空间中旋转的图纸(带有X和Y坐标的点的阵列): http://www.motiondraw.com/mtdraw.com/mddraw.com/md/as_samples/tesmples/testesmples/testesting/testing/testing/_mindreadreadreadreder /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);

}

我只是无法缠绕我的头;-) 任何指针都非常感谢!

安德烈亚斯·韦伯

I have drawings (arrays of points with x and y coordinates) that are rotated in 3d space:
http://www.motiondraw.com/md/as_samples/Testing/_mindreader/main.html

As it is now, the drawing looks as if wrapped around a cube, with a nasty 90° degree in the corner. Instead it should look as if it were wrapped around a cylinder.
Before starting the rotation I call a function (in ActionScript) 'bendDrawing' that for each point sets an initial z-value:

for (var j = 0; j < numPoints; j++ ) {
// drawings are centered – points left of center are < 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);

}

I just can't wrap my head around this ;-)
Any pointers much appreciated!

Andreas Weber

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人│生佛魔见 2024-11-14 01:13:49

试试这个:

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

try this:

shape[i].points[j].z  = 
    wid * Math.cos((shape[i].points[j].x / wid) * (0.5 * Math.PI));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文