Sub() public method

Return the difference of this vector and another; does not alter either one.
public Sub ( Vec2 v ) : Vec2
v Vec2
return Vec2
 /// <summary>
 /// Initialize the bodies, anchors, and length using the world anchors.
 /// </summary>
 /// <param name="b1">First body</param>
 /// <param name="b2">Second body</param>
 /// <param name="anchor1">World anchor on first body</param>
 /// <param name="anchor2">World anchor on second body</param>
 public void Initialize(Body b1, Body b2, Vec2 anchor1, Vec2 anchor2)
 {
     BodyA = b1;
     BodyB = b2;
     LocalAnchorA.Set(BodyA.GetLocalPoint(anchor1));
     LocalAnchorB.Set(BodyB.GetLocalPoint(anchor2));
     Vec2 d = anchor2.Sub(anchor1);
     Length = d.Length();
 }
Beispiel #2
0
 /// <summary>
 /// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
 /// </summary>
 public void Initialize(Body b1, Body b2, Vec2 ga1, Vec2 ga2, Vec2 anchor1, Vec2 anchor2, float r)
 {
     BodyA = b1;
     BodyB = b2;
     GroundAnchorA = ga1;
     GroundAnchorB = ga2;
     LocalAnchorA = BodyA.GetLocalPoint(anchor1);
     LocalAnchorB = BodyB.GetLocalPoint(anchor2);
     Vec2 d1 = anchor1.Sub(ga1);
     LengthA = d1.Length();
     Vec2 d2 = anchor2.Sub(ga2);
     LengthB = d2.Length();
     Ratio = r;
     Debug.Assert(Ratio > Settings.EPSILON);
 }