public class Utils
extends java.lang.Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static double |
cap(double val,
double cap) |
static double |
deadzone(double d,
double deadzone)
Applies a deadzone to a value.
|
static double |
getDegreesToTurn(double x)
Gets how many degrees the Robot needs to turn to get x in the center of the camera's vision.
|
static double |
getDegreesToTurn(double x,
double target)
Gets how many degrees the Robot needs to turn to get x to target.
|
static double |
getDistanceFromPx(double sizeInInches,
double sizeInPx)
Gets a distance from a certain object.
|
static int |
getKeycode(char c)
Gets the keycode for a character.
|
static int |
getThreadCount()
Gets the amount of Threads running.
|
static boolean |
isIntClass(java.lang.Class c)
Checks if a Class is an Integer or int class.
|
static double |
maxDouble(double... nums)
Get the absolute value of the largest number passed of an arbitrary number of doubles
|
static double |
minMax(double val,
double min,
double max)
Taking a value, bound it with a max and a deadzone respecting the sign of the input.
|
static java.lang.String |
newLine()
Gets the new line character for the current operating system.
|
static double |
rescale(double original,
double originalScaleMax,
double newScaleMax) |
static int |
round(double d)
Rounds a Double to an Integer.
|
static double |
roundToDecimals(double number,
int decimalPlaces)
Rounds a double down to a certain amount of decimal places.
|
static double |
roundToPlace(double d,
double place) |
static void |
runInOwnThread(java.lang.Runnable r)
Runs code in it's own separate Thread.
|
static double |
sign(double d)
Returns 1 if d is positive or 0, returns -1 if d is negative.
|
public static double cap(double val, double cap)
public static double minMax(double val, double min, double max)
val
- The value to be comparedmin
- The minimum value to accept. Below this, it returns 0.max
- The maximum value to accept. Above this, it returns this.min
and max
.public static double deadzone(double d, double deadzone)
d
- The value to be deadzoned.deadzone
- The deadzone.public static double sign(double d)
d
- The number who's sign we're checking.public static double getDistanceFromPx(double sizeInInches, double sizeInPx)
sizeInPx
- The size of the object in pixels.public static double getDegreesToTurn(double x)
x
- The coordinate.public static double getDegreesToTurn(double x, double target)
x
- The coordinate.target
- Where you want x to wind up.public static double roundToDecimals(double number, int decimalPlaces)
number
- The number to be rounded.decimalPlaces
- The decimal places.public static int round(double d)
d
- The Double to be rounded.public static int getThreadCount()
public static java.lang.String newLine()
public static boolean isIntClass(java.lang.Class c)
c
- The Class to be checked.public static void runInOwnThread(java.lang.Runnable r)
r
- The code to be run.public static int getKeycode(char c)
c
- The character.public static double maxDouble(double... nums)
nums
- Doubles to search throughpublic static double roundToPlace(double d, double place)
public static double rescale(double original, double originalScaleMax, double newScaleMax)