/// <summary> /// Get the velocity of this point on the polygon. A sum of the translational and tangential velocities at the point. /// </summary> /// <param name="pointOnPolygon">The point of the local velocity.</param> /// <returns>Returns the velocity at this point.</returns> public Vector2 GetLocalVelocity(Vector2 pointOnPolygon) { Vector2 radiusVector = pointOnPolygon - CollisionPolygon.CenterPoint; Vector2 tangentialVelocity = IntersectionEvent.CrossProduct(_angularVelocity, radiusVector); return(tangentialVelocity + _translationalVelocity); }
/// <summary> /// Applies a force at the given application point on the polygon. Will calculate torque. /// </summary> /// <param name="forceVector">The value of the force.</param> /// <param name="applicationPoint">The point on the polygon at which to apply the force.</param> public void ApplyForce(Vector2 forceVector, Vector2 applicationPoint) { AddTranslationalVelocity(forceVector * IntersectionEvent.GetLimitedRecip(Mass), isMomentum: false); Vector2 radiusVector = applicationPoint - CollisionPolygon.CenterPoint; radiusVector.Normalize(); AddAngularVelocity(IntersectionEvent.GetLimitedRecip(Inertia) * IntersectionEvent.CrossProduct(radiusVector, forceVector), isMomentum: false); }