Package tagalong.math

Class GeometricUtils

java.lang.Object
tagalong.math.GeometricUtils

public class GeometricUtils extends Object
Utility functions for geometric math like finding if a location is within a given 2d-shapes.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    inRange(Pose2d curPose, Rotation2d yaw, Pose2d targetPose, double xyToleranceM, double thetaToleranceDeg)
    Checks if current position is in range of the target
    static 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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • 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 robot
      yaw - current yaw (position of robot with z-axis)
      targetPose - target position
      xyToleranceM - tolerance for x and y in meters
      thetaToleranceDeg - 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 check
      Y - Y-coordinate of the point to check
      T1X - X-coordinate of the first vertex
      T1Y - Y-coordinate of the first vertex
      T2X - X-coordinate of the second vertex
      T2Y - Y-coordinate of the second vertex
      T3X - X-coordinate of the third vertex
      T3Y - 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 check
      Y - Y-coordinate of the point to check
      R1X - X-coordinate of the first vertex
      R1Y - Y-coordinate of the first vertex
      R2X - X-coordinate of the second vertex
      R2Y - Y-coordinate of the second vertex
      R3X - X-coordinate of the third vertex
      R3Y - Y-coordinate of the third vertex
      R4X - X-coordinate of the fourth vertex
      R4Y - Y-coordinate of the fourth vertex
      Returns:
      Whether or not (X, Y) falls within the rectangle specified