/// <summary> /// Creates a rotation matrix from a quaternion /// </summary> /// <param name="orientation">The orientation quaternion</param> /// <returns>A rotation matrix</returns> public static Matrix4 CreateRotation(Quaternion orientation) { return new Matrix4(Matrix4d.Rotate(orientation.OpenTKEquivalent)); }
/// <summary> /// Rotates a matrix using a quaternion /// </summary> /// <param name="orientation">The orientation quaternion</param> /// <returns>A rotated matrix</returns> public void Rotate(Quaternion orientation) { OpenTKEquivalent = OpenTKEquivalent * Matrix4d.Rotate(orientation.OpenTKEquivalent); }
/// <summary> /// Set the orientation of the entity instantly. /// </summary> /// <param name="orientation">The new orientation of the entity.</param> public void SetOrientation(Quaternion orientation) { Orientation = orientation; }
internal void Integrate(double deltaTime) { Vector3 Acceleration = ForceAccumulator * InverseMass; Velocity += Acceleration * deltaTime; Position += Velocity * deltaTime; ForceAccumulator = Vector3.Zero; Vector3 AngularAcceleration = InertiaTensor * TorqueAccumulator; AngularVelocity *= new Quaternion(AngularAcceleration * deltaTime); AngularVelocity.Normalize(); Orientation *= AngularVelocity; Orientation.Normalize(); TorqueAccumulator = Vector3.Zero; CalculateTransformMatrix(); }
/// <summary> /// Set the angular velocity of the entity instantly. /// </summary> /// <param name="angularVelocity">The new angular velocity of the entity.</param> public void SetAngularVelocity(Quaternion angularVelocity) { AngularVelocity = angularVelocity; }