Project290.Physics.Dynamics.Body.GetLocalPoint C# (CSharp) Method

GetLocalPoint() public method

Gets a local point relative to the body's origin given a world point. Note that the vector only takes the rotation into account, not the position.
public GetLocalPoint ( Vector2 &worldPoint ) : Vector2
worldPoint Vector2 A point in world coordinates.
return Vector2
        public Vector2 GetLocalPoint(ref Vector2 worldPoint)
        {
            return new Vector2((worldPoint.X - Xf.Position.X)*Xf.R.Col1.X + (worldPoint.Y - Xf.Position.Y)*Xf.R.Col1.Y,
                               (worldPoint.X - Xf.Position.X)*Xf.R.Col2.X + (worldPoint.Y - Xf.Position.Y)*Xf.R.Col2.Y);
        }

Usage Example

Example #1
0
 /// <summary>
 /// Creates a revolute joint and adds it to the world
 /// </summary>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="localanchorB"></param>
 /// <returns></returns>
 public static RevoluteJoint CreateRevoluteJoint(Body bodyA, Body bodyB, Vector2 localanchorB)
 {
     Vector2 localanchorA = bodyA.GetLocalPoint(bodyB.GetWorldPoint(localanchorB));
     RevoluteJoint joint = new RevoluteJoint(bodyA, bodyB, localanchorA, localanchorB);
     return joint;
 }
All Usage Examples Of Project290.Physics.Dynamics.Body::GetLocalPoint