Files
PhotonVision/Main/src/main/java/com/chameleonvision/util/MathHandler.java

28 lines
631 B
Java
Raw Normal View History

package com.chameleonvision.util;
2019-09-29 00:05:20 +03:00
import java.lang.Math;
import edu.wpi.first.wpiutil.math.Num;
2019-10-07 21:15:17 +03:00
import org.apache.commons.math3.util.FastMath;
2019-09-29 00:05:20 +03:00
public class MathHandler {
MathHandler() {}
public static double sigmoid(Number x){
2019-09-29 00:05:20 +03:00
double bias = 0;
double a = 5;
double b = -0.05;
double k = 200;
if (x.doubleValue() < 50){
2019-09-28 14:27:50 -07:00
bias = -1.338;
2019-09-29 00:05:20 +03:00
}
return ((k / (1 + Math.pow(Math.E,(a + (b * x.doubleValue()))))) + bias);
2019-09-29 00:05:20 +03:00
}
public static double toSlope(Number angle){
return FastMath.atan(FastMath.toRadians(angle.doubleValue() - 90));
}
2019-09-29 00:05:20 +03:00
}