Example #1
0
 /// <summary>
 /// Constructs this matrix from a hmat3. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public hmat2(hmat3 m)
 {
     this.m00 = m.m00;
     this.m01 = m.m01;
     this.m10 = m.m10;
     this.m11 = m.m11;
 }
Example #2
0
 /// <summary>
 /// Constructs this matrix from a hmat3. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public hmat2x3(hmat3 m)
 {
     this.m00 = m.m00;
     this.m01 = m.m01;
     this.m02 = m.m02;
     this.m10 = m.m10;
     this.m11 = m.m11;
     this.m12 = m.m12;
 }
Example #3
0
 /// <summary>
 /// Constructs this matrix from a hmat3. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public hmat3x2(hmat3 m)
 {
     this.m00 = m.m00;
     this.m01 = m.m01;
     this.m10 = m.m10;
     this.m11 = m.m11;
     this.m20 = m.m20;
     this.m21 = m.m21;
 }
Example #4
0
 /// <summary>
 /// Constructs this matrix from a hmat3. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public hmat4x2(hmat3 m)
 {
     this.m00 = m.m00;
     this.m01 = m.m01;
     this.m10 = m.m10;
     this.m11 = m.m11;
     this.m20 = m.m20;
     this.m21 = m.m21;
     this.m30 = Half.Zero;
     this.m31 = Half.Zero;
 }
Example #5
0
 /// <summary>
 /// Constructs this matrix from a hmat3. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public hmat2x4(hmat3 m)
 {
     this.m00 = m.m00;
     this.m01 = m.m01;
     this.m02 = m.m02;
     this.m03 = Half.Zero;
     this.m10 = m.m10;
     this.m11 = m.m11;
     this.m12 = m.m12;
     this.m13 = Half.Zero;
 }
Example #6
0
 /// <summary>
 /// Constructs this matrix from a hmat3. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public hmat3(hmat3 m)
 {
     this.m00 = m.m00;
     this.m01 = m.m01;
     this.m02 = m.m02;
     this.m10 = m.m10;
     this.m11 = m.m11;
     this.m12 = m.m12;
     this.m20 = m.m20;
     this.m21 = m.m21;
     this.m22 = m.m22;
 }
Example #7
0
 /// <summary>
 /// Constructs this matrix from a hmat3. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public hmat4x3(hmat3 m)
 {
     this.m00 = m.m00;
     this.m01 = m.m01;
     this.m02 = m.m02;
     this.m10 = m.m10;
     this.m11 = m.m11;
     this.m12 = m.m12;
     this.m20 = m.m20;
     this.m21 = m.m21;
     this.m22 = m.m22;
     this.m30 = Half.Zero;
     this.m31 = Half.Zero;
     this.m32 = Half.Zero;
 }
Example #8
0
 /// <summary>
 /// Constructs this matrix from a hmat3. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public hmat3x4(hmat3 m)
 {
     this.m00 = m.m00;
     this.m01 = m.m01;
     this.m02 = m.m02;
     this.m03 = Half.Zero;
     this.m10 = m.m10;
     this.m11 = m.m11;
     this.m12 = m.m12;
     this.m13 = Half.Zero;
     this.m20 = m.m20;
     this.m21 = m.m21;
     this.m22 = m.m22;
     this.m23 = Half.Zero;
 }
Example #9
0
        /// <summary>
        /// Creates a quaternion from the rotational part of a hmat4.
        /// </summary>
        public static hquat FromMat3(hmat3 m)
        {
            var fourXSquaredMinus1       = m.m00 - m.m11 - m.m22;
            var fourYSquaredMinus1       = m.m11 - m.m00 - m.m22;
            var fourZSquaredMinus1       = m.m22 - m.m00 - m.m11;
            var fourWSquaredMinus1       = m.m00 + m.m11 + m.m22;
            var biggestIndex             = 0;
            var fourBiggestSquaredMinus1 = fourWSquaredMinus1;

            if (fourXSquaredMinus1 > fourBiggestSquaredMinus1)
            {
                fourBiggestSquaredMinus1 = fourXSquaredMinus1;
                biggestIndex             = 1;
            }
            if (fourYSquaredMinus1 > fourBiggestSquaredMinus1)
            {
                fourBiggestSquaredMinus1 = fourYSquaredMinus1;
                biggestIndex             = 2;
            }
            if (fourZSquaredMinus1 > fourBiggestSquaredMinus1)
            {
                fourBiggestSquaredMinus1 = fourZSquaredMinus1;
                biggestIndex             = 3;
            }
            var biggestVal = Math.Sqrt((double)fourBiggestSquaredMinus1 + 1.0) * 0.5;
            var mult       = 0.25 / biggestVal;

            switch (biggestIndex)
            {
            case 0: return(new hquat((Half)((double)(m.m12 - m.m21) * mult), (Half)((double)(m.m20 - m.m02) * mult), (Half)((double)(m.m01 - m.m10) * mult), (Half)(biggestVal)));

            case 1: return(new hquat((Half)(biggestVal), (Half)((double)(m.m01 + m.m10) * mult), (Half)((double)(m.m20 + m.m02) * mult), (Half)((double)(m.m12 - m.m21) * mult)));

            case 2: return(new hquat((Half)((double)(m.m01 + m.m10) * mult), (Half)(biggestVal), (Half)((double)(m.m12 + m.m21) * mult), (Half)((double)(m.m20 - m.m02) * mult)));

            default: return(new hquat((Half)((double)(m.m20 + m.m02) * mult), (Half)((double)(m.m12 + m.m21) * mult), (Half)(biggestVal), (Half)((double)(m.m01 - m.m10) * mult)));
            }
        }
Example #10
0
 /// <summary>
 /// Executes a component-wise - (subtract).
 /// </summary>
 public static hmat3 CompSub(hmat3 A, hmat3 B) => new hmat3(A.m00 - B.m00, A.m01 - B.m01, A.m02 - B.m02, A.m10 - B.m10, A.m11 - B.m11, A.m12 - B.m12, A.m20 - B.m20, A.m21 - B.m21, A.m22 - B.m22);
Example #11
0
 /// <summary>
 /// Executes a component-wise / (divide).
 /// </summary>
 public static hmat3 CompDiv(hmat3 A, hmat3 B) => new hmat3(A.m00 / B.m00, A.m01 / B.m01, A.m02 / B.m02, A.m10 / B.m10, A.m11 / B.m11, A.m12 / B.m12, A.m20 / B.m20, A.m21 / B.m21, A.m22 / B.m22);
Example #12
0
 /// <summary>
 /// Executes a component-wise + (add).
 /// </summary>
 public static hmat3 CompAdd(hmat3 A, hmat3 B) => new hmat3(A.m00 + B.m00, A.m01 + B.m01, A.m02 + B.m02, A.m10 + B.m10, A.m11 + B.m11, A.m12 + B.m12, A.m20 + B.m20, A.m21 + B.m21, A.m22 + B.m22);
Example #13
0
 /// <summary>
 /// Returns true iff this equals rhs component-wise.
 /// </summary>
 public bool Equals(hmat3 rhs) => ((((m00.Equals(rhs.m00) && m01.Equals(rhs.m01)) && m02.Equals(rhs.m02)) && (m10.Equals(rhs.m10) && m11.Equals(rhs.m11))) && ((m12.Equals(rhs.m12) && m20.Equals(rhs.m20)) && (m21.Equals(rhs.m21) && m22.Equals(rhs.m22))));
Example #14
0
 /// <summary>
 /// Executes a component-wise * (multiply).
 /// </summary>
 public static hmat3 CompMul(hmat3 A, hmat3 B) => new hmat3(A.m00 * B.m00, A.m01 * B.m01, A.m02 * B.m02, A.m10 * B.m10, A.m11 * B.m11, A.m12 * B.m12, A.m20 * B.m20, A.m21 * B.m21, A.m22 * B.m22);
Example #15
0
 /// <summary>
 /// Creates a 2D array with all values (address: Values[x, y])
 /// </summary>
 public static Half[,] Values(hmat3 m) => m.Values;
Example #16
0
 /// <summary>
 /// Creates a 1D array with all values (internal order)
 /// </summary>
 public static Half[] Values1D(hmat3 m) => m.Values1D;
Example #17
0
 /// <summary>
 /// Creates a quaternion from the rotational part of this matrix.
 /// </summary>
 public static hquat ToQuaternion(hmat3 m) => m.ToQuaternion;
Example #18
0
 /// <summary>
 /// Returns an enumerator that iterates through all fields.
 /// </summary>
 public static IEnumerator <Half> GetEnumerator(hmat3 m) => m.GetEnumerator();
Example #19
0
 /// <summary>
 /// Creates a quaternion from the rotational part of a hmat3.
 /// </summary>
 public hquat(hmat3 m)
     : this(FromMat3(m))
 {
 }