Class SLMath

java.lang.Object
com.stuypulse.stuylib.math.SLMath

public final class SLMath extends Object
SLMath (StuyLib Math) is a class containing many algorithms that are useful for developing robot code. Algorithms include limit, deadband, raising to powers while keeping the sign, and some other new algorithms we came up with.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    clamp(double x)
    clamp input from -1 to 1
    static double
    clamp(double x, double max)
    clamp input from max to -max
    static double
    clamp(double x, double min, double max)
    clamp input from max to min
    static double
    deadband(double x, double window)
    Dead bands x value with window being the dead band.
    static double
    spow(double x, double power)
    spow (signless pow), raises a number to a power without affecting the sign of the number

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • clamp

      public static double clamp(double x, double min, double max)
      clamp input from max to min
      Parameters:
      x - input
      min - min value for x
      max - max value for x
      Returns:
      clamp input
    • clamp

      public static double clamp(double x, double max)
      clamp input from max to -max
      Parameters:
      x - input
      max - max and min value
      Returns:
      clamped input
    • clamp

      public static double clamp(double x)
      clamp input from -1 to 1
      Parameters:
      x - input
      Returns:
      clamped input
    • deadband

      public static double deadband(double x, double window)
      Dead bands x value with window being the dead band. all values for this are [-1.0...1.0]
      Parameters:
      x - value
      window - deadband window
      Returns:
      deadbanded value
    • spow

      public static double spow(double x, double power)
      spow (signless pow), raises a number to a power without affecting the sign of the number
      Parameters:
      x - input
      power - power to raise x to
      Returns:
      input ^ power