Box2DX.Dynamics.GearJoint.GearJoint C# (CSharp) Method

GearJoint() public method

public GearJoint ( GearJointDef def ) : System
def GearJointDef
return System
        public GearJoint(GearJointDef def)
            : base(def)
        {
            JointType type1 = def.Joint1.GetType();
            JointType type2 = def.Joint2.GetType();

            Box2DXDebug.Assert(type1 == JointType.RevoluteJoint || type1 == JointType.PrismaticJoint);
            Box2DXDebug.Assert(type2 == JointType.RevoluteJoint || type2 == JointType.PrismaticJoint);
            Box2DXDebug.Assert(def.Joint1.GetBody1().IsStatic());
            Box2DXDebug.Assert(def.Joint2.GetBody1().IsStatic());

            _revolute1 = null;
            _prismatic1 = null;
            _revolute2 = null;
            _prismatic2 = null;

            float coordinate1, coordinate2;

            _ground1 = def.Joint1.GetBody1();
            _body1 = def.Joint1.GetBody2();
            if (type1 == JointType.RevoluteJoint)
            {
                _revolute1 = (RevoluteJoint)def.Joint1;
                _groundAnchor1 = _revolute1._localAnchor1;
                _localAnchor1 = _revolute1._localAnchor2;
                coordinate1 = _revolute1.JointAngle;
            }
            else
            {
                _prismatic1 = (PrismaticJoint)def.Joint1;
                _groundAnchor1 = _prismatic1._localAnchor1;
                _localAnchor1 = _prismatic1._localAnchor2;
                coordinate1 = _prismatic1.JointTranslation;
            }

            _ground2 = def.Joint2.GetBody1();
            _body2 = def.Joint2.GetBody2();
            if (type2 == JointType.RevoluteJoint)
            {
                _revolute2 = (RevoluteJoint)def.Joint2;
                _groundAnchor2 = _revolute2._localAnchor1;
                _localAnchor2 = _revolute2._localAnchor2;
                coordinate2 = _revolute2.JointAngle;
            }
            else
            {
                _prismatic2 = (PrismaticJoint)def.Joint2;
                _groundAnchor2 = _prismatic2._localAnchor1;
                _localAnchor2 = _prismatic2._localAnchor2;
                coordinate2 = _prismatic2.JointTranslation;
            }

            _ratio = def.Ratio;

            _constant = coordinate1 + _ratio * coordinate2;

            _impulse = 0.0f;
        }