Package com.marswars.util
Class GeomUtil
java.lang.Object
com.marswars.util.GeomUtil
Geometry utilities for working with translations, rotations, transforms, and poses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Pose2dstatic Twist2dMultiplies a twist by a scaling factorstatic Pose2dtoPose2d(Rotation2d rotation) Creates a pure rotated posestatic Pose2dtoPose2d(Transform2d transform) Converts a Transform2d to a Pose2d to be used as a position or as the start of a kinematic chainstatic Pose2dtoPose2d(Translation2d translation) Creates a pure translated posestatic Pose3dtoPose3d(Transform3d transform) Converts a Transform3d to a Pose3d to be used as a position or as the start of a kinematic chainstatic Transform2dtoTransform2d(double x, double y) Creates a pure translating transformstatic Transform2dtoTransform2d(Pose2d pose) Converts a Pose2d to a Transform2d to be used in a kinematic chainstatic Transform2dtoTransform2d(Rotation2d rotation) Creates a pure rotating transformstatic Transform2dtoTransform2d(Translation2d translation) Creates a pure translating transformstatic Transform3dtoTransform3d(Pose3d pose) Converts a Pose3d to a Transform3d to be used in a kinematic chainstatic Twist2dtoTwist2d(ChassisSpeeds speeds) Converts a ChassisSpeeds to a Twist2d by extracting two dimensions (Y and Z).static Pose2dwithRotation(Pose2d pose, Rotation2d rotation) Creates a new pose from an existing one using a different rotation value.static Pose2dwithTranslation(Pose2d pose, Translation2d translation) Creates a new pose from an existing one using a different translation value.
-
Constructor Details
-
GeomUtil
public GeomUtil()
-
-
Method Details
-
toTransform2d
Creates a pure translating transform- Parameters:
translation- The translation to create the transform with- Returns:
- The resulting transform
-
toTransform2d
Creates a pure translating transform- Parameters:
x- The x coordinate of the translationy- The y coordinate of the translation- Returns:
- The resulting transform
-
toTransform2d
Creates a pure rotating transform- Parameters:
rotation- The rotation to create the transform with- Returns:
- The resulting transform
-
toTransform2d
Converts a Pose2d to a Transform2d to be used in a kinematic chain- Parameters:
pose- The pose that will represent the transform- Returns:
- The resulting transform
-
inverse
-
toPose2d
Converts a Transform2d to a Pose2d to be used as a position or as the start of a kinematic chain- Parameters:
transform- The transform that will represent the pose- Returns:
- The resulting pose
-
toPose2d
Creates a pure translated pose- Parameters:
translation- The translation to create the pose with- Returns:
- The resulting pose
-
toPose2d
Creates a pure rotated pose- Parameters:
rotation- The rotation to create the pose with- Returns:
- The resulting pose
-
multiply
Multiplies a twist by a scaling factor- Parameters:
twist- The twist to multiplyfactor- The scaling factor for the twist components- Returns:
- The new twist
-
toTransform3d
Converts a Pose3d to a Transform3d to be used in a kinematic chain- Parameters:
pose- The pose that will represent the transform- Returns:
- The resulting transform
-
toPose3d
Converts a Transform3d to a Pose3d to be used as a position or as the start of a kinematic chain- Parameters:
transform- The transform that will represent the pose- Returns:
- The resulting pose
-
toTwist2d
Converts a ChassisSpeeds to a Twist2d by extracting two dimensions (Y and Z). chain- Parameters:
speeds- The original translation- Returns:
- The resulting translation
-
withTranslation
Creates a new pose from an existing one using a different translation value.- Parameters:
pose- The original posetranslation- The new translation to use- Returns:
- The new pose with the new translation and original rotation
-
withRotation
Creates a new pose from an existing one using a different rotation value.- Parameters:
pose- The original poserotation- The new rotation to use- Returns:
- The new pose with the original translation and new rotation
-