//! multiplication operator by a vector public static Vector3D operator *(Vector3D lhs, Quaternion rhs) { Vector3D qvec = new Vector3D(rhs.X, rhs.Y, rhs.Z); Vector3D uv = qvec.CrossProduct(lhs); Vector3D uuv = qvec.CrossProduct(uv); uv *= (2.0f * rhs.W); uuv *= 2.0f; return lhs + uv + uuv; }
/// <summary> Builds a right-handed look-at matrix.</summary> public void BuildCameraLookAtMatrixRH(Vector3D position, Vector3D target, Vector3D upVector) { Vector3D zaxis = position - target; zaxis.Normalize(); Vector3D xaxis = upVector.CrossProduct(zaxis); xaxis.Normalize(); Vector3D yaxis = zaxis.CrossProduct(xaxis); SetMInsecure(0, 0, xaxis.X); SetMInsecure(1, 0, yaxis.X); SetMInsecure(2, 0, zaxis.X); SetMInsecure(3, 0, 0); SetMInsecure(0, 1, xaxis.Y); SetMInsecure(1, 1, yaxis.Y); SetMInsecure(2, 1, zaxis.Y); SetMInsecure(3, 1, 0); SetMInsecure(0, 2, xaxis.Z); SetMInsecure(1, 2, yaxis.Z); SetMInsecure(2, 2, zaxis.Z); SetMInsecure(3, 2, 0); SetMInsecure(0, 3, -xaxis.DotProduct(position)); SetMInsecure(1, 3, -yaxis.DotProduct(position)); SetMInsecure(2, 3, -zaxis.DotProduct(position)); SetMInsecure(3, 3, 1.0f); }