Examples of sub()


Examples of net.phys2d.math.Vector2f.sub()

          startA.y + uA * (endA.y - startA.y));
    }
   
    Vector2f normal = endB; // reuse of vector object
    normal.set(startB);
    normal.sub(position);
    float distSquared = normal.lengthSquared();
    float radiusSquared = circle.getRadius() * circle.getRadius();
   
    if ( distSquared < radiusSquared ) {
      contacts[0].setPosition(position);
View Full Code Here

Examples of net.phys2d.math.Vector2f.sub()

      if ( dis2 < r2 ) {
        Vector2f pt = new Vector2f();
       
        line.getClosestPoint(bodyB.getPosition(), pt);
        Vector2f normal = new Vector2f(bodyB.getPosition());
        normal.sub(pt);
        float sep = circle.getRadius() - normal.length();
        normal.normalise();
       
        contacts[noContacts].setSeparation(-sep);
        contacts[noContacts].setPosition(pt);
View Full Code Here

Examples of net.phys2d.math.Vector2f.sub()

   * @param circlePos The position (center) of the circle
   * @return The list of edges that can collide with the circle
   */
  protected int[][] getCollisionCandidates(Vector2f[] vertsA, ROVector2f centroid, float radius, ROVector2f circlePos) {
    Vector2f sweepDir = new Vector2f(centroid);
    sweepDir.sub(circlePos);
    sweepDir.normalise(); //TODO: this normalization might not be necessary
   
    EdgeSweep sweep = new EdgeSweep(sweepDir);//vertsA[0], true, true, dist);
   
    sweep.addVerticesToSweep(true, vertsA);
View Full Code Here

Examples of net.phys2d.math.Vector2f.sub()

   * @return the closest point on the line or null if the lines are parallel
   */
  public static Vector2f getClosestPoint(Vector2f startA, Vector2f endA, Vector2f point) {
    Vector2f startB = point;
    Vector2f endB = new Vector2f(endA);
    endB.sub(startA);
    endB.set(endB.y, -endB.x);

    float d = endB.y * (endA.x - startA.x);
    d -= endB.x * (endA.y - startA.y);
   
View Full Code Here

Examples of net.phys2d.math.Vector2f.sub()

    Vector2f position = new Vector2f(
        startA.x + uA * (endA.x - startA.x),
        startA.y + uA * (endA.y - startA.y));
   
    Vector2f dist = new Vector2f(position);
    dist.sub(startA);
    float distFromVertA = dist.lengthSquared();
    dist = new Vector2f(position);
    dist.sub(startB);
    float distFromVertB = dist.lengthSquared();
   
View Full Code Here

Examples of net.phys2d.math.Vector2f.sub()

   
    Vector2f dist = new Vector2f(position);
    dist.sub(startA);
    float distFromVertA = dist.lengthSquared();
    dist = new Vector2f(position);
    dist.sub(startB);
    float distFromVertB = dist.lengthSquared();
   
    // z axis of 3d cross product
    float sA = (startA.x - startB.x) * (endB.y - startB.y) - (endB.x - startB.x) * (startA.y - startB.y);
   
View Full Code Here

Examples of net.phys2d.math.Vector2f.sub()

    R = new Vector2f(r1);
    R.add(dp);
    // System.out.println(accumulateImpulse);
    Vector2f relativeVelocity = new Vector2f(body2.getVelocity());
    relativeVelocity.add(MathUtil.cross(r2, body2.getAngularVelocity()));
    relativeVelocity.sub(body1.getVelocity());
    relativeVelocity.sub(MathUtil.cross(r1, body1.getAngularVelocity()));

    /*
     * Matrix2f tr1 = new Matrix2f(-body1.getRotation()); relativeVelocity =
     * MathUtil.mul(tr1, relativeVelocity);
View Full Code Here

Examples of net.phys2d.math.Vector2f.sub()

    R.add(dp);
    // System.out.println(accumulateImpulse);
    Vector2f relativeVelocity = new Vector2f(body2.getVelocity());
    relativeVelocity.add(MathUtil.cross(r2, body2.getAngularVelocity()));
    relativeVelocity.sub(body1.getVelocity());
    relativeVelocity.sub(MathUtil.cross(r1, body1.getAngularVelocity()));

    /*
     * Matrix2f tr1 = new Matrix2f(-body1.getRotation()); relativeVelocity =
     * MathUtil.mul(tr1, relativeVelocity);
     * relativeVelocity.add(MathUtil.mul(tr1, dp));
View Full Code Here

Examples of net.phys2d.math.Vector2f.sub()

    stretchedSpringConst = 100;
    compressedSpringConst = 100;
    brokenSpringConst = 100;
   
    Vector2f spring = new Vector2f(anchor1);
    spring.sub(anchor2);
    springSize = spring.length();
    minSpringSize = 0;
    maxSpringSize = 2 * springSize;
   
    set(b1,b2,anchor1,anchor2);
 
View Full Code Here

Examples of net.phys2d.math.Vector2f.sub()

    body2 = b2; 

    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    Matrix2f rot1T = rot1.transpose();
    Vector2f a1 = new Vector2f(anchor1);
    a1.sub(body1.getPosition());
    localAnchor1 = MathUtil.mul(rot1T,a1);
   
    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Matrix2f rot2T = rot2.transpose();
    Vector2f a2 = new Vector2f(anchor2);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.