Exemplo n.º 1
0
 /// <summary>
 /// Z軸(001)を引数のベクトルvに回転させる行列を生成する
 /// </summary>
 /// <param name="v"></param>
 /// <returns></returns>
 public static M3d CreateRotationFromZ(V3d v)
 {
     v.Normalize();
     if (Math.Abs(v.Z - 1) < Th)
     {
         return(M3d.Identity);
     }
     else if (Math.Abs(v.Z + 1) < Th)
     {
         return(M3d.CreateRotationX(Math.PI));
     }
     else
     {
         return(M3d.CreateFromAxisAngle(V3d.Cross(v, Z), V3d.CalculateAngle(Z, v)));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Z軸(001)を引数のベクトルvに回転させる行列を生成する
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static M3d CreateRotationToZ(V3d v)
        {
            M3d rot;

            v.Normalize();
            if (Math.Abs(v.Z - 1) < Th)
            {
                rot = M3d.Identity;
            }
            else if (Math.Abs(v.Z + 1) < Th)
            {
                rot = M3d.CreateRotationX(Math.PI);
            }
            else
            {
                rot = M3d.CreateFromAxisAngle(V3d.Cross(Z, v), V3d.CalculateAngle(Z, v));
            }
            return(rot);
        }