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
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumNested classes/interfaces inherited from class Rectangle2D
Rectangle2D.Double, Rectangle2D.Float -
Field Summary
FieldsModifier and TypeFieldDescriptionorg.wpilib.math.geometry.Translation2dbooleanorg.wpilib.math.geometry.Translation2dbooleanbooleanbooleanbooleanbooleanorg.wpilib.math.geometry.Translation2dbooleanorg.wpilib.math.geometry.Translation2dbooleanFields inherited from class Rectangle2D.Double
height, width, x, yFields inherited from class Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabsorbObstacle(Obstacle other) checkXCombination(org.wpilib.math.geometry.Translation2d first, org.wpilib.math.geometry.Translation2d second) checkYCombination(org.wpilib.math.geometry.Translation2d first, org.wpilib.math.geometry.Translation2d second) booleandoesPointLieAlongMidlines(org.wpilib.math.geometry.Translation2d point) doublefindClosestPointOnPerimeterToPoint(org.wpilib.math.geometry.Translation2d point) doubleorg.wpilib.math.geometry.Translation2dorg.wpilib.math.geometry.Translation2dgetClosestCornerToPoint(org.wpilib.math.geometry.Translation2d other) Finds the closest available corner of this obstacle from a given point.doublegetDistanceToCenter(org.wpilib.math.geometry.Translation2d other) Gets the distance between the center of this obstacle and a given point.org.wpilib.math.geometry.Translation2dgetIntersectionAveragePoint(org.wpilib.math.geometry.Translation2d start, org.wpilib.math.geometry.Translation2d end) Finds the two intersection points of a line that passes through this obstacle, and averages them together.org.wpilib.math.geometry.Translation2dgetLineIntersectionPoint(Line2D.Double lineA, Line2D.Double lineB) org.wpilib.math.geometry.Translation2dgetLineIntersectionPoint(org.wpilib.math.geometry.Translation2d lineA1, org.wpilib.math.geometry.Translation2d lineA2, org.wpilib.math.geometry.Translation2d lineB1, org.wpilib.math.geometry.Translation2d lineB2) Calculates the intersection point of two line segments.getName()getParallelCrossingType(org.wpilib.math.geometry.Translation2d point) getPointProjectionCombination(org.wpilib.math.geometry.Translation2d first, org.wpilib.math.geometry.Translation2d second, Obstacle.ParallelCrossingType crossingType) org.wpilib.math.geometry.Translation2dmovePointOutsideOfBounds(org.wpilib.math.geometry.Translation2d point) voidSets the corners back to default availability.voidrestoreCorner(org.wpilib.math.geometry.Translation2d corner) voidsetBonusOffset(double bonusOffset) Methods inherited from class Rectangle2D.Double
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect, toStringMethods inherited from class Rectangle2D
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, unionMethods inherited from class RectangularShape
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
-
Field Details
-
topLeft
public org.wpilib.math.geometry.Translation2d topLeft -
topRight
public org.wpilib.math.geometry.Translation2d topRight -
bottomLeft
public org.wpilib.math.geometry.Translation2d bottomLeft -
bottomRight
public org.wpilib.math.geometry.Translation2d 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
public org.wpilib.math.geometry.Translation2d getCenter() -
resetCorners
public void resetCorners()Sets the corners back to default availability. -
getDistanceToCenter
public double getDistanceToCenter(org.wpilib.math.geometry.Translation2d other) 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
public org.wpilib.math.geometry.Translation2d getIntersectionAveragePoint(org.wpilib.math.geometry.Translation2d start, org.wpilib.math.geometry.Translation2d end) 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 org.wpilib.math.geometry.Translation2d getLineIntersectionPoint(org.wpilib.math.geometry.Translation2d lineA1, org.wpilib.math.geometry.Translation2d lineA2, org.wpilib.math.geometry.Translation2d lineB1, org.wpilib.math.geometry.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
public org.wpilib.math.geometry.Translation2d getLineIntersectionPoint(Line2D.Double lineA, Line2D.Double lineB) -
doesPointLieAlongMidlines
public boolean doesPointLieAlongMidlines(org.wpilib.math.geometry.Translation2d point) -
getParallelCrossingType
public Obstacle.ParallelCrossingType getParallelCrossingType(org.wpilib.math.geometry.Translation2d point) -
getClosestCornerToPoint
public org.wpilib.math.geometry.Translation2d getClosestCornerToPoint(org.wpilib.math.geometry.Translation2d other) 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
public void restoreCorner(org.wpilib.math.geometry.Translation2d corner) -
getBonusOffset
public double getBonusOffset() -
setBonusOffset
public void setBonusOffset(double bonusOffset) -
movePointOutsideOfBounds
public org.wpilib.math.geometry.Translation2d movePointOutsideOfBounds(org.wpilib.math.geometry.Translation2d point) -
getPointProjectionCombination
public Obstacle.PointProjectionCombination getPointProjectionCombination(org.wpilib.math.geometry.Translation2d first, org.wpilib.math.geometry.Translation2d second, Obstacle.ParallelCrossingType crossingType) -
checkXCombination
public Obstacle.PointProjectionCombination checkXCombination(org.wpilib.math.geometry.Translation2d first, org.wpilib.math.geometry.Translation2d second) -
checkYCombination
public Obstacle.PointProjectionCombination checkYCombination(org.wpilib.math.geometry.Translation2d first, org.wpilib.math.geometry.Translation2d second) -
absorbObstacle
-
findClosestPointOnPerimeterToPoint
public double findClosestPointOnPerimeterToPoint(org.wpilib.math.geometry.Translation2d point)
-