예제 #1
0
        /// <summary>
        /// Create a translation and rotation matrix.
        /// </summary>
        /// <param name="translation">Translation as 3 doubles in a DVector3 struct.</param>
        /// <param name="orientation">Orientation as 4 doubles in a DVector4 struct.</param>
        /// <returns>Double matrix.</returns>
        public static DMatrix4x4 TR(DVector3 translation, DVector4 orientation)
        {
            double[] dTranslation = new double[3];
            double[] dOrientation = new double[4];

            dTranslation[0] = translation.x;
            dTranslation[1] = translation.y;
            dTranslation[2] = translation.z;

            dOrientation[0] = orientation.x;
            dOrientation[1] = orientation.y;
            dOrientation[2] = orientation.z;
            dOrientation[3] = orientation.w;

            return(DMatrix4x4.TR(dTranslation, dOrientation));
        }
예제 #2
0
 /// <summary>
 /// Dot Product of two vectors.
 /// </summary>
 /// <returns>Dot product as a double.</returns>
 /// <param name="a">First vector.</param>
 /// <param name="b">Second vector.</param>
 public static double Dot(DVector4 a, DVector4 b)
 {
     return((a.x * b.x) + (a.y * b.y) + (a.z * b.z) + (a.w * b.w));
 }
예제 #3
0
 /// <summary>
 /// Returns the distance between a and b.
 /// </summary>
 /// <returns>Euclidean distance as a double.</returns>
 /// <param name="a">First vector.</param>
 /// <param name="b">Second vector.</param>
 public static double Distance(DVector4 a, DVector4 b)
 {
     return((a - b).Magnitude);
 }