Example #1
0
 internal DualMatrix4x3(DualVector3 xBasis, DualVector3 yBasis, DualVector3 zBasis, DualVector3 translation) : this()
 {
     this.translation = translation;
     this.xBasis      = xBasis;
     this.yBasis      = yBasis;
     this.zBasis      = zBasis;
 }
Example #2
0
 internal DualMatrix4x3(DualVector3 translation, Quaternion rotation, DualVector3 scale) : this()
 {
     this.translation = translation;
     xBasis           = new DualVector3(rotation * (DualVector3.right * scale.x), Vector3.zero);
     yBasis           = new DualVector3(rotation * (DualVector3.up * scale.y), Vector3.zero);
     zBasis           = new DualVector3(rotation * (DualVector3.forward * scale.z), Vector3.zero);
 }
Example #3
0
 public static DualNumber SqrMagnitude(this DualVector3 vector)
 {
     return(vector.x.Squared() + vector.y.Squared() + vector.z.Squared());
 }
Example #4
0
 public static DualNumber Dot(this DualVector3 first, DualVector3 second)
 {
     return((first.x * second.x) + (first.y * second.y) + (first.z * second.z));
 }
Example #5
0
 public static DualVector3 Cross(this DualVector3 first, DualVector3 second)
 {
     return(new DualVector3((first.y * second.z) - (first.z * second.y),
                            (first.z * second.x) - (first.x * second.z),
                            (first.x * second.y) - (first.y * second.x)));
 }
Example #6
0
        /// <summary> Orthogonalizes the rotation; preserves forward then y </summary>
        public static DualMatrix4x3 Orthogonalize(this DualMatrix4x3 matrix)
        {
            DualVector3 newXBasis = matrix.yBasis.Cross(matrix.zBasis);

            return(new DualMatrix4x3(newXBasis, newXBasis.Cross(matrix.zBasis), matrix.zBasis, matrix.translation));
        }
Example #7
0
 public static DualVector3 Normalize(this DualVector3 vector)
 {
     return(vector / vector.Magnitude());
 }
Example #8
0
 public static DualNumber Magnitude(this DualVector3 vector)
 {
     return(Pow(SqrMagnitude(vector), 0.5f));
 }