Project290.Physics.Dynamics.Joints.FixedRevoluteJoint.FixedRevoluteJoint C# (CSharp) Method

FixedRevoluteJoint() public method

Initialize the bodies, anchors, and reference angle using the world anchor. This requires defining an anchor point where the bodies are joined. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. You also need to specify the initial relative angle for joint limits. This helps when saving and loading a game. The local anchor points are measured from the body's origin rather than the center of mass because: 1. you might not know where the center of mass will be. 2. if you add/remove shapes from a body and recompute the mass, the joints will be broken.
public FixedRevoluteJoint ( Body body, Vector2 bodyAnchor, Vector2 worldAnchor ) : System
body Body The body.
bodyAnchor Vector2 The body anchor.
worldAnchor Vector2 The world anchor.
return System
        public FixedRevoluteJoint(Body body, Vector2 bodyAnchor, Vector2 worldAnchor)
            : base(body)
        {
            JointType = JointType.FixedRevolute;

            // Changed to local coordinates.
            LocalAnchorA = bodyAnchor;
            _worldAnchor = worldAnchor;

            ReferenceAngle = -BodyA.Rotation;

            _impulse = Vector3.Zero;

            _limitState = LimitState.Inactive;
        }