/// <summary>Rotates a vector from the default orientation into a specified orientation.</summary> /// <param name="vector">The vector.</param> /// <param name="orientation">The orientation.</param> /// <returns>The rotated vector.</returns> /// <remarks>The default orientation is X = {1, 0, 0), Y = {0, 1, 0} and Z = {0, 0, 1}.</remarks> public static Vector3f Rotate(Vector3f vector, Orientation3f orientation) { float x = orientation.X.X * vector.X + orientation.Y.X * vector.Y + orientation.Z.X * vector.Z; float y = orientation.X.Y * vector.X + orientation.Y.Y * vector.Y + orientation.Z.Y * vector.Z; float z = orientation.X.Z * vector.X + orientation.Y.Z * vector.Y + orientation.Z.Z * vector.Z; return(new Vector3f(x, y, z)); }
/// <summary>Translates a vector by a specified offset that is measured along a specified orientation.</summary> /// <param name="vector">The vector.</param> /// <param name="orientation">The orientation.</param> /// <param name="offset">The offset measured in the specified orientation.</param> public static Vector3f Translate(Vector3f vector, Orientation3f orientation, Vector3f offset) { float x = vector.X + orientation.X.X * offset.X + orientation.Y.X * offset.Y + orientation.Z.X * offset.Z; float y = vector.Y + orientation.X.Y * offset.X + orientation.Y.Y * offset.Y + orientation.Z.Y * offset.Z; float z = vector.Z + orientation.X.Z * offset.X + orientation.Y.Z * offset.Y + orientation.Z.Z * offset.Z; return(new Vector3f(x, y, z)); }
/// <summary>Rotates the vector from the default orientation into a specified orientation.</summary> /// <param name="orientation">The orientation.</param> /// <remarks>The default orientation is X = {1, 0, 0), Y = {0, 1, 0} and Z = {0, 0, 1}.</remarks> public void Rotate(Orientation3f orientation) { float x = orientation.X.X * this.X + orientation.Y.X * this.Y + orientation.Z.X * this.Z; float y = orientation.X.Y * this.X + orientation.Y.Y * this.Y + orientation.Z.Y * this.Z; float z = orientation.X.Z * this.X + orientation.Y.Z * this.Y + orientation.Z.Z * this.Z; this = new Vector3f(x, y, z); }
/// <summary>Rotates a vector from the default orientation into a specified orientation.</summary> /// <param name="vector">The vector.</param> /// <param name="orientation">The orientation.</param> /// <returns>The rotated vector.</returns> /// <remarks>The default orientation is X = {1, 0, 0), Y = {0, 1, 0} and Z = {0, 0, 1}.</remarks> public static Vector3f Rotate(Vector3f vector, Orientation3f orientation) { float x = orientation.X.X * vector.X + orientation.Y.X * vector.Y + orientation.Z.X * vector.Z; float y = orientation.X.Y * vector.X + orientation.Y.Y * vector.Y + orientation.Z.Y * vector.Z; float z = orientation.X.Z * vector.X + orientation.Y.Z * vector.Y + orientation.Z.Z * vector.Z; return new Vector3f(x, y, z); }
/// <summary>Translates a vector by a specified offset that is measured along a specified orientation.</summary> /// <param name="vector">The vector.</param> /// <param name="orientation">The orientation.</param> /// <param name="offset">The offset measured in the specified orientation.</param> public static Vector3f Translate(Vector3f vector, Orientation3f orientation, Vector3f offset) { float x = vector.X + orientation.X.X * offset.X + orientation.Y.X * offset.Y + orientation.Z.X * offset.Z; float y = vector.Y + orientation.X.Y * offset.X + orientation.Y.Y * offset.Y + orientation.Z.Y * offset.Z; float z = vector.Z + orientation.X.Z * offset.X + orientation.Y.Z * offset.Y + orientation.Z.Z * offset.Z; return new Vector3f(x, y, z); }
/// <summary>Translates the vector by a specified offset that is measured in a specified orientation.</summary> /// <param name="orientation">The orientation.</param> /// <param name="offset">The offset measured in the specified orientation.</param> public void Translate(Orientation3f orientation, Vector3f offset) { this.X += orientation.X.X * offset.X + orientation.Y.X * offset.Y + orientation.Z.X * offset.Z; this.Y += orientation.X.Y * offset.X + orientation.Y.Y * offset.Y + orientation.Z.Y * offset.Z; this.Z += orientation.X.Z * offset.X + orientation.Y.Z * offset.Y + orientation.Z.Z * offset.Z; }