示例#1
0
 /// <summary>
 /// 四元数的逆
 /// </summary>
 /// <param name="rotation"></param>
 /// <returns></returns>
 public static Quaterniond Inverse(Quaterniond rotation)
 {
     return(new Quaterniond(-rotation.x, -rotation.y, -rotation.z, rotation.w));
 }
示例#2
0
        /// <summary>
        /// 夹角大小
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static double Angle(Quaterniond a, Quaterniond b)
        {
            double single = Dot(a, b);

            return(Math.Acos(Math.Min(Math.Abs(single), 1f)) * 2f * (180 / Math.PI));
        }
示例#3
0
 /// <summary>
 /// 点乘
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static double Dot(Quaterniond a, Quaterniond b)
 {
     return(a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w);
 }
示例#4
0
 /// <summary>
 /// 设置平移旋转缩放矩阵
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="q"></param>
 /// <param name="s"></param>
 public void SetTRS(Vector3d pos, Quaterniond q, Vector3d s)
 {
     this = TRS(pos, q, s);
 }