Class MathUtils

java.lang.Object
frc.team_8840_lib.utils.math.MathUtils

public class MathUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    clamp(double value, double min, double max)
    Clamps a value between a min and max
    static double
    degreesToRadians(double degrees)
     
    static double
    distance(double x1, double y1, double x2, double y2)
    Returns the distance between (x1, y1) and (x2, y2)
    static double
    distance(edu.wpi.first.math.geometry.Translation2d a, edu.wpi.first.math.geometry.Translation2d b)
    Returns the distance between two Translation2d objects
    static double
    inchesToMeters(double inches)
     
    static double
    lerp(double a, double b, double t)
     
    static double
    metersToInches(double meters)
     
    static double
    normalizeAngle(double angle)
     
    static double
    radiansToDegrees(double radians)
     
    static double
    sigmoid(double x)
     
    static double
     
    static double
    swerveFunc(double a)
    Returns a percentage used in the backend of the swerve utils.
    static double
    swerveFunc(double a, double end0)
    Returns a percentage used in the backend of the swerve utils.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 Translation2d
      b - 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 point
      y1 - y value of first point
      x2 - x value of second point
      y2 - y value of second point
      Returns:
      Distance between the two points