Package javax.vecmath

Examples of javax.vecmath.Vector2d.scale()


    if (linearInfluence!=null) {
      li = new Vector2d(linearInfluence);
      double nSpeed = li.length();
      if (nSpeed>getMaxLinearSpeed()) {
        li.normalize();
        li.scale(getMaxLinearSpeed());
      }
    }
    else {
      li = new Vector2d();
    }
View Full Code Here


    if (linearInfluence!=null) {
      li = new Vector2d(linearInfluence);
      double nSpeed = li.length();
      if (nSpeed>getMaxLinearAcceleration()) {
        li.normalize();
        li.scale(getMaxLinearAcceleration());
      }
    }
    else {
      li = new Vector2d();
    }
View Full Code Here

  }

  private Vector2d scaleVector(Vector2d v, double length, SimulationTimeManager clock) {
    Vector2d v2 = new Vector2d(v);
    if (v2.length()>0) v2.normalize();
    v2.scale(clock.perSecond(length));
    return v2;
  }

  /** Compute a steering move according to the linear move and to
   * the internal attributes of this object.
View Full Code Here

   
    Vector2d direction = new Vector2d();
    direction.sub(target,position);
   
    direction.normalize();   
    direction.scale(maxLinearSpeed);
   
    output.setLinear(direction.getX(), direction.getY());
   
    return output;
  }
View Full Code Here

    if (linearInfluence!=null) {
      li = new Vector2d(linearInfluence);
      double nSpeed = li.length();
      if (nSpeed>getMaxLinearSpeed()) {
        li.normalize();
        li.scale(getMaxLinearSpeed());
      }
    }
    else {
      li = new Vector2d();
    }
View Full Code Here

    if (linearInfluence!=null) {
      li = new Vector2d(linearInfluence);
      double nSpeed = li.length();
      if (nSpeed>getMaxLinearAcceleration()) {
        li.normalize();
        li.scale(getMaxLinearAcceleration());
      }
    }
    else {
      li = new Vector2d();
    }
View Full Code Here

    // Translate so line goes through origin
    newAtomVector.sub(start);
   
    // Magic formula
    Vector2d refVect = new Vector2d(aVector);
    refVect.scale(2*aVector.dot(newAtomVector)/aVector.dot(aVector));
    newAtomVector.sub(refVect);
   
    // Translate back
    newAtomVector.add(start);
   
View Full Code Here

    private double advectWaterParticle(double timeStep, Particle particle, int i, int j) {

        Vector2d vel = interpolator.findVelocity(particle);

        // scale the velocity by the cell size so we can assume the cells have unit dims
        vel.scale(CellDimensions.INVERSE_CELL_SIZE);

        double xChange = timeStep * vel.x;
        double yChange = timeStep * vel.y;
        particle.set( particle.x + xChange, particle.y + yChange );
        particle.incAge( timeStep );
View Full Code Here

        force_.set(force);

        acceleration_.set(force);
        acceleration_.scale( 1.0 / getMass());
        Vector2d deltaVelocity = new Vector2d(acceleration_);
        deltaVelocity.scale(timeStep);
        velocity_.add(deltaVelocity);

        position_.set(position_.x + SCALE_FACTOR * timeStep * velocity_.x,
                      position_.y + SCALE_FACTOR * timeStep * velocity_.y);
        if (isOnRamp() && position_.y < (-4)) {
View Full Code Here

    public Vector2d getProjectileAttachPoint() {
        Vector2d attachPt = getHookPosition();
        Vector2d dir = new Vector2d(projectile_.getX()-attachPt.x, projectile_.getY()-attachPt.y);
        dir.normalize();
        dir.scale(SCALE_FACTOR * length_);
        attachPt.add(dir);
        return attachPt;
    }


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.