List of usage examples for org.apache.commons.math.geometry Vector3D getNorm
public double getNorm()
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;// w ww . ja v a2s . com } else speed = new Vector3D(0.0, 0.0, 0.0); }
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>. * // w w w . 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); }