Examples of normalise()


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

       
        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);
        contacts[noContacts].setNormal(normal);
        contacts[noContacts].setFeature(new FeaturePair());
View Full Code Here

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

   * @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.normalise()

    for (int i=0;i<count;i++) {
      Vector2f vec = MathUtil.scale(contacts[i].getNormal(),-1);
      contacts[i].setNormal(vec);
     
      Vector2f pt = MathUtil.sub(contacts[i].getPosition(), circleBody.getPosition());
      pt.normalise();
      pt.scale(((Circle) circleBody.getShape()).getRadius());
      pt.add(circleBody.getPosition());
      contacts[i].setPosition(pt);
    }
   
View Full Code Here

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

   
    Line line = (Line) bodyA.getShape();
    Box box = (Box) bodyB.getShape();
   
    Vector2f lineVec = new Vector2f(line.getDX(), line.getDY());
    lineVec.normalise()
    Vector2f axis = new Vector2f(-line.getDY(), line.getDX());
    axis.normalise();
   
    Vector2f res = new Vector2f();
    line.getStart().projectOntoUnit(axis, res);
View Full Code Here

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

    Box box = (Box) bodyB.getShape();
   
    Vector2f lineVec = new Vector2f(line.getDX(), line.getDY());
    lineVec.normalise()
    Vector2f axis = new Vector2f(-line.getDY(), line.getDX());
    axis.normalise();
   
    Vector2f res = new Vector2f();
    line.getStart().projectOntoUnit(axis, res);
    float linePos = getProp(res,axis);
   
View Full Code Here

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

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

   */
  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

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

    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

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

    // 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

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

  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
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.