Package javax.vecmath

Examples of javax.vecmath.Vector2d.scale()


            // v = v0 + a * dt
            totAcc.add(fo.getAcceleration());
            totAcc.scale(deltaTime / 1000.0);
            newVelocity.add(fo.getVelocity());
            newVelocity.add(totAcc);
            newVelocity.scale(env.getEnvironmentalResistanceAtPoint(fo.getPosition()));
            fo.setVelocity(newVelocity);
        }
       
        // TODO: Collision detection
        for (int i = 0; i < fWorld.objects.size(); i++) {
View Full Code Here


            FysixObject fo = (FysixObject) i.next();
            Vector2d move;
           
            // s = v * dt
            move = (Vector2d) fo.getVelocity().clone();
            move.scale(deltaTime / 1000.0);
            fo.getPosition().add(move);
            fWorld.updateObject(fo);
        }
    }
}
View Full Code Here

//                  mat.transform(tmp);
//                  tmp.scale(50);
//                  fo.setAcceleration(new Vector2d(tmp.x, tmp.y));
//                  fo1.setDirection(theta);
                  Vector2d newAcc = new Vector2d(fo1.getDirection());
                  newAcc.scale(120);
                  fo1.setAcceleration(newAcc);
                 
                  DustObject dustObj = new DustObject();                 
                  dustObj.time = 39; // 0-39 : 40 units (map against color list)
                  dustObj.fo = (FysixObject) fe.AddObject(fo1.getPosition().x, fo1.getPosition().y, 5, null);
View Full Code Here

                  if(dustA >= Math.PI){
                    dustA -= Math.PI;
                  }
                  dustObj.fo.setDirection(dustA+Math.PI);
                  Vector2d dustAcc = new Vector2d(dustObj.fo.getDirection());
                  dustAcc.scale(220);
                  dustObj.fo.setAcceleration(dustAcc);
                  dustVector.add(dustObj);
                 
                } else {
                    fo1.setAcceleration(accNone);
View Full Code Here

                if (InputManager.isKeyDown("FIRE")) {
                  if (++delay == 6) {
                    delay = 0;
                    FysixObject fo = (FysixObject) fe.AddObject(fo1.getPosition().x, fo1.getPosition().y, 0.000000001, null);
                    Vector2d vel = (Vector2d) fo1.getDirection().clone();
                    vel.scale(450);
                    //vel.add(fo1.getVelocity());
                    fo.setVelocity(vel);
                    Polygon ba = new Polygon();
                    ba.addPoint(-1, 0);
                    ba.addPoint(1, 0);
View Full Code Here

  public KinematicBehaviourOutput runWander(Point2d position, Vector2d orientation, double linearSpeed, double maxLinearSpeed, double angularSpeed, double maxAngularSpeed) {
    KinematicBehaviourOutput output = new KinematicBehaviourOutput();
   
    Vector2d v = new Vector2d(orientation);
    if (v.length()>0) v.normalize();
    v.scale(maxLinearSpeed);
   
    output.setLinear(v.x, v.y);
   
    output.setAngular((Math.random() - Math.random()) * maxAngularSpeed);
   
 
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public SteeringBehaviourOutput runWander(Point2d position, Vector2d orientation, double linearSpeed, double maxLinearAcc, double angularSpeed, double maxAngularAcc) {
    Vector2d circleDirection = new Vector2d(orientation);
    circleDirection.scale(this.circleDistance);
   
    Point2d circleCenter = new Point2d();
    circleCenter.add(position, circleDirection);

    double deltaAngle = (Math.random() - Math.random()) * this.maxRotation;
 
View Full Code Here

    double deltaAngle = (Math.random() - Math.random()) * this.maxRotation;
    this.rotation = GeometryUtil.clamp(this.rotation+deltaAngle, -Math.PI, Math.PI);
   
    Vector2d targetDirection = new Vector2d(orientation);
    targetDirection.normalize();
    targetDirection.scale(this.circleRadius);
    GeometryUtil.turnVector(targetDirection, this.rotation);
   
    Point2d faceTarget = new Point2d();
    faceTarget.add(circleCenter, targetDirection);
       
View Full Code Here

   
    if (output==null) output = new SteeringBehaviourOutput();
   
    targetDirection = new Vector2d(orientation);
    targetDirection.normalize();
    targetDirection.scale(maxLinearAcc);
   
    output.setLinear(targetDirection.x, targetDirection.y);
   
    return output;
  }
View Full Code Here

   
    Vector2d direction = new Vector2d();
    direction.sub(target,position);
   
    direction.normalize();   
    direction.scale(maxLinearAcc);
   
    output.setLinear(direction.getX(), direction.getY());
   
    return output;
  }
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.