public class CartesianPlot2D
extends java.lang.Object
IGroupParser that generates a set of IGeometric2D.| Constructor and Description |
|---|
CartesianPlot2D(IGroupParser parser) |
| Modifier and Type | Method and Description |
|---|---|
java.util.Iterator<Rect2D> |
getBoundaries() |
java.util.Iterator<IGeometric2D> |
getShapes() |
boolean |
isEmpty()
Checks whether the plot does not contain any elements.
|
boolean |
isPointInsideBorderShape(Point2D point)
Checks whether the given point is on any of the shapes of the plot.
|
boolean |
isPointInsideShape(Point2D point)
Checks whether the given point is inside any of the shapes of the plot.
|
void |
loadMap(java.io.InputStream input,
java.lang.String groupID)
Loads a map input into this Cartesian plot.
|
Point2D |
randomPoint()
Calculates a random point that is somewhere inside one of the shapes of the plot or on a border of a shape.
|
double |
rayCast(Ray2D ray)
Calculates the length of a ray until it intersects with a shape.
As this class uses the set maximum ray range to speed up this ray casting, this function may return Double.POSITIVE_INFINITY for a ray that intersects with an obstacle that is further away than the rayRange from the given starting point. |
void |
setRayRange(double rayRange)
Sets the maximum length of a rayCast after which
Double.POSITIVE_INFINITY may be returned. |
void |
setShapes(java.util.ArrayList<IGeometric2D> shapes)
Sets the set of shapes of the plot.
|
public CartesianPlot2D(IGroupParser parser)
parser - a file parser which implements IGroupParser. This parser is used to load a map file.public void setRayRange(double rayRange)
Double.POSITIVE_INFINITY may be returned.rayRange - the maximum non zero positive length, that the ray can reliably have. This parameter is used to speed up rayCast.
Set this to Double.POSITIVE_INFINITY if you like waiting.public void setShapes(java.util.ArrayList<IGeometric2D> shapes)
shapes - the set of shapes to be set.public void loadMap(java.io.InputStream input,
java.lang.String groupID)
throws java.lang.Exception
input - the stream containing the data.groupID - the identification for the group of elements that will be loaded.java.lang.Exception - thrown if the input does not contain the group.java.lang.Exception - thrown by the parser when it encounters an error in the input.public java.util.Iterator<IGeometric2D> getShapes()
public java.util.Iterator<Rect2D> getBoundaries()
public boolean isEmpty()
public Point2D randomPoint()
public double rayCast(Ray2D ray)
Double.POSITIVE_INFINITY for a ray that intersects with an obstacle that is further away than the rayRange from the given starting point.ray - the ray to be used for ray casting.public boolean isPointInsideBorderShape(Point2D point)
point - the point to be tested.public boolean isPointInsideShape(Point2D point)
point - the point to be tested.