Class Mathutils


  • public class Mathutils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Mathutils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double clamp​(double value, double low, double high)
      Returns value clamped between low and high boundaries.
      static boolean epsilonEquals​(double a, double b, double epsilon)
      Checks if two values are roughly equal to each other.
      static double getWrappedError​(double currentAngle, double desiredAngle)
      Gets the error between two angles and allows crossing the 360/0 degree boundary
      static void main​(java.lang.String[] args)  
      static double map​(double value, double input_low, double input_high, double output_low, double output_high)  
      static int mode​(int[] array)  
      static int mode​(edu.wpi.first.wpiutil.CircularBuffer array, int size)  
      static double wpiAngleTo5k​(double angle)
      Convert from the [-180-180] angles used by WPILib to the [0-360] angles used by lib5k
      static double wrapGyro​(double angle)
      This allows the angle to respect 'wrapping', where 360 and 0 are the same value
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Mathutils

        public Mathutils()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
      • wrapGyro

        public static double wrapGyro​(double angle)
        This allows the angle to respect 'wrapping', where 360 and 0 are the same value
        Parameters:
        angle - Gyroscope angle
        Returns:
        Wrapped value
      • getWrappedError

        public static double getWrappedError​(double currentAngle,
                                             double desiredAngle)
        Gets the error between two angles and allows crossing the 360/0 degree boundary
        Parameters:
        currentAngle - Current angle
        desiredAngle - Desired/goal angle
        Returns:
        Difference
      • wpiAngleTo5k

        public static double wpiAngleTo5k​(double angle)
        Convert from the [-180-180] angles used by WPILib to the [0-360] angles used by lib5k
        Parameters:
        angle - Angle
        Returns:
        Angle
      • clamp

        public static double clamp​(double value,
                                   double low,
                                   double high)
        Returns value clamped between low and high boundaries.
        Parameters:
        value - Value to clamp.
        low - The lower boundary to which to clamp value.
        high - The higher boundary to which to clamp value.
      • epsilonEquals

        public static boolean epsilonEquals​(double a,
                                            double b,
                                            double epsilon)
        Checks if two values are roughly equal to each other.
        Parameters:
        a -
        b -
        epsilon -
        Returns:
        true if a and b are within epsilon
      • map

        public static double map​(double value,
                                 double input_low,
                                 double input_high,
                                 double output_low,
                                 double output_high)
      • mode

        public static int mode​(int[] array)
      • mode

        public static int mode​(edu.wpi.first.wpiutil.CircularBuffer array,
                               int size)