Package net.sf.fysix.math

Examples of net.sf.fysix.math.Vector2d


  private double throttle(double speedW, double strafeW, double rotateW) {
    double targetSpeed = getTargetSpeed();
    double targetStrafe = 0.0;
    double targetAV = 0.0;
    Vector2d v = getVelocity();
    v.rotate(-getRotation());    // Make velocity relative to the ships orientation (x=forward, y=starboard)
    double speed = v.getX();
    double strafe = v.getY();
    double tots = v.length();
    double av = getAngularVelocity();
    if (Math.signum(speed * speedW) > 0) {  // Are we moving in the direction of this engines thrust?
      // The formula below makes speed closer to total speed instead of forward/backward speed in a smooth manner.
      // This limits the thrust that otherwise had been applied when moving almost sideways to the wanted direction of movement.
      // If this limitation is not applied the ship could accelerate so that the total speed exceeds the speed limit
View Full Code Here


      if(spread>20){
        spread = -1*(spread/2);
      } else {
        spread = (spread/2);
      }
      Vector2d dir = new Vector2d(Math.cos(ph.getWorldObject().getRotation()-Math.PI-Math.toRadians(spread)), Math.sin(ph.getWorldObject().getRotation()-Math.PI-Math.toRadians(spread)));
      Vector2d pos = ph.getWorldObject().getPosition();
      pos.addScaled(9, dir);
      dust.setPosition(pos);
      dir.scale(100);
      Vector2d vel = ph.getWorldObject().getVelocity();
      dust.setVelocity(vel);
      World.getInstance().addObject(dust, true);
      dust.applyImpulse(dir);
    }   
  }
View Full Code Here

  }
 
  public Collection<Force> getForces() {
    List<Force> list = new ArrayList<Force>();
   
    Vector2d force = new Vector2d(200000.0, 0.0);
    force.scale(getMainEngineThrottle());
    list.add(new Force(new Vector2d(-7, 0.0), force));
 
    return list;
  }
View Full Code Here

      return 0;
    }
  }

  public Vector2d getGravity(Vector2d pos) {
    return new Vector2d(0, 9.82);
  }
View Full Code Here

    this.woPtr = wo;
  }

  public void copyState(WorldObject wo)
  {
    this.setPosition(new Vector2d(wo.getPosition().getX(), wo.getPosition().getY()));
    this.setVelocity(new Vector2d(wo.getVelocity().getX(), wo.getVelocity().getY()));
    this.setAngularVelocity(wo.getAngularVelocity());
   
    // Just set body to find in search... NOTE: THIS IS NOT A COPY, IT MIGHT HAVE CHANGED!!!
    this.setBody(wo.getBody());
View Full Code Here

  }

  public Vector2d getPosition() {
    if (body != null) {
      Vec2 pos = body.getPosition();
      return new Vector2d(pos.x, pos.y);
    }
    return new Vector2d(position);
  }
View Full Code Here

  }

  public Vector2d getVelocity() {
    if (body != null) {
      Vec2 vel = body.getLinearVelocity();
      return new Vector2d(vel.x, vel.y);
    }
    return new Vector2d(velocity);
  }
View Full Code Here

      body.setAngularVelocity((float) av);
    }
  }

  public void setPosition(Vector2d pos) {
    position = new Vector2d(pos);
    if (body != null) {
      body.setXForm(new Vec2((float) pos.getX(), (float) pos.getY()), body.getAngle());
    }
  }
View Full Code Here

      body.setXForm(body.getPosition(), (float) rad);
    }
  }

  public void setVelocity(Vector2d v) {
    velocity = new Vector2d(v);
    if (body != null) {
      body.setLinearVelocity(new Vec2((float) v.getX(), (float) v.getY()));
    }
  }
View Full Code Here

    }
    ShapeHandler sh = new ShapeHandler();
    sh.loadShapes(new File("config\\shapes.xml"));
   
    player1 = new PlayerHandler(input1, sh.getShapeByName("classic"));
    player1.enterCreate(world, new Vector2d(0, 0));
    player1.enterInit(world);
    player1.enterPlayActive(world);
    hud1.setPlayerShip(player1);
    pb1.setPlayerShip(player1);
   
    player2 = new PlayerHandler(input2, sh.getShapeByName("modified"));
    player2.enterCreate(world, new Vector2d(0, -400));
    player2.enterInit(world);
    player2.enterPlayActive(world);
    hud2.setPlayerShip(player2);
    pb2.setPlayerShip(player2);
   
    //planet = new Planet(60, AbstractWorldObject.TTL_INFINITE, TypeE.OBJECT_ALIVE);
    testPlanetEnvironment = new TestPlanetEnvironment(new Vector2d(300, 0))// TODO : Test
    //planet.setPosition(new Vector2d(300, 0));
    //world.addObject(planet, false);
   
    // MAP/LEVEL
    if(levelEditor == false){
View Full Code Here

TOP

Related Classes of net.sf.fysix.math.Vector2d

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.