Ejemplo n.º 1
0
        /// <summary>
        /// Transform a Vector3d by the given Matrix, and project the resulting Vector4 back to a Vector3
        /// </summary>
        /// <param name="vec">The vector to transform</param>
        /// <param name="mat">The desired transformation</param>
        /// <returns>The transformed vector</returns>
        public static Vector3d TransformPerspective(Vector3d vec, Matrix4d mat)
        {
            Vector4d h = Transform(vec, mat);

            return(new Vector3d(h.X / h.W, h.Y / h.W, h.Z / h.W));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs a new instance from the given Vector4d.
 /// </summary>
 /// <param name="v">The Vector4d to copy components from.</param>
 public Vector3d(Vector4d v)
 {
     X = v.X;
     Y = v.Y;
     Z = v.Z;
 }
Ejemplo n.º 3
0
        /// <summary>Transform a Vector by the given Matrix</summary>
        /// <param name="vec">The vector to transform</param>
        /// <param name="mat">The desired transformation</param>
        /// <param name="result">The transformed vector</param>
        public static void Transform(ref Vector3d vec, ref Matrix4d mat, out Vector4d result)
        {
            Vector4d v4 = new Vector4d(vec.X, vec.Y, vec.Z, 1.0f);

            Vector4d.Transform(ref v4, ref mat, out result);
        }