Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Slipgate/src/org/usfirst/frc/team263/robot/LimelightMath
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import javax.swing.JOptionPane;
import java.lang.Math;
public class LimelightMath
{
public static void main(String[] args)
{
String X = JOptionPane.showInputDialog("Enter the robot's distance from cube (in).");
double x = Double.parseDouble(X);
String Y = JOptionPane.showInputDialog("Enter the fixed height of the Limelight.");
double y = Double.parseDouble(Y);
String V = JOptionPane.showInputDialog("Enter the velocity of the robot (in/s)."); // v = dx
double v = Double.parseDouble(V);
double h = calcLimelightDistance(x, y);
double dh = changeInLimelightDistance(x,y,v);
double o1 = Math.toDegrees(angleOfElevation(x,y));
double o2 = Math.toDegrees(angleOther(x,y));
double do1 = Math.toDegrees(-1 * changeInAngle(x,y));
double do2 = Math.toDegrees(changeInAngle(x,y));
if (v == 0)
{
do1 = 0;
do2 = 0;
}
System.out.println("Distance = " + h + " in");
System.out.println("Change in Diagonal Distance = " + dh + " in/s");
System.out.println("Angle of Elevation = " + o1 + " degrees");
System.out.println("Other Angle = " + o2 + " degrees");
System.out.println("Change in Angle of Elevation = " + do1 + " degrees/s");
System.out.println("Change in Other Angle = " + do2 + " degrees/s");
}
public static double calcLimelightDistance(double a, double b)
{
return Math.hypot(a, b);
}
public static double changeInLimelightDistance(double a, double b, double c)
{
return (a * c) / Math.hypot(a, b);
}
public static double angleOfElevation(double a, double b)
{
return Math.acos(a / (Math.hypot(a, b)));
}
public static double angleOther(double a, double b)
{
return Math.asin(a / (Math.hypot(a, b)));
}
public static double changeInAngle(double a, double b)
{
return 1 / (b * (1 + Math.pow(a, 2) / Math.pow(b, 2)));
}
}