public abstract class PolygonMapComponent extends PhysicalMapComponent implements PolygonShape
Modifier and Type | Field and Description |
---|---|
protected PathShape |
shape
The
PathShape shape of the physical obstacle. |
position
map
Constructor and Description |
---|
PolygonMapComponent(double[] x,
double[] y)
Create a wall from a list of (x,y) coordinates.
|
PolygonMapComponent(double topX,
double topY,
double width,
double height)
Creates a rectangular wall with a specified top left corner, width and
height.
|
PolygonMapComponent(double x0,
double x1,
double x2,
double x3,
double y0,
double y1,
double y2,
double y3)
Creates a wall from four corner coordinates.
|
PolygonMapComponent(java.util.List<Position> corners)
Create a wall from a list of corner
Position s. |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.util.List<Position> positions)
Determines if a point out of a set of points is contained in a shape.
|
boolean |
contains(Position position)
Determines if the shape contains a position.
|
Position |
generatePosition()
Generates a position inside the shape.
|
Position |
generatePosition(RandomPlus randomGenerator)
Generates a position inside the shape.
|
java.util.List<Position> |
generatePositions(int numberOfPositions)
Generates a set of positions inside the shape.
|
java.util.List<Position> |
generatePositions(int numberOfPositions,
RandomPlus randomGenerator)
Generates a set of positions inside the shape.
|
java.util.List<Position> |
getCorners()
Gets the list of corner
Position s. |
private PathShape |
getShape()
Gets the
PathShape shape of the physical obstacle. |
Vector |
getVectorToPosition(Position position)
|
boolean |
isCollision(PolygonMapComponent other)
Determines if two
PolygonMapComponent s intersect. |
boolean |
isLineCollision(Position start,
Position end)
Determines if a line intersects with the
PhysicalMapComponent . |
java.lang.String |
toString() |
getDistance, getPosition
isDestroyed
public PolygonMapComponent(double topX, double topY, double width, double height)
topX
- The x coordinate of the top left corner.topY
- The y coordinate of the top left corner.width
- The width of the wall.height
- The height of the wall.public PolygonMapComponent(double x0, double x1, double x2, double x3, double y0, double y1, double y2, double y3)
x0
- The first x coordinate.x1
- The second x coordinate.x2
- The third x coordinate.x3
- The fourth x coordinate.y0
- The first y coordinate.y1
- The second y coordinate.y2
- The third y coordinate.y3
- The fourth y coordinate.public PolygonMapComponent(double[] x, double[] y)
x
- The x coordinates.y
- The y coordinates.public boolean contains(java.util.List<Position> positions)
positions
- The points.public boolean contains(Position position)
position
- The position.public Position generatePosition()
public Position generatePosition(RandomPlus randomGenerator)
randomGenerator
- The random generator.public java.util.List<Position> generatePositions(int numberOfPositions)
numberOfPositions
- The number of positions we want to generate.public java.util.List<Position> generatePositions(int numberOfPositions, RandomPlus randomGenerator)
numberOfPositions
- The number of positions we want to generate.randomGenerator
- The random generator.public java.util.List<Position> getCorners()
Position
s.getCorners
in interface PolygonShape
private PathShape getShape()
PathShape
shape of the physical obstacle.public Vector getVectorToPosition(Position position)
PhysicalMapComponent
getVectorToPosition
in class PhysicalMapComponent
position
- The first position.public boolean isCollision(PolygonMapComponent other)
PolygonMapComponent
s intersect.other
- The second shape.public boolean isLineCollision(Position start, Position end)
PhysicalMapComponent
PhysicalMapComponent
.isLineCollision
in class PhysicalMapComponent
start
- The start position of the line.end
- The end position of the line.public java.lang.String toString()
toString
in class java.lang.Object