|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.robotics.pathfinding.FourWayGridMesh
public class FourWayGridMesh
Generates a grid of nodes. Spacing between the grid nodes and clearance around map geometry can be specified. This set can be generated once at the beginning of a user program, and the same node set can be used for all subsequent navigation.
Constructor Summary | |
---|---|
FourWayGridMesh(LineMap map,
float gridSpace,
float clearance)
Instantiates a grid mesh of nodes which won't interconnect between any map geometry. |
Method Summary | |
---|---|
int |
addNode(Node node,
int neighbors)
Adds a node to this set and connects it with a number of neighboring nodes. |
boolean |
connect(Node node1,
Node node2)
Attempts to connect two nodes together by adding them as neighbors. |
boolean |
disconnect(Node node1,
Node node2)
Disconnects two nodes by removing them as neighbors. |
java.util.Collection<Node> |
getMesh()
Returns a collection of all nodes within this navigation mesh. |
void |
regenerate()
Throws away the previous set of nodes and recalculates them all. |
boolean |
removeNode(Node node)
Removes a node from the set and removes any existing connections with its neighbors. |
void |
setClearance(float clearance)
Changes the safety zone between all nodes/connections and map geometry. |
void |
setGridSpacing(float gridSpace)
Change the size of each grid square. |
void |
setMap(LineMap map)
Feeds this class a new map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FourWayGridMesh(LineMap map, float gridSpace, float clearance)
map
- The map containing geometry.gridSpace
- The size of each grid square.clearance
- The safety zone between all nodes/connections and the map geometry.Method Detail |
---|
public java.util.Collection<Node> getMesh()
NavigationMesh
getMesh
in interface NavigationMesh
public void setGridSpacing(float gridSpace)
gridSpace
- The unit size of each grid square.public void setClearance(float clearance)
clearance
- The safety clearance between nodes/connections and map geometry.public void setMap(LineMap map)
map
- The new map data.public void regenerate()
NavigationMesh
regenerate
in interface NavigationMesh
public boolean connect(Node node1, Node node2)
NavigationMesh
connect
in interface NavigationMesh
public boolean disconnect(Node node1, Node node2)
NavigationMesh
disconnect
in interface NavigationMesh
public int addNode(Node node, int neighbors)
addNode
in interface NavigationMesh
node
- The unconnected node to add to this mesh. Will be connected with others in the set.neighbors
- The maximum number of neighbors to attempt to connect with.
public boolean removeNode(Node node)
NavigationMesh
removeNode
in interface NavigationMesh
node
- The node to remove.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |