Package frc.team_8840_lib.utils.math
Class MathUtils
java.lang.Object
frc.team_8840_lib.utils.math.MathUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleclamp(double value, double min, double max) Clamps a value between a min and maxstatic doubledegreesToRadians(double degrees) static doubledistance(double x1, double y1, double x2, double y2) Returns the distance between (x1, y1) and (x2, y2)static doubledistance(edu.wpi.first.math.geometry.Translation2d a, edu.wpi.first.math.geometry.Translation2d b) Returns the distance between two Translation2d objectsstatic doubleinchesToMeters(double inches) static doublelerp(double a, double b, double t) static doublemetersToInches(double meters) static doublenormalizeAngle(double angle) static doubleradiansToDegrees(double radians) static doublesigmoid(double x) static doublesigmoidDerivative(double x) static doubleswerveFunc(double a) Returns a percentage used in the backend of the swerve utils.static doubleswerveFunc(double a, double end0) Returns a percentage used in the backend of the swerve utils.
-
Constructor Details
-
MathUtils
public MathUtils()
-
-
Method Details
-
sigmoid
public static double sigmoid(double x) -
sigmoidDerivative
public static double sigmoidDerivative(double x) -
degreesToRadians
public static double degreesToRadians(double degrees) -
radiansToDegrees
public static double radiansToDegrees(double radians) -
normalizeAngle
public static double normalizeAngle(double angle) -
inchesToMeters
public static double inchesToMeters(double inches) -
metersToInches
public static double metersToInches(double meters) -
lerp
public static double lerp(double a, double b, double t) -
swerveFunc
public static double swerveFunc(double a) Returns a percentage used in the backend of the swerve utils.- Parameters:
a- Time passed or whatever time measurement. Range: [0, 10]. Will start up after .5- Returns:
- Percentage of the change, range: [0, 1]
-
swerveFunc
public static double swerveFunc(double a, double end0) Returns a percentage used in the backend of the swerve utils.- Parameters:
a- Time passed or whatever time measurement. Range: [0, 9.5 + end0]. Will start up after end0.- Returns:
- Percentage of the change, range: [0, 1]
-
clamp
public static double clamp(double value, double min, double max) Clamps a value between a min and max- Parameters:
value- Value to clamp
-
distance
public static double distance(edu.wpi.first.math.geometry.Translation2d a, edu.wpi.first.math.geometry.Translation2d b) Returns the distance between two Translation2d objects- Parameters:
a- First Translation2db- Second Translation2d- Returns:
- Distance between the two Translation2d objects
-
distance
public static double distance(double x1, double y1, double x2, double y2) Returns the distance between (x1, y1) and (x2, y2)- Parameters:
x1- x value of first pointy1- y value of first pointx2- x value of second pointy2- y value of second point- Returns:
- Distance between the two points
-