Package net.phys2d.math

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


      // between the two elements cross?
      Vector2f contactPoint = new Vector2f();
      lines[closest].getClosestPoint(circleBody.getPosition(), contactPoint);
     
      Vector2f normal = MathUtil.sub(circleBody.getPosition(), contactPoint);
      normal.normalise();
      contacts[0].setNormal(normal);
      contacts[0].setPosition(contactPoint);
      contacts[0].setFeature(new FeaturePair());
     
      return 1;
View Full Code Here


   */
  public boolean isActive() {
    if (body1.getPosition().distanceSquared(body2.getPosition()) < distance) {
      Vector2f to2 = new Vector2f(body2.getPosition());
      to2.sub(body1.getPosition());
      to2.normalise();
      Vector2f vel = new Vector2f(body1.getVelocity());
      vel.normalise();
      if (body1.getVelocity().dot(to2) < 0) {
        return true;
      }
View Full Code Here

    if (body1.getPosition().distanceSquared(body2.getPosition()) < distance) {
      Vector2f to2 = new Vector2f(body2.getPosition());
      to2.sub(body1.getPosition());
      to2.normalise();
      Vector2f vel = new Vector2f(body1.getVelocity());
      vel.normalise();
      if (body1.getVelocity().dot(to2) < 0) {
        return true;
      }
    }
   
View Full Code Here

    // dp.scale(1.0f/length);
    Vector2f V = new Vector2f((float) Math.cos(originalAngle
        + body1.getRotation()), (float) Math.sin(originalAngle
        + body1.getRotation()));
    Vector2f ndp = new Vector2f(dp);
    ndp.normalise();
    float torq = (float) Math.asin(MathUtil.cross(ndp, V))
        * compressConstant / invDT;
    float P = torq / length;
    Vector2f n = new Vector2f(ndp.y, -ndp.x);
    Vector2f impulse = new Vector2f(n);
View Full Code Here

  public static Vector2f getNormal(ROVector2f x, ROVector2f y) {
    Vector2f normal = new Vector2f(y);
    normal.sub(x);
   
    normal = new Vector2f(normal.y, -normal.x);
    normal.normalise();
   
    return normal;
  }
 
//  public static Vector2f intersect(Vector2f startA, Vector2f endA, Vector2f startB, Vector2f endB) {       
View Full Code Here

    float f4 = localCircle.getRadius() * localCircle.getRadius();
    if (f3 < f4)
    {
      paramArrayOfContact[0].setPosition(localVector2f4);
      paramArrayOfContact[0].setFeature(new FeaturePair());
      localVector2f5.normalise();
      paramArrayOfContact[0].setNormal(localVector2f5);
      float f5 = (float)Math.sqrt(f3) - localCircle.getRadius();
      paramArrayOfContact[0].setSeparation(f5);
      return 1;
    }
View Full Code Here

    Vector2f localVector2f2 = paramArrayOfVector2f1[((paramIntersection.edgeA + 1) % paramArrayOfVector2f1.length)];
    Vector2f localVector2f3 = paramArrayOfVector2f2[paramIntersection.edgeB];
    Vector2f localVector2f4 = paramArrayOfVector2f2[((paramIntersection.edgeB + 1) % paramArrayOfVector2f2.length)];
    Vector2f localVector2f5 = MathUtil.getNormal(localVector2f1, localVector2f2);
    localVector2f5.sub(MathUtil.getNormal(localVector2f3, localVector2f4));
    localVector2f5.normalise();
    paramContact.setNormal(localVector2f5);
    paramContact.setSeparation(0.0F);
    paramContact.setFeature(new FeaturePair(paramIntersection.edgeA, paramIntersection.edgeB, 0, 0));
    paramContact.setPosition(paramIntersection.position);
  }
View Full Code Here

    bool = localCircle1.touches(f1, f2, localCircle2, f3, f4);
    if (!bool)
      return 0;
    Vector2f localVector2f1 = MathUtil.sub(paramBody2.getPosition(), paramBody1.getPosition());
    float f5 = localCircle1.getRadius() + localCircle2.getRadius() - localVector2f1.length();
    localVector2f1.normalise();
    Vector2f localVector2f2 = MathUtil.scale(localVector2f1, localCircle1.getRadius());
    localVector2f2.add(paramBody1.getPosition());
    paramArrayOfContact[0].setSeparation(-f5);
    paramArrayOfContact[0].setPosition(localVector2f2);
    paramArrayOfContact[0].setNormal(localVector2f1);
View Full Code Here

        Vector2f localVector2f4 = new Vector2f();
        localLine.getClosestPoint(paramBody2.getPosition(), localVector2f4);
        Vector2f localVector2f5 = new Vector2f(paramBody2.getPosition());
        localVector2f5.sub(localVector2f4);
        float f3 = localCircle.getRadius() - localVector2f5.length();
        localVector2f5.normalise();
        paramArrayOfContact[i].setSeparation(-f3);
        paramArrayOfContact[i].setPosition(localVector2f4);
        paramArrayOfContact[i].setNormal(localVector2f5);
        paramArrayOfContact[i].setFeature(new FeaturePair());
        i++;
View Full Code Here

  protected int[][] getCollisionCandidates(Vector2f[] paramArrayOfVector2f, ROVector2f paramROVector2f1, float paramFloat, ROVector2f paramROVector2f2)
  {
    Vector2f localVector2f = new Vector2f(paramROVector2f1);
    localVector2f.sub(paramROVector2f2);
    localVector2f.normalise();
    EdgeSweep localEdgeSweep = new EdgeSweep(localVector2f);
    localEdgeSweep.addVerticesToSweep(true, paramArrayOfVector2f);
    float f = paramROVector2f2.dot(localVector2f);
    localEdgeSweep.insert(0, false, -paramFloat + f);
    localEdgeSweep.insert(0, false, paramFloat + f);
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.