点投影到yx旋转平面(point projection into yx rotated plane)

编程入门 行业动态 更新时间:2024-10-17 21:21:36
点投影到yx旋转平面(point projection into yx rotated plane)

我想在2D空间中模拟深度,如果我有一个点P1,我想我需要将给定点P1投影到平面x轴顺时针旋转“theta”rads,得到P1'

似乎P1'.x coord必须与P1.x和P1'相同。它必须比P1.y短。 在3D世界中:

cosa = cos(theta) sina = sin(theta) P1'.x = P1.x P1'.y = P1.y * cosa - P1.z * sina P1'.z = P1.y * sina + P1.z * cosa

我的P1.z = 0吗? 我试过了,P1'.y = P1.y * cosa没有按预期结果

任何回应将不胜感激,谢谢!

编辑:我想要的,现在我旋转相机并翻译矩阵

编辑2:具有start1点和end1点的单行示例(它是水平线,只要倾斜角度增加,预期结果是到“floor”的下降线)

我认为这是一个符号错误或需要的偏移量(java画布图(0,0)位于左上角),因为我的新线倾斜度为0,是一个低于所有值且值为90º的新线和原来的一个匹配

I want to simulate depth in a 2D space, If I have a point P1 I suppose that I need to project that given point P1 into a plane x axis rotated "theta" rads clockwise, to get P1'

It seems that P1'.x coord has to be the same as the P1.x and the P1'.y has to b shorter than P1.y. In a 3D world:

cosa = cos(theta) sina = sin(theta) P1'.x = P1.x P1'.y = P1.y * cosa - P1.z * sina P1'.z = P1.y * sina + P1.z * cosa

Is my P1.z = 0? I tried it and P1'.y = P1.y * cosa doesn't result as expected

Any response would be appreciated, Thanks!

EDIT: What I want, now I rotate camera and translate matrix

EDIT 2: an example of a single line with a start1 point and a end1 point (it's an horizontal line, result expected is a falling line to the "floor" as long as tilt angle increases)

I think it's a sign error or an offset needed (java canvas drawing (0,0) is at top-left), because my new line with a tilt of 0 is the one below of all and with a value of 90º the new line and the original one match

最满意答案

如果要围绕x轴顺时针旋转,则执行的计算是正确的。 如果您将线条视为一张纸,则直接观察线条时旋转0度。

对于示例,您已经给出了与x轴水平的线。 这不会改变围绕x轴的旋转(线和它旋转的轴彼此平行)。 当你在0到90度之间旋转时,线的y坐标将随着P1.y * cos(theta)在90度下降到0而减小(考虑一下我们围绕它的底边旋转的那张纸, x轴,90度纸张是平的,y轴垂直于页面,因此页面的两个边缘具有相同的y坐标,两侧是“x轴”和相反的平行方将有y = 0)。

因此,您可以看到您的示例,这已正常工作。

编辑:乘以90度的原因并不能给出完全零答案,只是浮点舍入

The calculation you are performing is correct if you would like to perform a rotation around the x axis clockwise. If you think of your line as a sheet of paper, a rotation of 0 degrees is you looking directly at the line.

For the example you have given the line is horizontal to the x axis. This will not change on rotation around the x axis (the line and the axis around which it is rotating are parallel to one another). As you rotate between 0 and 90 degrees the y co-ordinates of the line will decrease with P1.y*cos(theta) down to 0 at 90 degrees (think about the piece of paper we have been rotating around it's bottom edge, the x axis, at 90 degrees the paper is flat, and the y axis is perpendicular to the page, thus both edges of the page have the same y co-ordinate, both the side that is the "x-axis" and the opposite parallel side will have y=0).

Thus as you can see for your example this has worked correctly.

EDIT: The reason that multiplying by 90 degrees does not give an exactly zero answer is simply floating point rounding

更多推荐

本文发布于:2023-08-04 10:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415214.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:平面   point   yx   plane   rotated

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!