Class GeomUtil

java.lang.Object
com.marswars.util.GeomUtil

public class GeomUtil extends Object
Geometry utilities for working with translations, rotations, transforms, and poses.
  • Constructor Details

    • GeomUtil

      public GeomUtil()
  • Method Details

    • toTransform2d

      public static Transform2d toTransform2d(Translation2d translation)
      Creates a pure translating transform
      Parameters:
      translation - The translation to create the transform with
      Returns:
      The resulting transform
    • toTransform2d

      public static Transform2d toTransform2d(double x, double y)
      Creates a pure translating transform
      Parameters:
      x - The x coordinate of the translation
      y - The y coordinate of the translation
      Returns:
      The resulting transform
    • toTransform2d

      public static Transform2d toTransform2d(Rotation2d rotation)
      Creates a pure rotating transform
      Parameters:
      rotation - The rotation to create the transform with
      Returns:
      The resulting transform
    • toTransform2d

      public static Transform2d toTransform2d(Pose2d pose)
      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

      public static Pose2d inverse(Pose2d pose)
    • toPose2d

      public static Pose2d toPose2d(Transform2d transform)
      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

      public static Pose2d toPose2d(Translation2d translation)
      Creates a pure translated pose
      Parameters:
      translation - The translation to create the pose with
      Returns:
      The resulting pose
    • toPose2d

      public static Pose2d toPose2d(Rotation2d rotation)
      Creates a pure rotated pose
      Parameters:
      rotation - The rotation to create the pose with
      Returns:
      The resulting pose
    • multiply

      public static Twist2d multiply(Twist2d twist, double factor)
      Multiplies a twist by a scaling factor
      Parameters:
      twist - The twist to multiply
      factor - The scaling factor for the twist components
      Returns:
      The new twist
    • toTransform3d

      public static Transform3d toTransform3d(Pose3d pose)
      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

      public static Pose3d toPose3d(Transform3d transform)
      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

      public static Twist2d toTwist2d(ChassisSpeeds speeds)
      Converts a ChassisSpeeds to a Twist2d by extracting two dimensions (Y and Z). chain
      Parameters:
      speeds - The original translation
      Returns:
      The resulting translation
    • withTranslation

      public static Pose2d withTranslation(Pose2d pose, Translation2d translation)
      Creates a new pose from an existing one using a different translation value.
      Parameters:
      pose - The original pose
      translation - The new translation to use
      Returns:
      The new pose with the new translation and original rotation
    • withRotation

      public static Pose2d withRotation(Pose2d pose, Rotation2d rotation)
      Creates a new pose from an existing one using a different rotation value.
      Parameters:
      pose - The original pose
      rotation - The new rotation to use
      Returns:
      The new pose with the original translation and new rotation