示例#1
0
        // Point-to-point constraint
        // Cdot = v2 - v1
        //      = v2 + cross(w2, r2) - v1 - cross(w1, r1)
        // J = [-I -r1_skew I r2_skew ]
        // Identity used:
        // w k % (rx i + ry j) = w * (-ry i + rx j)

        // Angle constraint
        // Cdot = w2 - w1
        // J = [0 0 -1 0 0 1]
        // K = invI1 + invI2
        public void Initialize(Body b1, Body b2,
                               Vector2 anchor1, Vector2 anchor2)
        {
            bodyA        = b1;
            bodyB        = b2;
            localAnchorA = bodyA.GetLocalPoint(anchor1);
            localAnchorB = bodyB.GetLocalPoint(anchor2);
        }
示例#2
0
	    /// Initialize the bodies, anchors, axis, and reference angle using the world
	    /// anchor and world axis.
        public void Initialize(Body b1, Body b2, Vector2 anchor, Vector2 axis)
        {
	        bodyA = b1;
	        bodyB = b2;
	        localAnchorA = bodyA.GetLocalPoint(anchor);
	        localAnchorB = bodyB.GetLocalPoint(anchor);
	        localAxisA = bodyA.GetLocalVector(axis);
        }
示例#3
0
        // Point-to-point constraint
        // C = p2 - p1
        // Cdot = v2 - v1
        //      = v2 + cross(w2, r2) - v1 - cross(w1, r1)
        // J = [-I -r1_skew I r2_skew ]
        // Identity used:
        // w k % (rx i + ry j) = w * (-ry i + rx j)

        // Angle constraint
        // C = angle2 - angle1 - referenceAngle
        // Cdot = w2 - w1
        // J = [0 0 -1 0 0 1]
        // K = invI1 + invI2

	    public void Initialize(Body b1, Body b2, Vector2 anchor)
        {
	        bodyA = b1;
	        bodyB = b2;
	        localAnchorA = bodyA.GetLocalPoint(anchor);
	        localAnchorB = bodyB.GetLocalPoint(anchor);
            referenceAngle = bodyB.GetAngle() - bodyA.GetAngle();
        }
示例#4
0
 /// Initialize the bodies, anchors, and reference angle using the world
 /// anchor.
 public void Initialize(Body b1, Body b2, Vector2 anchor)
 {
     bodyA          = b1;
     bodyB          = b2;
     localAnchorA   = bodyA.GetLocalPoint(anchor);
     localAnchorB   = bodyB.GetLocalPoint(anchor);
     referenceAngle = bodyB.GetAngle() - bodyA.GetAngle();
 }
示例#5
0
 /// Initialize the bodies, anchors, axis, and reference angle using the world
 /// anchor and world axis.
 public void Initialize(Body b1, Body b2, Vector2 anchor, Vector2 axis)
 {
     bodyA        = b1;
     bodyB        = b2;
     localAnchorA = bodyA.GetLocalPoint(anchor);
     localAnchorB = bodyB.GetLocalPoint(anchor);
     localAxisA   = bodyA.GetLocalVector(axis);
 }
示例#6
0
        // Point-to-point constraint
        // Cdot = v2 - v1
        //      = v2 + cross(w2, r2) - v1 - cross(w1, r1)
        // J = [-I -r1_skew I r2_skew ]
        // Identity used:
        // w k % (rx i + ry j) = w * (-ry i + rx j)

        // Angle constraint
        // Cdot = w2 - w1
        // J = [0 0 -1 0 0 1]
        // K = invI1 + invI2
	    public void Initialize(Body b1, Body b2,
					    Vector2 anchor1, Vector2 anchor2)
        {
	        bodyA = b1;
	        bodyB = b2;
	        localAnchorA = bodyA.GetLocalPoint(anchor1);
	        localAnchorB = bodyB.GetLocalPoint(anchor2);
        }
示例#7
0
	    /// Initialize the bodies, anchors, and length using the world
	    /// anchors.
        // 1-D rained system
        // m (v2 - v1) = lambda
        // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.
        // x2 = x1 + h * v2

        // 1-D mass-damper-spring system
        // m (v2 - v1) + h * d * v2 + h * k * 

        // C = norm(p2 - p1) - L
        // u = (p2 - p1) / norm(p2 - p1)
        // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))
        // J = [-u -cross(r1, u) u cross(r2, u)]
        // K = J * invM * JT
        //   = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
	    public void Initialize(Body b1, Body b2,
					    Vector2 anchor1, Vector2 anchor2, float maxlength)
        {
	        bodyA = b1;
	        bodyB = b2;
	        localAnchorA = bodyA.GetLocalPoint(anchor1);
	        localAnchorB = bodyB.GetLocalPoint(anchor2);
            length = maxlength;
        }
示例#8
0
        /// Initialize the bodies, anchors, and length using the world
        /// anchors.
        // 1-D rained system
        // m (v2 - v1) = lambda
        // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.
        // x2 = x1 + h * v2

        // 1-D mass-damper-spring system
        // m (v2 - v1) + h * d * v2 + h * k *

        // C = norm(p2 - p1) - L
        // u = (p2 - p1) / norm(p2 - p1)
        // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))
        // J = [-u -cross(r1, u) u cross(r2, u)]
        // K = J * invM * JT
        //   = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
        public void Initialize(Body b1, Body b2,
                               Vector2 anchor1, Vector2 anchor2, float maxlength)
        {
            bodyA        = b1;
            bodyB        = b2;
            localAnchorA = bodyA.GetLocalPoint(anchor1);
            localAnchorB = bodyB.GetLocalPoint(anchor2);
            length       = maxlength;
        }
示例#9
0
	    /// Initialize the bodies, anchors, and length using the world
	    /// anchors.
        // 1-D rained system
        // m (v2 - v1) = lambda
        // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.
        // x2 = x1 + h * v2

        // 1-D mass-damper-spring system
        // m (v2 - v1) + h * d * v2 + h * k * 

        // C = norm(p2 - p1) - L
        // u = (p2 - p1) / norm(p2 - p1)
        // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))
        // J = [-u -cross(r1, u) u cross(r2, u)]
        // K = J * invM * JT
        //   = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
	    public void Initialize(Body b1, Body b2,
					    Vector2 anchor1, Vector2 anchor2)
        {
	        bodyA = b1;
	        bodyB = b2;
	        localAnchorA = bodyA.GetLocalPoint(anchor1);
	        localAnchorB = bodyB.GetLocalPoint(anchor2);
	        Vector2 d = anchor2 - anchor1;
	        length = d.Length();
        }
示例#10
0
        /// Initialize the bodies, anchors, and length using the world
        /// anchors.
        // 1-D rained system
        // m (v2 - v1) = lambda
        // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.
        // x2 = x1 + h * v2

        // 1-D mass-damper-spring system
        // m (v2 - v1) + h * d * v2 + h * k *

        // C = norm(p2 - p1) - L
        // u = (p2 - p1) / norm(p2 - p1)
        // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))
        // J = [-u -cross(r1, u) u cross(r2, u)]
        // K = J * invM * JT
        //   = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
        public void Initialize(Body b1, Body b2,
                               Vector2 anchor1, Vector2 anchor2)
        {
            bodyA        = b1;
            bodyB        = b2;
            localAnchorA = bodyA.GetLocalPoint(anchor1);
            localAnchorB = bodyB.GetLocalPoint(anchor2);
            Vector2 d = anchor2 - anchor1;

            length = d.Length();
        }
示例#11
0
	    /// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
        public void Initialize(Body b1, Body b2,
                        Vector2 ga1, Vector2 ga2,
					    Vector2 anchor1, Vector2 anchor2,
					    float r)
        {
	        bodyA = b1;
	        bodyB = b2;
	        groundAnchorA = ga1;
	        groundAnchorB = ga2;
	        localAnchorA = bodyA.GetLocalPoint(anchor1);
	        localAnchorB = bodyB.GetLocalPoint(anchor2);
	        Vector2 d1 = anchor1 - ga1;
	        lengthA = d1.Length();
	        Vector2 d2 = anchor2 - ga2;
	        lengthB = d2.Length();
	        ratio = r;
	        Debug.Assert(ratio > Settings.b2_epsilon);
	        float C = lengthA + ratio * lengthB;
	        maxLengthA = C - ratio * b2_minPulleyLength;
	        maxLengthB = (C - b2_minPulleyLength) / ratio;
        }
示例#12
0
文件: PullyJoint.cs 项目: Bitsits/web
        /// <summary>
        /// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
        /// </summary>
        /// <param name="b1"></param>
        /// <param name="b2"></param>
        /// <param name="ga1"></param>
        /// <param name="ga2"></param>
        /// <param name="anchor1"></param>
        /// <param name="anchor2"></param>
        /// <param name="r"></param>
        public void Initialize(Body b1, Body b2,
                               Vector2 ga1, Vector2 ga2,
                               Vector2 anchor1, Vector2 anchor2,
                               float r)
        {
            bodyA         = b1;
            bodyB         = b2;
            groundAnchorA = ga1;
            groundAnchorB = ga2;
            localAnchorA  = bodyA.GetLocalPoint(anchor1);
            localAnchorB  = bodyB.GetLocalPoint(anchor2);
            Vector2 d1 = anchor1 - ga1;

            lengthA = d1.Length();
            Vector2 d2 = anchor2 - ga2;

            lengthB = d2.Length();
            ratio   = r;
            Debug.Assert(ratio > Settings.b2_epsilon);
            float C = lengthA + ratio * lengthB;

            maxLengthA = C - ratio * b2_minPulleyLength;
            maxLengthB = (C - b2_minPulleyLength) / ratio;
        }