List of usage examples for org.apache.commons.math.geometry Vector3D normalize
public Vector3D normalize()
From source file:magma.agent.behavior.complex.GetInScorePosition.java
double[] getPosition() { Vector3D ballPosition = worldModel.getBall().getPosition(); IThisPlayer thisPlayer = worldModel.getThisPlayer(); Vector3D shootVector = worldModel.getOtherGoalPosition().subtract(ballPosition); Vector3D scorePosition = ballPosition.add(-0.25, shootVector.normalize()); if (thisPlayer.getDistanceTo(ballPosition) < thisPlayer.getDistanceTo(scorePosition)) { Angle delta1 = thisPlayer.getDirectionTo(ballPosition) .subtract(thisPlayer.getDirectionTo(scorePosition)); double delta = Math.abs(delta1.degrees()); if (delta < 90) { // We have to run around the ball scorePosition = calculateAlternativePosition(ballPosition, thisPlayer, scorePosition); } else if (delta < 140) { scorePosition = ballPosition.add(-BALL_KEEP_AWAY_DISTANCE, shootVector.normalize()); }//from w ww . j a v a 2s. c o m } return new double[] { scorePosition.getX(), scorePosition.getY(), shootVector.getAlpha() }; }
From source file:org.orekit.utils.Line.java
/** Build a line from a point and a direction. * @param p point belonging to the line (this can be any point) * @param direction direction of the line * @exception IllegalArgumentException if the direction norm is too small *//*from w ww .j a va 2 s . c o m*/ public Line(final Vector3D p, final Vector3D direction) { this.direction = direction.normalize(); zero = new Vector3D(1.0, p, -Vector3D.dotProduct(p, this.direction), this.direction); }
From source file:uk.ac.imperial.presage2.util.location.Location.java
/** * Get the {@link Move} from this Location towards a location <code>l</code> * with a magnitude less than or equal to <code>speed</code>. * /*from w ww. jav a 2 s.c o m*/ * @param l * @param speed * @return */ public Move getMoveTo(Location l, double speed) { Vector3D v = getVectorTo(l); if (v.getNorm() > speed) return new Move(v.normalize().scalarMultiply(speed)); else return new Move(v); }