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

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

Introduction

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

Prototype

Vector3D

Source Link

Usage

From source file:magma.agent.perception.impl.VisibleObjectPerceptor.java

/**
 * Default constructor
 * 
 * @param name Object name
 */
public VisibleObjectPerceptor(String name) {
    this(name, new Vector3D());
}

From source file:magma.agent.agentmodel.impl.ForceResistance.java

public ForceResistance(String name) {
    super(name);
    forceOrigin = new Vector3D();
    force = new Vector3D();
}

From source file:magma.agent.agentmodel.impl.GyroRate.java

/**
 * resets the gyro to upright position/*  w  w  w . ja va2s.co m*/
 */
public void initialize() {
    if (identity != null) {
        logger.log(Level.FINER, "gyro init old: ({0}, {1}, {2})",
                new Object[] { identity.m02, identity.m12, identity.m22 });
    }

    gyro = new Vector3D();
    identity = new Matrix3d(1, 0, 0, 0, 1, 0, 0, 0, 1);
}

From source file:magma.agent.behavior.complex.RunToPosition.java

public RunToPosition(String name, IGlobalMap worldModel, IAgentModel agentModel, BehaviorParameter params,
        Map<String, IBehavior> behaviors) {
    super(name, worldModel, agentModel, params, behaviors);

    position = new Vector3D();
    turnedLeftBefore = false;/*w  ww .  j av a 2  s  .c  o  m*/
    turnedRightBefore = false;
}

From source file:magma.agent.worldmodel.impl.MovableObject.java

public void calculateSpeed(float lastSeenTime, float time) {
    // need previousPosition, hence speed is calculated after update
    if (getPreviousPosition() != null) {
        Vector3D checkSpeed = new Vector3D();
        checkSpeed = getPosition().subtract(getPreviousPosition());
        if (time - lastSeenTime > 1)
            checkSpeed = new Vector3D(checkSpeed.getX() / (time - lastSeenTime),
                    checkSpeed.getY() / (time - lastSeenTime), checkSpeed.getZ() / (time - lastSeenTime));

        // we don't set speed for impossible values
        if (checkSpeed.getNorm() < getPossibleSpeed())
            speed = checkSpeed;/*from  w w w.j  av a 2s.c  o  m*/
    } else
        speed = new Vector3D(0.0, 0.0, 0.0);
}

From source file:magma.agent.perception.impl.ServerMessageParser.java

/**
 * Parse a symbol tree node into a Player object
 * /*from  w w  w.j  a  v  a 2 s .  co  m*/
 * @param node Symbol tree node
 * @return Player object
 * @throws PerceptorConversionException
 */
private PlayerPos parsePlayer(SymbolNode node) throws PerceptorConversionException {
    try {
        /* Parse content */
        String teamName = IMagmaConstants.UNKNOWN_PLAYER_TEAMNAME;
        int id = IMagmaConstants.UNKNOWN_PLAYER_NUMBER;
        Vector3D pol = new Vector3D();
        boolean parsedPol = false;

        for (int i = 1; i < node.childCount(); i++) {
            if (!(node.getChild(i) instanceof SymbolNode))
                throw new PerceptorConversionException("Malformed node: " + node.toString());

            SymbolNode param = (SymbolNode) node.getChild(i);

            if (param.getChild(0).content().equals("team"))
                teamName = param.getChild(1).content();
            else if (param.getChild(0).content().equals("id"))
                id = Integer.parseInt(param.getChild(1).content());

            // in case of seeing parts of opponent, we have to look into them
            else if (!parsedPol && (param.getChild(0).content().equals("head")
                    || param.getChild(0).content().equals("rlowerarm")
                    || param.getChild(0).content().equals("llowerarm")
                    || param.getChild(0).content().equals("rfoot")
                    || param.getChild(0).content().equals("lfoot"))) {
                param = (SymbolNode) param.getChild(1);
            }

            if (param.getChild(0).content().equals("pol")) {
                pol = parsePol(param);
                parsedPol = true;
            }
        }

        return new PlayerPos(pol, id, teamName);
    } catch (IndexOutOfBoundsException e) {
        throw new PerceptorConversionException("Malformed node: " + node.toString());
    }
}