简体   繁体   English

我们如何在 2D 中通过 Line 角度计算 Rotation3D Axis (Vector3D)

[英]How can we calculate Rotation3D Axis (Vector3D) by Line angle in 2D

I have some shapes in the 2D and also I have 3D models created exactly by 2D Shapes that I have, Now I want to rotate my 3d models by bottom line of them and I'm usinf from RotateTransform3D and also AxisAngleRotation3D, So I need Angle,CenterPoint and Vector3D of Axis x,y,z.我在 2D 中有一些形状,而且我有 3D 模型完全由我拥有的 2D 形状创建,现在我想通过它们的底线旋转我的 3d 模型,我使用的是 RotateTransform3D 和 AxisAngleRotation3D,所以我需要 Angle ,CenterPoint 和 Vector3D 轴 x,y,z。

Angle to rotate model to up is always 90 degrees. model 向上旋转的角度始终为 90 度。

Also I can calculate angle of each line that I want to rotate 3d model by that line ( Red Lines in the example picture) and center point by 2d but my question is how can I calculate Axis to say it should rotate by which axis(or axises).此外,我可以计算我想通过该线旋转 3d model 的每条线的角度(示例图片中的红线)和 2d 的中心点,但我的问题是我如何计算 Axis 说它应该旋转哪个轴(或轴)。

var myRotateTransform = new RotateTransform3D(
                                 new AxisAngleRotation3D(
                                 new Vector3D(?, ?, ?), angle),
                                 new Point3D(getCenter.X, getCenter.Y, getCenter.Z));

Also in the picture I attached it here you can see and example to understand it better.同样在我附在此处的图片中,您可以查看示例以更好地理解它。 Example例子

I believe for 0 degree Vector3D must be (-1,0,0) or for 180 degree Vector3D must be (1,0,0), but how can I calculate it automatically?我相信 0 度 Vector3D 必须是 (-1,0,0) 或 180 度 Vector3D 必须是 (1,0,0),但我怎样才能自动计算呢?

If you want to rotate the object around the red lines, you need to calculate the direction of the line.如果要绕红线旋转object,需要计算线的方向。 Ie calculate end - start .即计算end - start This direction can then be used as the rotation-axis.然后可以将该方向用作旋转轴。 You might also want to use a point on said line as the rotation-center since this will make the rotation work similar to a hinge.您可能还想使用所述线上的一个点作为旋转中心,因为这将使旋转工作类似于铰链。

You do not specify how you are describing the lines, so it is difficult to provide more specific instructions.您没有指定如何描述这些行,因此很难提供更具体的说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM