Пример #1
1
        public static void GetRotatedVector(this Quaternion quaternion, Point3D[] points)
        {
            Matrix3D matrix = new Matrix3D();
            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            transform.Transform(points);
        }
Пример #2
0
        /// <summary>
        /// Rotates the double vector around the angle in degrees
        /// </summary>
        public DoubleVector GetRotatedVector(Vector3D axis, double angle)
        {
            Matrix3D matrix = new Matrix3D();
            matrix.Rotate(new Quaternion(axis, angle));

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return new DoubleVector(transform.Transform(this.Standard), transform.Transform(this.Orth));
        }
Пример #3
0
 /// <summary>
 /// Transforms from local to world coordinates.
 /// </summary>
 /// <param name="vector">
 /// The vector (local coordinates).
 /// </param>
 /// <returns>
 /// Transformed vector (world coordinates).
 /// </returns>
 protected Vector3D ToWorld(Vector3D vector)
 {
     var mat = Visual3DHelper.GetTransform(this);
     var t = new MatrixTransform3D(mat);
     return t.Transform(vector);
 }
Пример #4
0
 /// <summary>
 /// Transforms from local to world coordinates.
 /// </summary>
 /// <param name="point">
 /// The point (local coordinates).
 /// </param>
 /// <returns>
 /// Transformed point (world coordinates).
 /// </returns>
 protected Point3D ToWorld(Point3D point)
 {
     var mat = Visual3DHelper.GetTransform(this);
     var t = new MatrixTransform3D(mat);
     return t.Transform(point);
 }
Пример #5
0
 /// <summary>
 /// Transforms from world to local coordinates.
 /// </summary>
 /// <param name="worldPoint">
 /// The point (world coordinates).
 /// </param>
 /// <returns>
 /// Transformed vector (local coordinates).
 /// </returns>
 protected Point3D ToLocal(Point3D worldPoint)
 {
     var mat = Visual3DHelper.GetTransform(this);
     mat.Invert();
     var t = new MatrixTransform3D(mat);
     return t.Transform(worldPoint);
 }
Пример #6
0
        /// <summary>
        /// This overload will rotate arrays of different types.  Just pass null if you don't have any of that type
        /// </summary>
        public static void GetRotatedVector(this Quaternion quaternion, Vector3D[] vectors, Point3D[] points, DoubleVector[] doubleVectors)
        {
            Matrix3D matrix = new Matrix3D();
            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            if (vectors != null)
            {
                transform.Transform(vectors);
            }

            if (points != null)
            {
                transform.Transform(points);
            }

            if (doubleVectors != null)
            {
                for (int cntr = 0; cntr < doubleVectors.Length; cntr++)
                {
                    doubleVectors[cntr] = new DoubleVector(transform.Transform(doubleVectors[cntr].Standard), transform.Transform(doubleVectors[cntr].Orth));
                }
            }
        }
Пример #7
0
        public static void GetRotatedVector(this Quaternion quaternion, DoubleVector[] doubleVectors)
        {
            Matrix3D matrix = new Matrix3D();
            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            for (int cntr = 0; cntr < doubleVectors.Length; cntr++)
            {
                doubleVectors[cntr] = new DoubleVector(transform.Transform(doubleVectors[cntr].Standard), transform.Transform(doubleVectors[cntr].Orth));
            }
        }
Пример #8
0
        public static DoubleVector GetRotatedVector(this Quaternion quaternion, DoubleVector doubleVector)
        {
            Matrix3D matrix = new Matrix3D();
            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return new DoubleVector(transform.Transform(doubleVector.Standard), transform.Transform(doubleVector.Orth));
        }
Пример #9
0
        public static Point3D GetRotatedVector(this Quaternion quaternion, Point3D point)
        {
            Matrix3D matrix = new Matrix3D();
            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return transform.Transform(point);
        }
Пример #10
0
        // I copy the code in each of these overloads, rather than make a private method to increase speed
        //TODO: I don't use these rotate extension methods anymore, but it would be worth testing whether to use this matrix transform, or use: new RotateTransform3D(new QuaternionRotation3D(quaternion))
        public static Vector3D GetRotatedVector(this Quaternion quaternion, Vector3D vector)
        {
            Matrix3D matrix = new Matrix3D();
            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return transform.Transform(vector);
        }
Пример #11
0
        /// <summary>
        /// Rotates the vector around the angle in degrees
        /// </summary>
        public static Vector3D GetRotatedVector(this Vector3D vector, Vector3D axis, double angle)
        {
            Matrix3D matrix = new Matrix3D();
            matrix.Rotate(new Quaternion(axis, angle));

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return transform.Transform(vector);
        }