Esempio n. 1
0
 }/// <summary>
 /// calculates the effect of this rotation on a point
 /// the new point is given by=q * P1 * q'
 /// this version does not alter P1 but returns the result.
 /// 
 /// for theory see:
 /// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/index.htm
 /// </summary>
 /// <param name="point">point to be transformed</param>
 /// <returns>translated point</returns>
 public sfvec3f getTransform(sfvec3f p1)
 {
     double wh = angle;
     double xh = x;
     double yh = y;
     double zh = z;
     if (coding == (int)cde.CODING_AXISANGLE)
     {
         double s = Math.Sin(angle / 2);
         xh = x * s;
         yh = y * s;
         zh = z * s;
         wh = Math.Cos(angle / 2);
     }
     sfvec3f p2 = new sfvec3f();
     p2.x = wh * wh * p1.x + 2 * yh * wh * p1.z - 2 * zh * wh * p1.y + xh * xh * p1.x + 2 * yh * xh * p1.y + 2 * zh * xh * p1.z - zh * zh * p1.x - yh * yh * p1.x;
     p2.y = 2 * xh * yh * p1.x + yh * yh * p1.y + 2 * zh * yh * p1.z + 2 * wh * zh * p1.x - zh * zh * p1.y + wh * wh * p1.y - 2 * xh * wh * p1.z - xh * xh * p1.y;
     p2.z = 2 * xh * zh * p1.x + 2 * yh * zh * p1.y + zh * zh * p1.z - 2 * wh * yh * p1.x - yh * yh * p1.z + 2 * wh * xh * p1.y - xh * xh * p1.z + wh * wh * p1.z;
     return p2;
 }/// <summary>
Esempio n. 2
0
 }/// <summary>
 /// calculates the effect of this rotation on a point
 /// the new point is given by=q * P1 * q'
 /// this version returns the result in p1
 /// 
 /// for theory see:
 /// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/index.htm
 /// </summary>
 /// <param name="point">point to be transformed</param>
 public void transform(sfvec3f p1)
 {
     double wh = angle;
     double xh = x;
     double yh = y;
     double zh = z;
     if (coding == (int)cde.CODING_AXISANGLE)
     {
         double s = Math.Sin(angle / 2);
         xh = x * s;
         yh = y * s;
         zh = z * s;
         wh = Math.Cos(angle / 2);
     }
     double resultx = wh * wh * p1.x + 2 * yh * wh * p1.z - 2 * zh * wh * p1.y + xh * xh * p1.x + 2 * yh * xh * p1.y + 2 * zh * xh * p1.z - zh * zh * p1.x - yh * yh * p1.x;
     double resulty = 2 * xh * yh * p1.x + yh * yh * p1.y + 2 * zh * yh * p1.z + 2 * wh * zh * p1.x - zh * zh * p1.y + wh * wh * p1.y - 2 * xh * wh * p1.z - xh * xh * p1.y;
     double resultz = 2 * xh * zh * p1.x + 2 * yh * zh * p1.y + zh * zh * p1.z - 2 * wh * yh * p1.x - yh * yh * p1.z + 2 * wh * xh * p1.y - xh * xh * p1.z + wh * wh * p1.z;
     p1.x = resultx;
     p1.y = resultx;
     p1.z = resultx;
 }/// <summary>
Esempio n. 3
0
 /// calculates the effect of this rotation on a point
 /// the new point is given by=q * P1 * q'
 /// this version returns the result in p1
 /// 
 /// for theory see:
 /// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/index.htm
 /// </summary>
 /// <param name="point">point to be transformed</param>
 public void transform(sfvec3f p1)
 {
     double wh = angle;
     double xh = x;
     double yh = y;
     double zh = z;
     if (coding == (int)cde.CODING_AXISANGLE)
     {
         double s = Math.Sin(angle / 2);
         xh = x * s;
         yh = y * s;
         zh = z * s;
         wh = Math.Cos(angle / 2);
     }
     double resultx = wh * wh * p1.x + 2 * yh * wh * p1.z - 2 * zh * wh * p1.y + xh * xh * p1.x + 2 * yh * xh * p1.y + 2 * zh * xh * p1.z - zh * zh * p1.x - yh * yh * p1.x;
     double resulty = 2 * xh * yh * p1.x + yh * yh * p1.y + 2 * zh * yh * p1.z + 2 * wh * zh * p1.x - zh * zh * p1.y + wh * wh * p1.y - 2 * xh * wh * p1.z - xh * xh * p1.y;
     double resultz = 2 * xh * zh * p1.x + 2 * yh * zh * p1.y + zh * zh * p1.z - 2 * wh * yh * p1.x - yh * yh * p1.z + 2 * wh * xh * p1.y - xh * xh * p1.z + wh * wh * p1.z;
     p1.x = resultx;
     p1.y = resultx;
     p1.z = resultx;
 }
Esempio n. 4
0
 /// calculates the effect of this rotation on a point
 /// the new point is given by=q * P1 * q'
 /// this version does not alter P1 but returns the result.
 /// 
 /// for theory see:
 /// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/index.htm
 /// </summary>
 /// <param name="point">point to be transformed</param>
 /// <returns>translated point</returns>
 public sfvec3f getTransform(sfvec3f p1)
 {
     double wh = angle;
     double xh = x;
     double yh = y;
     double zh = z;
     if (coding == (int)cde.CODING_AXISANGLE)
     {
         double s = Math.Sin(angle / 2);
         xh = x * s;
         yh = y * s;
         zh = z * s;
         wh = Math.Cos(angle / 2);
     }
     sfvec3f p2 = new sfvec3f();
     p2.x = wh * wh * p1.x + 2 * yh * wh * p1.z - 2 * zh * wh * p1.y + xh * xh * p1.x + 2 * yh * xh * p1.y + 2 * zh * xh * p1.z - zh * zh * p1.x - yh * yh * p1.x;
     p2.y = 2 * xh * yh * p1.x + yh * yh * p1.y + 2 * zh * yh * p1.z + 2 * wh * zh * p1.x - zh * zh * p1.y + wh * wh * p1.y - 2 * xh * wh * p1.z - xh * xh * p1.y;
     p2.z = 2 * xh * zh * p1.x + 2 * yh * zh * p1.y + zh * zh * p1.z - 2 * wh * yh * p1.x - yh * yh * p1.z + 2 * wh * xh * p1.y - xh * xh * p1.z + wh * wh * p1.z;
     return p2;
 }