internal DualMatrix4x3(DualVector3 xBasis, DualVector3 yBasis, DualVector3 zBasis, DualVector3 translation) : this() { this.translation = translation; this.xBasis = xBasis; this.yBasis = yBasis; this.zBasis = zBasis; }
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); }
public static DualNumber SqrMagnitude(this DualVector3 vector) { return(vector.x.Squared() + vector.y.Squared() + vector.z.Squared()); }
public static DualNumber Dot(this DualVector3 first, DualVector3 second) { return((first.x * second.x) + (first.y * second.y) + (first.z * second.z)); }
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))); }
/// <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)); }
public static DualVector3 Normalize(this DualVector3 vector) { return(vector / vector.Magnitude()); }
public static DualNumber Magnitude(this DualVector3 vector) { return(Pow(SqrMagnitude(vector), 0.5f)); }