Skip to content

Commit

Permalink
Added scaling for Translation2d's to aid in control smoothing.
Browse files Browse the repository at this point in the history
Signed-off-by: thenetworkgrinch <thenetworkgrinch@users.noreply.github.com>
  • Loading branch information
thenetworkgrinch committed Jun 12, 2024
1 parent 6c94892 commit 46a5117
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/swervelib/math/SwerveMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,16 @@ public static Translation2d cubeTranslation(Translation2d translation)
{
return new Translation2d(Math.pow(translation.getNorm(), 3), translation.getAngle());
}

/**
* Scale the {@link Translation2d} Polar coordinate magnitude.
*
* @param translation {@link Translation2d} to use.
* @param scalar Multiplier for the Polar coordinate magnitude to use.
* @return {@link Translation2d} scaled by given magnitude scalar.
*/
public static Translation2d scaleTranslation(Translation2d translation, double scalar)
{
return new Translation2d(translation.getNorm() * scalar, translation.getAngle());
}
}

0 comments on commit 46a5117

Please sign in to comment.