Exemple #1
0
        /// <summary>
        /// Transforms a vector using a matrix.
        /// </summary>
        /// <param name="v">Vector to transform.</param>
        /// <param name="matrix">Transform to apply to the vector.</param>
        /// <returns>Transformed vector.</returns>
        public static TSVector4 Transform4x4(TSVector v, TSMatrix4x4 matrix)
        {
            TSVector4 toReturn;

            Transform(ref v, ref matrix, out toReturn);
            return(toReturn);
        }
Exemple #2
0
 /// <summary>
 /// Transforms a vector using a matrix.
 /// </summary>
 /// <param name="v">Vector to transform.</param>
 /// <param name="matrix">Transform to apply to the vector.</param>
 /// <param name="result">Transformed vector.</param>
 public static void Transform(ref TSVector v, ref TSMatrix4x4 matrix, out TSVector4 result)
 {
     result.x = v.x * matrix.M11 + v.y * matrix.M21 + v.z * matrix.M31 + matrix.M41;
     result.y = v.x * matrix.M12 + v.y * matrix.M22 + v.z * matrix.M32 + matrix.M42;
     result.z = v.x * matrix.M13 + v.y * matrix.M23 + v.z * matrix.M33 + matrix.M43;
     result.w = v.x * matrix.M14 + v.y * matrix.M24 + v.z * matrix.M34 + matrix.M44;
 }
Exemple #3
0
        /**
         *  @brief Transform a direction from world space to local space.
         **/
        public TSVector4 InverseTransformDirection(TSVector4 direction)
        {
            Debug.Assert(direction.w == FP.Zero);
            TSMatrix4x4 matrix = TSMatrix4x4.Translate(position) * TSMatrix4x4.Rotate(rotation);

            return(TSVector4.Transform(direction, TSMatrix4x4.Inverse(matrix)));
        }
 public static void Transform(ref TSVector4 vector, ref TSMatrix4x4 matrix, out TSVector4 result)
 {
     result.x = vector.x * matrix.M11 + vector.y * matrix.M12 + vector.z * matrix.M13 + vector.w * matrix.M14;
     result.y = vector.x * matrix.M21 + vector.y * matrix.M22 + vector.z * matrix.M23 + vector.w * matrix.M24;
     result.z = vector.x * matrix.M31 + vector.y * matrix.M32 + vector.z * matrix.M33 + vector.w * matrix.M34;
     result.w = vector.x * matrix.M41 + vector.y * matrix.M42 + vector.z * matrix.M43 + vector.w * matrix.M44;
 }
        public static TSVector4 Transform(TSVector position, TSMatrix4x4 matrix)
        {
            TSVector4 result;

            TSVector4.Transform(ref position, ref matrix, out result);
            return(result);
        }
Exemple #6
0
        /// <summary>
        /// Transforms a vector using a matrix.
        /// </summary>
        /// <param name="v">Vector to transform.</param>
        /// <param name="matrix">Transform to apply to the vector.</param>
        /// <param name="result">Transformed vector.</param>
        public static void Transform(ref TSVector v, ref TSMatrix4x4 matrix, out TSVector result)
        {
            FP vX = v.x;
            FP vY = v.y;
            FP vZ = v.z;

            result.x = vX * matrix.M11 + vY * matrix.M21 + vZ * matrix.M31 + matrix.M41;
            result.y = vX * matrix.M12 + vY * matrix.M22 + vZ * matrix.M32 + matrix.M42;
            result.z = vX * matrix.M13 + vY * matrix.M23 + vZ * matrix.M33 + matrix.M43;
        }