/// <summary> /// Returns Euler angles (in the YXZ convention: when decomposing, /// first Z, then X, and Y last) corresponding to the rotation /// represented by the unit quaternion. Returned vector contains /// the rotation angles in the format (X angle, Y angle, Z angle). /// </summary> /// <returns>The Euler angle representation of this quaternion.</returns> public Vector3d GetEuler() { #if DEBUG if (!IsNormalized()) { throw new InvalidOperationException("Quatd is not normalized"); } #endif var basis = new Basisd(this); return(basis.GetEuler()); }
public void SetLookAt(Vector3d eye, Vector3d target, Vector3d up) { // Make rotation matrix // Z vector Vector3d column2 = eye - target; column2.Normalize(); Vector3d column1 = up; Vector3d column0 = column1.Cross(column2); // Recompute Y = Z cross X column1 = column2.Cross(column0); column0.Normalize(); column1.Normalize(); basis = new Basisd(column0, column1, column2); origin = eye; }
public Transformd Inverse() { Basisd basisTr = basis.Transposed(); return(new Transformd(basisTr, basisTr.Xform(-origin))); }
public Transformd(Basisd basis, Vector3d origin) { this.basis = basis; this.origin = origin; }
public Transformd(Quatd quat, Vector3d origin) { basis = new Basisd(quat); this.origin = origin; }
// Constructors public Transformd(Vector3d column0, Vector3d column1, Vector3d column2, Vector3d origin) { basis = new Basisd(column0, column1, column2); this.origin = origin; }
public Transformd AffineInverse() { Basisd basisInv = basis.Inverse(); return(new Transformd(basisInv, basisInv.Xform(-origin))); }
/// <summary> /// Rotates the given Basis, interpreting this Vector4 as AxisAngle. /// </summary> public Basisd Rotated(Basisd b) { return(b * new Basisd(XYZ, w)); }
public static Vector4d AxisAngle(Basisd b) { return(AxisAngle(b.Quat())); // Might be a more efficient way to do this. }
/// <summary> /// Constructs a quaternion from the given <see cref="Basisd"/>. /// </summary> /// <param name="basis">The basis to construct from.</param> public Quatd(Basisd basis) { this = basis.Quat(); }
public Vector3d GetEuler() { var basis = new Basisd(this); return(basis.GetEuler()); }