Package xbot.common.trajectory
Class Obstacle
java.lang.Object
java.awt.geom.RectangularShape
java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Double
xbot.common.trajectory.Obstacle
- All Implemented Interfaces:
Shape
,Serializable
,Cloneable
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
Rectangle2D.Double, Rectangle2D.Float
-
Field Summary
Modifier and TypeFieldDescriptionboolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
Fields inherited from class java.awt.geom.Rectangle2D.Double
height, width, x, y
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
absorbObstacle
(Obstacle other) checkXCombination
(Translation2d first, Translation2d second) checkYCombination
(Translation2d first, Translation2d second) boolean
double
double
Finds the closest available corner of this obstacle from a given point.double
getDistanceToCenter
(Translation2d other) Gets the distance between the center of this obstacle and a given point.getIntersectionAveragePoint
(Translation2d start, Translation2d end) Finds the two intersection points of a line that passes through this obstacle, and averages them together.getLineIntersectionPoint
(Translation2d lineA1, Translation2d lineA2, Translation2d lineB1, Translation2d lineB2) Calculates the intersection point of two line segments.getLineIntersectionPoint
(Line2D.Double lineA, Line2D.Double lineB) getName()
getPointProjectionCombination
(Translation2d first, Translation2d second, Obstacle.ParallelCrossingType crossingType) void
Sets the corners back to default availability.void
restoreCorner
(Translation2d corner) void
setBonusOffset
(double bonusOffset) Methods inherited from class java.awt.geom.Rectangle2D.Double
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect, toString
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
-
Field Details
-
topLeft
-
topRight
-
bottomLeft
-
bottomRight
-
topLeftAvailable
public boolean topLeftAvailable -
topRightAvailable
public boolean topRightAvailable -
bottomLeftAvailable
public boolean bottomLeftAvailable -
bottomRightAvailable
public boolean bottomRightAvailable -
defaultTopLeft
public boolean defaultTopLeft -
defaultTopRight
public boolean defaultTopRight -
defaultBottomLeft
public boolean defaultBottomLeft -
defaultBottomRight
public boolean defaultBottomRight -
name
-
-
Constructor Details
-
Obstacle
Creates an obstacle, represented by an Axis-Aligned Bounding Box.- Parameters:
x
- CenterX of the obstacley
- CenterY of the obstaclewidth
- width (x) of the obstacleheight
- height (y) of the obstaclename
- name
-
-
Method Details
-
getName
-
getCenter
-
resetCorners
public void resetCorners()Sets the corners back to default availability. -
getDistanceToCenter
Gets the distance between the center of this obstacle and a given point.- Parameters:
other
- The given point- Returns:
- distance to that point from the center of the obstacle.
-
getIntersectionAveragePoint
Finds the two intersection points of a line that passes through this obstacle, and averages them together.- Parameters:
start
- Line x1,y1end
- Line x2,y2- Returns:
- The average intersection point, or null if there is no intersection point.
-
getLineIntersectionPoint
public Translation2d getLineIntersectionPoint(Translation2d lineA1, Translation2d lineA2, Translation2d lineB1, Translation2d lineB2) Calculates the intersection point of two line segments. Copied from https://stackoverflow.com/questions/40314303/java-find-intersection-of-line-and-rectangle- Parameters:
lineA1
- Line A x1,y1lineA2
- Line A x2,y2lineB1
- Line B x1,y1lineB2
- Line B x2,y2- Returns:
- 0,0 if the segments do not intersect.
-
getLineIntersectionPoint
-
doesPointLieAlongMidlines
-
getParallelCrossingType
-
getClosestCornerToPoint
Finds the closest available corner of this obstacle from a given point. Once it returns a point, that point is unavailable until resetCorners() is called.- Parameters:
other
- The point to measure from- Returns:
- The closest corner, or 0,0 if no corner is found.
- See Also:
-
restoreCorner
-
getBonusOffset
public double getBonusOffset() -
setBonusOffset
public void setBonusOffset(double bonusOffset) -
movePointOutsideOfBounds
-
getPointProjectionCombination
public Obstacle.PointProjectionCombination getPointProjectionCombination(Translation2d first, Translation2d second, Obstacle.ParallelCrossingType crossingType) -
checkXCombination
public Obstacle.PointProjectionCombination checkXCombination(Translation2d first, Translation2d second) -
checkYCombination
public Obstacle.PointProjectionCombination checkYCombination(Translation2d first, Translation2d second) -
absorbObstacle
-
findClosestPointOnPerimeterToPoint
-