Ejemplo n.º 1
0
        protected override void OnRender()
        {
            var ratio = _joint4.GetRatio();
            var value = _joint1.GetJointAngle() + ratio * _joint2.GetJointAngle();

            DrawString($"theta1 + {ratio:F2} * theta2 ={value:F2}");

            ratio = _joint5.GetRatio();
            value = _joint2.GetJointAngle() + ratio * _joint3.GetJointTranslation();
            DrawString($"theta2 + {ratio:F2} * delta = {value:F2}");
        }
Ejemplo n.º 2
0
        public override void Step(Framework.Settings settings)
        {
            base.Step(settings);

            double ratio = 0.0;
            double value = 0.0;

            ratio = _joint4.GetRatio();
            value = _joint1.GetJointAngle() + ratio * _joint2.GetJointAngle();
            _debugDraw.DrawString(50, _textLine, "theta1 + {0:n} * theta2 = {1:n}", (double)ratio, (double)value);
            _textLine += 15;

            ratio = _joint5.GetRatio();
            value = _joint2.GetJointAngle() + ratio * _joint3.GetJointTranslation();
            _debugDraw.DrawString(50, _textLine, "theta2 + {0:n} * delta = {1:n}", (double)ratio, (double)value);
            _textLine += 15;
        }
Ejemplo n.º 3
0
        internal GearJoint(GearJointDef def)
            : base(def)
        {
            JointType type1 = def.joint1.JointType;
            JointType type2 = def.joint2.JointType;

            Debug.Assert(type1 == JointType.Revolute || type1 == JointType.Prismatic);
            Debug.Assert(type2 == JointType.Revolute || type2 == JointType.Prismatic);
            Debug.Assert(def.joint1.GetBody1().IsStatic);
            Debug.Assert(def.joint2.GetBody1().IsStatic);

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

            float coordinate1, coordinate2;

            _ground1 = def.joint1.GetBody1();
            _bodyA = def.joint1.GetBody2();
            if (type1 == JointType.Revolute)
            {
                _revolute1 = (RevoluteJoint)def.joint1;
                _groundAnchor1 = _revolute1._localAnchor1;
                _localAnchor1 = _revolute1._localAnchor2;
                coordinate1 = _revolute1.GetJointAngle();
            }
            else
            {
                _prismatic1 = (PrismaticJoint)def.joint1;
                _groundAnchor1 = _prismatic1._localAnchor1;
                _localAnchor1 = _prismatic1._localAnchor2;
                coordinate1 = _prismatic1.GetJointTranslation();
            }

            _ground2 = def.joint2.GetBody1();
            _bodyB = def.joint2.GetBody2();
            if (type2 == JointType.Revolute)
            {
                _revolute2 = (RevoluteJoint)def.joint2;
                _groundAnchor2 = _revolute2._localAnchor1;
                _localAnchor2 = _revolute2._localAnchor2;
                coordinate2 = _revolute2.GetJointAngle();
            }
            else
            {
                _prismatic2 = (PrismaticJoint)def.joint2;
                _groundAnchor2 = _prismatic2._localAnchor1;
                _localAnchor2 = _prismatic2._localAnchor2;
                coordinate2 = _prismatic2.GetJointTranslation();
            }

            _ratio = def.ratio;

            _ant = coordinate1 + _ratio * coordinate2;

            _impulse = 0.0f;
        }