/// <summary> /// Transforms a vector by the given matrix. /// </summary> /// <param name="position">The vector to transform.</param> /// <param name="matrix">The transform matrix.</param> /// <returns>The transformed vector.</returns> #region public static JVector Transform(JVector position, JMatrix matrix) public static FPVector Transform(FPVector position, FPMatrix matrix) { FPVector result; FPVector.Transform(ref position, ref matrix, out result); return(result); }
private void UpdateChildRotation() { FPMatrix matrix = FPMatrix.CreateFromQuaternion(_rotation); foreach (FPTransform child in tsChildren) { child.localRotation = FPQuaternion.CreateFromMatrix(FPMatrix.Inverse(matrix)) * _rotation; child.localPosition = FPVector.Transform(child.localPosition, FPMatrix.CreateFromQuaternion(child.localRotation)); child.position = TransformPoint(child.localPosition); } }
/** * @brief Rotates game object based on provided axis, point and angle of rotation. **/ public void RotateAround(FPVector point, FPVector axis, FP angle) { FPVector vector = this.position; FPVector vector2 = vector - point; vector2 = FPVector.Transform(vector2, FPMatrix.AngleAxis(angle * FP.Deg2Rad, axis)); vector = point + vector2; this.position = vector; Rotate(axis, angle); }
/** * @brief Moves game object based on provided translation vector and a relative {@link FPTransform}. * * The game object will move based on FPTransform's forward vector. **/ public void Translate(FPVector translation, FPTransform relativeTo) { this.position += FPVector.Transform(translation, FPMatrix.CreateFromQuaternion(relativeTo.rotation)); }