コード例 #1
0
 /// <summary>
 /// SUbtract a quaternion from this quaternion.
 /// </summary>
 public Quaternion Subtract(
     Quaternion q
     )
 {
     return new Quaternion(
         qw - q.qw,
         qx - q.qx,
         qy - q.qy,
         qz - q.qz
         );
 }
コード例 #2
0
 /// <summary>
 /// Raise the quaternion to a given power.
 /// </summary>
 public Quaternion Pow(
     Quaternion power
     )
 {
     return power.Multiply(Ln()).Exp();
 }
コード例 #3
0
 /// <summary>
 /// Multiply a quaternion with this quaternion.
 /// </summary>
 public Quaternion Multiply(
     Quaternion q
     )
 {
     double ci = +qx * q.qw + qy * q.qz - qz * q.qy + qw * q.qx;
     double cj = -qx * q.qz + qy * q.qw + qz * q.qx + qw * q.qy;
     double ck = +qx * q.qy - qy * q.qx + qz * q.qw + qw * q.qz;
     double cr = -qx * q.qx - qy * q.qy - qz * q.qz + qw * q.qw;
     return new Quaternion(cr, ci, cj, ck);
 }
コード例 #4
0
 /// <summary>
 /// Multiplies a Quaternion with the inverse of another
 /// Quaternion (q*q<sup>-1</sup>). Note that for Quaternions
 /// q*q<sup>-1</sup> is not the same then q<sup>-1</sup>*q,
 /// because this will lead to a rotation in the other direction.
 /// </summary>
 public Quaternion Divide(
     Quaternion q
     )
 {
     return Multiply(q.Inverse());
 }
コード例 #5
0
 /// <summary>
 /// Add a quaternion to this quaternion.
 /// </summary>
 public Quaternion Add(
     Quaternion q
     )
 {
     return new Quaternion(
         qw + q.qw,
         qx + q.qx,
         qy + q.qy,
         qz + q.qz
         );
 }
コード例 #6
0
 /// <summary>
 /// Returns the distance |a-b| of two quaternions, forming a metric space.
 /// </summary>
 public static double Distance(
     Quaternion a,
     Quaternion b
     )
 {
     return a.Subtract(b).Abs;
 }