Package javax.vecmath

Examples of javax.vecmath.Vector2d.normalize()


  }

  private void redirectRobotToPoint(RoboterComponent rc, Point2d mouseClickedPointPosition) {
    Roboter roboter = rc.getModelObject();
    Vector2d vec = new Vector2d(mouseClickedPointPosition.getX() - roboter.getX(), mouseClickedPointPosition.getY() - roboter.getY());
    vec.normalize();
    roboter.setDirection(vec);
  }

  private void redirectRobotsToPoint(Point2d mouseClickedPointPosition) {
    Iterator<RoboterComponent> it = this.roboterComponents.iterator();
View Full Code Here


    while (it.hasNext()) {
      RoboterComponent rc = it.next();
      Roboter roboter = rc.getModelObject();
      Vector2d vec = new Vector2d(mouseClickedPointPosition.getX() - roboter.getX(), mouseClickedPointPosition.getY()
          - roboter.getY());
      vec.normalize();
      roboter.setDirection(vec);
    }
  }

  private void deselectAllSelectableSlickComponents() {
View Full Code Here

    double newRoboterPointX = (leftSpeedPoint.getX() + rightSpeedPoint.getX()) / 2;
    double newRoboterPointY = (leftSpeedPoint.getY() + rightSpeedPoint.getY()) / 2;
    Point2d newRoboterPoint = new Point2d(newRoboterPointX, newRoboterPointY);

    Vector2d topVektor = new Vector2d(rightSpeedPoint.getX() - leftSpeedPoint.getX(), rightSpeedPoint.getY() - leftSpeedPoint.getY());
    topVektor.normalize();
    Vector2d newDirectionVector = new Vector2d(topVektor.getY(), -topVektor.getX());

    RoboterMove rmove = new RoboterMove(roboter, newRoboterPoint, newDirectionVector);

    return rmove;
View Full Code Here

  }

  private Vector2d buildRightAngleVector(Vector2d vector) {
    Vector2d horizontalVector = new Vector2d(-vector.getY(), vector.getX());
    horizontalVector.normalize();
    return horizontalVector;
  }

}
View Full Code Here

    double sideY = line.sideY;
    double sideVectX = line.sideVectX;
    double sideVectY = line.sideVectY;

    Vector2d direction = rm.getNewDirectionVector();
    direction.normalize();
    RealMatrix coefficients = new Array2DRowRealMatrix(new double[][] { { direction.getX(), -(sideVectX) },
        { direction.getY(), -(sideVectY) } }, false);
    DecompositionSolver solver = new LUDecompositionImpl(coefficients).getSolver();
    RealVector constants = new ArrayRealVector(new double[] { sideX - roboter1.getX(), sideY - roboter1.getY() }, false);
    RealVector solution = solver.solve(constants);
View Full Code Here

          // ===== 1. Find if the polygons are currently intersecting =====

          // Find the axis perpendicular to the current edge
          Vector2d axis = new Vector2d(-edge.y, edge.x);
          axis.normalize();

          // Find the projection of the polygon on the current axis
          //float minA = 0; float minB = 0; float maxA = 0; float maxB = 0;
          ProjectionResult resA = ProjectPolygon(axis, polygonA);
          ProjectionResult resB = ProjectPolygon(axis, polygonB);
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

    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

    SteeringBehaviourOutput output = this.faceBehaviour.runFace(position, orientation, angularSpeed, maxAngularAcc, faceTarget);
   
    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

    SteeringBehaviourOutput output = new SteeringBehaviourOutput();
   
    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.