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