List of usage examples for org.apache.commons.math.geometry Vector3D add
public Vector3D add(double factor, Vector3D v)
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()); }//w ww .j av a 2 s . co m } return new double[] { scorePosition.getX(), scorePosition.getY(), shootVector.getAlpha() }; }