Package tagalong.math
Class GeometricUtils
java.lang.Object
tagalong.math.GeometricUtils
Utility functions for geometric math like finding if a location is within a
given 2d-shapes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
inRange
(Pose2d curPose, Rotation2d yaw, Pose2d targetPose, double xyToleranceM, double thetaToleranceDeg) Checks if current position is in range of the targetstatic boolean
inRectangle
(double X, double Y, double R1X, double R1Y, double R2X, double R2Y, double R3X, double R3Y, double R4X, double R4Y) static boolean
inTriangle
(double X, double Y, double T1X, double T1Y, double T2X, double T2Y, double T3X, double T3Y)
-
Constructor Details
-
GeometricUtils
public GeometricUtils()
-
-
Method Details
-
inRange
public static boolean inRange(Pose2d curPose, Rotation2d yaw, Pose2d targetPose, double xyToleranceM, double thetaToleranceDeg) Checks if current position is in range of the target- Parameters:
curPose
- current position of the robotyaw
- current yaw (position of robot with z-axis)targetPose
- target positionxyToleranceM
- tolerance for x and y in metersthetaToleranceDeg
- Tolerance in degrees- Returns:
- True if the current pose is in the specified range
-
inTriangle
public static boolean inTriangle(double X, double Y, double T1X, double T1Y, double T2X, double T2Y, double T3X, double T3Y) - Parameters:
X
- X-coordinate of the point to checkY
- Y-coordinate of the point to checkT1X
- X-coordinate of the first vertexT1Y
- Y-coordinate of the first vertexT2X
- X-coordinate of the second vertexT2Y
- Y-coordinate of the second vertexT3X
- X-coordinate of the third vertexT3Y
- Y-coordinate of the third vertex- Returns:
- Whether or not (X, Y) falls within the triangle specified
-
inRectangle
public static boolean inRectangle(double X, double Y, double R1X, double R1Y, double R2X, double R2Y, double R3X, double R3Y, double R4X, double R4Y) - Parameters:
X
- X-coordinate of the point to checkY
- Y-coordinate of the point to checkR1X
- X-coordinate of the first vertexR1Y
- Y-coordinate of the first vertexR2X
- X-coordinate of the second vertexR2Y
- Y-coordinate of the second vertexR3X
- X-coordinate of the third vertexR3Y
- Y-coordinate of the third vertexR4X
- X-coordinate of the fourth vertexR4Y
- Y-coordinate of the fourth vertex- Returns:
- Whether or not (X, Y) falls within the rectangle specified
-