Package com.marswars.geometry
Class AllianceFlipUtil
java.lang.Object
com.marswars.geometry.AllianceFlipUtil
Utility class for flipping geometric coordinates between alliance perspectives in FRC.
This class provides methods to transform coordinates, poses, and regions based on field symmetry.
The utility supports two types of field symmetry:
- DIAGONAL - Rotates coordinates 180 degrees around the field center
- DIRECT - Mirrors coordinates horizontally across the field center
Before using any transformation methods, the field geometry must be configured using
configureFieldGeometry(SymmetryType, Translation2d).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of field symmetry types for alliance coordinate transformation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CircularRegionapply(CircularRegion region) Applies alliance flip transformation to a circular region.static PolygonRegionapply(PolygonRegion region) Applies alliance flip transformation to a polygon region.static RegionApplies alliance flip transformation to a region.static TightRopeApplies alliance flip transformation to a tight rope path.static Pose2dApplies alliance flip transformation to a 2D pose.static Pose3dApplies alliance flip transformation to a 3D pose.static Translation2dapply(Translation2d translation) Applies alliance flip transformation to a 2D translation.static Translation3dapply(Translation3d translation) Applies alliance flip transformation to a 3D translation.static voidconfigureFieldGeometry(AllianceFlipUtil.SymmetryType symmetry, Translation2d field_center) Configures the field geometry for alliance coordinate transformations.
-
Constructor Details
-
AllianceFlipUtil
public AllianceFlipUtil()
-
-
Method Details
-
configureFieldGeometry
public static void configureFieldGeometry(AllianceFlipUtil.SymmetryType symmetry, Translation2d field_center) Configures the field geometry for alliance coordinate transformations. This method must be called before using any transformation methods.- Parameters:
symmetry- the type of field symmetry (DIAGONAL or DIRECT)field_center- the center point of the field
-
apply
Applies alliance flip transformation to a 2D translation.- Parameters:
translation- the original translation to transform- Returns:
- the transformed translation from the opposite alliance perspective
- Throws:
IllegalStateException- if the utility has not been configured
-
apply
Applies alliance flip transformation to a 3D translation.- Parameters:
translation- the original 3D translation to transform- Returns:
- the transformed 3D translation from the opposite alliance perspective
- Throws:
IllegalStateException- if the utility has not been configured
-
apply
Applies alliance flip transformation to a 2D pose. Transforms both the translation and rotation components.- Parameters:
pose- the original 2D pose to transform- Returns:
- the transformed 2D pose from the opposite alliance perspective
- Throws:
IllegalStateException- if the utility has not been configured
-
apply
Applies alliance flip transformation to a 3D pose. Transforms both the translation and rotation components.- Parameters:
pose- the original 3D pose to transform- Returns:
- the transformed 3D pose from the opposite alliance perspective
- Throws:
IllegalStateException- if the utility has not been configured
-
apply
Applies alliance flip transformation to a region. Automatically determines the region type and applies the appropriate transformation.- Parameters:
region- the original region to transform (PolygonRegion or CircularRegion)- Returns:
- the transformed region from the opposite alliance perspective
- Throws:
IllegalStateException- if the utility has not been configured
-
apply
Applies alliance flip transformation to a polygon region. Transforms all vertices of the polygon.- Parameters:
region- the original polygon region to transform- Returns:
- the transformed polygon region from the opposite alliance perspective
- Throws:
IllegalStateException- if the utility has not been configured
-
apply
Applies alliance flip transformation to a circular region. Transforms the center point while preserving the radius.- Parameters:
region- the original circular region to transform- Returns:
- the transformed circular region from the opposite alliance perspective
- Throws:
IllegalStateException- if the utility has not been configured
-
apply
Applies alliance flip transformation to a tight rope path. Transforms both endpoint poses and swaps their order to maintain path direction.- Parameters:
tightRope- the original tight rope path to transform- Returns:
- the transformed tight rope path from the opposite alliance perspective
- Throws:
IllegalStateException- if the utility has not been configured
-