Package net.phys2d.math

Examples of net.phys2d.math.ROVector2f


    return slider;
  }
 
  public Body addJumpingSoldier(float footX, float footY) {
    float oldMass = setMass(JumpingSoldier.MASS);
    ROVector2f oldPosition = setPosition(new Vector2f(footX + JumpingSoldier.WIDTH / 2.0f, footY - JumpingSoldier.HEIGHT / 2.0f));
    Body soldier = addAxisAlignedBox(new JumpingSoldier(), JumpingSoldier.WIDTH, JumpingSoldier.HEIGHT);
    setMass(oldMass);
    setPosition(oldPosition);
    return soldier;
  }
View Full Code Here


    this.camera = camera;
  }
 
  public void doCameraTranslation(Graphics g) {
    if(this.camera != null) {
      ROVector2f translation = this.camera.getPosition();
      g.translate(-translation.getX(), Math.max(-translation.getY(), -20.5f + Engine.getInstance().getHeight() / 2.0f / ZOOM));
    }
  }
View Full Code Here

    for ( PhysicalSensor s : physSensors )
      s.translate(dx, dy);
  }
 
  private void rotateSensors(double angle) {
    ROVector2f pos = getPosition();
    for ( PhysicalSensor s : physSensors )
      s.rotate(angle, pos.getX(), pos.getY());
  }
View Full Code Here

    return getShape();
  }

  @Override
  public Point2D getLocation() {
    ROVector2f pos = getPosition();
    return new Point2D.Double(pos.getX(), pos.getY());
  }
View Full Code Here

    return getPosition().getY();
  }

  @Override
  public Point2D getSpeed() {
    ROVector2f v = getVelocity();
    return new Point2D.Double(v.getX(), v.getY());
  }
View Full Code Here

            for(int w = 0; w < cells.length; w++)
              if ( cells[w][h].intersects(bounds) )
                cells[w][h].addBody(b);
      }
      else {
        ROVector2f pos = b.getPosition();
        GridCell cell = grid.getCell(pos.getX(), pos.getY());
        cell.addBody(b);
        if ( !b.isStatic() ) {
          Set<GridCell> cells = new HashSet<GridCell>(6);
          cells.add(cell);
          currentCells.put(b, cells);
        }
        if ( !cell.contains(bounds) ) {
          GridCell[] neighbours = cell.getQuadrantNeightbours(pos.getX(), pos.getY());
          for ( int i = 0; i < neighbours.length; i++ )
            if ( neighbours[i].intersects(bounds) ) {
              neighbours[i].addBody(b);
              if ( !b.isStatic() )
                currentCells.get(b).add(neighbours[i]);
View Full Code Here

            for(int w = 0; w < cells.length; w++)
              if ( cells[w][h].intersects(bounds) )
                cells[w][h].removeBody((net.javlov.world.Body)b);
      }
      else {
        ROVector2f pos = b.getPosition();
        GridCell cell = grid.getCell(pos.getX(), pos.getY());
        cell.removeBody((net.javlov.world.Body)b);
        if ( !b.isStatic() )
          currentCells.remove(b);
        if ( !cell.contains(bounds) ) {
          GridCell[] neighbours = cell.getQuadrantNeightbours(pos.getX(), pos.getY());
          for ( int i = 0; i < neighbours.length; i++ )
            if ( neighbours[i].intersects(bounds) )
              neighbours[i].removeBody((net.javlov.world.Body)b);
        }       
      }
View Full Code Here

    Line localLine = (Line)paramBody1.getShape();
    Circle localCircle = (Circle)paramBody2.getShape();
    Vector2f[] arrayOfVector2f = localLine.getVertices(paramBody1.getPosition(), paramBody1.getRotation());
    Vector2f localVector2f1 = arrayOfVector2f[0];
    Vector2f localVector2f2 = arrayOfVector2f[1];
    ROVector2f localROVector2f = paramBody2.getPosition();
    Vector2f localVector2f3 = new Vector2f(localVector2f2);
    localVector2f3.sub(localVector2f1);
    localVector2f3.set(localVector2f3.y, -localVector2f3.x);
    float f1 = localVector2f3.y * (localVector2f2.x - localVector2f1.x);
    f1 -= localVector2f3.x * (localVector2f2.y - localVector2f1.y);
    float f2 = localVector2f3.x * (localVector2f1.y - localROVector2f.getY());
    f2 -= localVector2f3.y * (localVector2f1.x - localROVector2f.getX());
    f2 /= f1;
    Vector2f localVector2f4 = null;
    if (f2 < 0.0F)
      localVector2f4 = localVector2f1;
    else if (f2 > 1.0F)
View Full Code Here

      return 0;
    hA.set(((Box)paramBody1.getShape()).getSize());
    hA.scale(0.5F);
    hB.set(((Box)paramBody2.getShape()).getSize());
    hB.scale(0.5F);
    ROVector2f localROVector2f1 = paramBody1.getPosition();
    ROVector2f localROVector2f2 = paramBody2.getPosition();
    Matrix2f localMatrix2f1 = new Matrix2f(paramBody1.getRotation());
    Matrix2f localMatrix2f2 = new Matrix2f(paramBody2.getRotation());
    Matrix2f localMatrix2f3 = localMatrix2f1.transpose();
    Matrix2f localMatrix2f4 = localMatrix2f2.transpose();
    Vector2f localVector2f1 = MathUtil.sub(localROVector2f2, localROVector2f1);
    Vector2f localVector2f2 = MathUtil.mul(localMatrix2f3, localVector2f1);
    Vector2f localVector2f3 = MathUtil.mul(localMatrix2f4, localVector2f1);
    Matrix2f localMatrix2f5 = MathUtil.mul(localMatrix2f3, localMatrix2f2);
    Matrix2f localMatrix2f6 = MathUtil.abs(localMatrix2f5);
    Matrix2f localMatrix2f7 = localMatrix2f6.transpose();
    Vector2f localVector2f4 = MathUtil.abs(localVector2f2);
    localVector2f4.sub(hA);
    localVector2f4.sub(MathUtil.mul(localMatrix2f6, hB));
    if ((localVector2f4.x > 0.0F) || (localVector2f4.y > 0.0F))
      return 0;
    Vector2f localVector2f5 = MathUtil.abs(localVector2f3);
    localVector2f5.sub(MathUtil.mul(localMatrix2f7, hA));
    localVector2f5.sub(hB);
    if ((localVector2f5.x > 0.0F) || (localVector2f5.y > 0.0F))
      return 0;
    int i = 1;
    float f5 = localVector2f4.x;
    Vector2f localVector2f6 = localVector2f2.x > 0.0F ? localMatrix2f1.col1 : MathUtil.scale(localMatrix2f1.col1, -1.0F);
    if (localVector2f4.y > 1.05F * f5 + 0.01F * hA.y)
    {
      i = 2;
      f5 = localVector2f4.y;
      localVector2f6 = localVector2f2.y > 0.0F ? localMatrix2f1.col2 : MathUtil.scale(localMatrix2f1.col2, -1.0F);
    }
    if (localVector2f5.x > 1.05F * f5 + 0.01F * hB.x)
    {
      i = 3;
      f5 = localVector2f5.x;
      localVector2f6 = localVector2f3.x > 0.0F ? localMatrix2f2.col1 : MathUtil.scale(localMatrix2f2.col1, -1.0F);
    }
    if (localVector2f5.y > 1.05F * f5 + 0.01F * hB.y)
    {
      i = 4;
      f5 = localVector2f5.y;
      localVector2f6 = localVector2f3.y > 0.0F ? localMatrix2f2.col2 : MathUtil.scale(localMatrix2f2.col2, -1.0F);
    }
    ClipVertex[] arrayOfClipVertex1 = { new ClipVertex(), new ClipVertex() };
    Vector2f localVector2f7;
    float f6;
    Vector2f localVector2f8;
    float f9;
    float f7;
    float f8;
    char c1;
    char c2;
    switch (i)
    {
    case 1:
      localVector2f7 = localVector2f6;
      f6 = localROVector2f1.dot(localVector2f7) + hA.x;
      localVector2f8 = localMatrix2f1.col2;
      f9 = localROVector2f1.dot(localVector2f8);
      f7 = -f9 + hA.y;
      f8 = f9 + hA.y;
      c1 = '\003';
      c2 = '\001';
      computeIncidentEdge(arrayOfClipVertex1, hB, localROVector2f2, localMatrix2f2, localVector2f7);
      break;
    case 2:
      localVector2f7 = localVector2f6;
      f6 = localROVector2f1.dot(localVector2f7) + hA.y;
      localVector2f8 = localMatrix2f1.col1;
      f9 = localROVector2f1.dot(localVector2f8);
      f7 = -f9 + hA.x;
      f8 = f9 + hA.x;
      c1 = '\002';
      c2 = '\004';
      computeIncidentEdge(arrayOfClipVertex1, hB, localROVector2f2, localMatrix2f2, localVector2f7);
      break;
    case 3:
      localVector2f7 = MathUtil.scale(localVector2f6, -1.0F);
      f6 = localROVector2f2.dot(localVector2f7) + hB.x;
      localVector2f8 = localMatrix2f2.col2;
      f9 = localROVector2f2.dot(localVector2f8);
      f7 = -f9 + hB.y;
      f8 = f9 + hB.y;
      c1 = '\003';
      c2 = '\001';
      computeIncidentEdge(arrayOfClipVertex1, hA, localROVector2f1, localMatrix2f1, localVector2f7);
      break;
    case 4:
      localVector2f7 = MathUtil.scale(localVector2f6, -1.0F);
      f6 = localROVector2f2.dot(localVector2f7) + hB.y;
      localVector2f8 = localMatrix2f2.col1;
      f9 = localROVector2f2.dot(localVector2f8);
      f7 = -f9 + hB.x;
      f8 = f9 + hB.x;
      c1 = '\002';
      c2 = '\004';
      computeIncidentEdge(arrayOfClipVertex1, hA, localROVector2f1, localMatrix2f1, localVector2f7);
View Full Code Here

TOP

Related Classes of net.phys2d.math.ROVector2f

Copyright © 2018 www.massapicom. 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.