【问题标题】:XNA equivalency of unity function Transform.InverseTransformDirection统一函数 Transform.InverseTransformDirection 的 XNA 等效性
【发布时间】:2013-06-30 10:28:40
【问题描述】:

寻找与此功能等效的 C# XNA 这个问题与以下帖子有关(当前未回答),

world velocity to local (ship might be flying backward so need worlds negative velocity etc.)

我也遇到的这个问题很容易通过上述函数统一解决,如果有人可以提供这个函数背后的数学代码或编写一个达到相同结果的小函数,那个人会!!!惊人的 !!!因为我们几天来一直在尝试解决这个问题。

问题的详细解释见上面我朋友的帖子。

提前谢谢大家

【问题讨论】:

    标签: c# xna rotation unity3d quaternions


    【解决方案1】:

    你可以在 XNA 中得到一个矩阵的逆,然后通过这样做来使用它:

    Matrix inverseMatrix = Matrix.Inverse(myMatrix);
    Vector3 result = Vector3.Transform(myVector, inverseMatrix);
    

    不过,根据我的理解,您希望在得到逆时忽略翻译。所以你只有一个方向(基本上这说明了旋转、缩放等)。我自己没有对此进行测试,但我认为这应该可以满足您的要求:

    Matrix copyOfMyMatrix = myMatrix;
    copyOfMyMatrix.Translation = Vector3.Zero; // reset the translation components
    Matrix inverseMatrix = Matrix.Inverse(copyOfMyMatrix);
    Vector3 result = Vector3.Transform(myVector, inverseMatrix);
    

    【讨论】:

    • 谢谢你,你真棒
    猜你喜欢
    • 2011-05-31
    • 1970-01-01
    • 2016-12-19
    • 1970-01-01
    • 2020-07-19
    • 1970-01-01
    • 2014-02-24
    • 2021-06-10
    • 1970-01-01
    相关资源
    最近更新 更多