Example usage for org.apache.commons.math3.geometry.euclidean.twod Vector2D toArray

List of usage examples for org.apache.commons.math3.geometry.euclidean.twod Vector2D toArray

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.euclidean.twod Vector2D toArray.

Prototype

public double[] toArray() 

Source Link

Document

Get the vector coordinates as a dimension 2 array.

Usage

From source file:de.r2soft.empires.framework.map.ObjectTree.java

/**
 * Delete a node from a tree. Instead of actually deleting node and rebuilding tree, marks node as
 * deleted. Hence, it is up to the caller to rebuild the tree as needed for efficiency.
 * /*ww w  .j a  v a2s. c  o m*/
 * @param position
 */
public void delete(Vector2D position) {
    tree.delete(position.toArray());
}

From source file:de.r2soft.empires.framework.map.ObjectTree.java

/**
 * Insert a node in a KD-tree.//from w  w  w  . j  ava2s  .c om
 * 
 * @param position
 * @param value
 */
public void insert(Vector2D position, T value) {
    tree.insert(position.toArray(), value);

}

From source file:de.r2soft.empires.framework.map.ObjectTree.java

/**
 * Find KD-tree node whose key is identical to key
 * /*w w w. ja va2 s  .c  o  m*/
 * @param position
 * @return
 */
public T search(Vector2D position) {
    return (T) tree.search(position.toArray());
}

From source file:de.r2soft.empires.framework.map.ObjectTree.java

/**
 * Find KD-tree node whose key is nearest neighbor to key.
 * /*from  w  w w .j  ava 2 s .c om*/
 * @param position
 */
public T nearest(Vector2D position) {
    return (T) tree.nearest(position.toArray());
}

From source file:de.r2soft.empires.framework.map.ObjectTree.java

/**
 * Find KD-tree nodes whose keys are n nearest neighbors to key. Neighbors are returned in
 * ascending order of distance to key./*from www  .  ja v  a 2 s.  com*/
 * 
 * @param position
 * @param n
 *          Number of neighbors
 * @return
 */
public T[] nearest(Vector2D position, int n) {
    return (T[]) tree.nearest(position.toArray(), n);
}

From source file:de.r2soft.empires.framework.map.ObjectTree.java

/**
 * Range search in a KD-tree./*from  w  ww  .  j  av  a 2s. c  om*/
 * 
 * @param lowX
 *          Lower x-Axis bound
 * @param highX
 *          Higher x-Axis bound
 * @param lowY
 *          Lower y-Axis bound
 * @param highY
 *          Higher y-Axis bound
 * @return
 */
public T[] range(Vector2D lowerK, Vector2D upperK) {
    return (T[]) tree.range(lowerK.toArray(), upperK.toArray());
}

From source file:de.r2soft.empires.framework.map.ObjectTree.java

/**
 * Move an object from an old position to a new position.
 * //from www  .  ja va2s.com
 * @param oldPosition
 * @param newPosition
 */
public void move(Vector2D oldPosition, Vector2D newPosition) {
    Object obj = tree.search(oldPosition.toArray());
    tree.delete(oldPosition.toArray());
    tree.insert(newPosition.toArray(), obj);
}

From source file:io.lonelyrobot.empires.fw.game.utils.Tree2D.java

/**
 * 
 * @param pos
 * @return
 */
public T search(Vector2D pos) {
    return (T) tree.search(pos.toArray());
}

From source file:io.lonelyrobot.empires.fw.game.utils.Tree2D.java

/**
 * /*from   ww w  .  j ava2 s .  c  om*/
 * @param item
 * @param pos
 */
public void insert(T item, Vector2D pos) {
    map.put(item, pos);
    tree.insert(pos.toArray(), item);
}

From source file:io.lonelyrobot.empires.fw.game.utils.Tree2D.java

/**
 * 
 * @param item
 */
public void remove(T item) {
    Vector2D pos = map.get(item);
    map.remove(item);
    tree.delete(pos.toArray());
}