English 中文(简体)
在两个正常矢量之间查找 x,y,z 旋转
原标题:Find x,y,z rotation between two normal vectors

我在 3D 间距有两个方格。 我想找到它们之间的 X,y,z 角度。 我从找到两个方格的正常矢量开始, 我正试图找到它们之间的角 。

我正在使用 XNA (C#) 矢量3 对象 。

我计算了正常矢量如下:

        Vector3 normal1 = (Vector3.Cross(sq1.corners[0] - sq1.corners[1], sq1.corners[0] - sq1.corners[2]));
        Vector3 normal2 = (Vector3.Cross(sq2.corners[0] - sq2.corners[1], sq2.corners[0] - sq2.corners[2]));

我想找到一个平滑的旋转音, 它会变得正常1 面对与正常2 相同的方式。

最佳回答

首先,您可以计算旋转轴和旋转量(假设任意轴):

Vector3 axis = Vector3.Cross(normal1, normal2);
axis.Normalize();
double angle = Math.Acos(Vector3.Dot(normal1, normal2) / normal1.Length() / normal2.Length());

如果正常值正常化,则角的计算降低到

double angle = Math.Acos(Vector3.Dot(normal1, normal2));

然后您就可以将此功能转换为从"

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签