Example usage for org.apache.commons.math.geometry Vector3D add

List of usage examples for org.apache.commons.math.geometry Vector3D add

Introduction

In this page you can find the example usage for org.apache.commons.math.geometry Vector3D add.

Prototype

public Vector3D add(double factor, Vector3D v) 

Source Link

Document

Add a scaled vector to the instance.

Usage

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() };
}