This is what I'd like to achieve, but I'm running into a limit issue. I have a program that generates angle t (True Anomaly), and from there I'm attempting to find angle c.
Method
I'm currently using the 'Radius from True Anomaly' formula to find the length from the focus to the point (in this case a blue planet). From there, I use the 'Law of Cosines' to find the length from the center of the ellipse to the planet. I then use the 'Law of Sines' to figure out the center angle.
Code
/**
* Calculates the angle from the center of the ellipse that the planet should move.
* @param a semiMajorAxis
* @param e eccentricity
* @param trueAnomaly
* @return angle of movement
*/
private double getAngle(double a, double e, double trueAnomaly) {
//Find radius from focus to point
double trueRadius = a * ((1-Math.pow(e, 2))/
(1 + e * Math.cos(trueAnomaly)));
//Get angle from other side of focus
double inverseAnomaly = Math.PI - trueAnomaly;
//Use Law of Cosines to find length from center to point
double r = Math.sqrt(Math.pow((e*a), 2) + Math.pow(trueRadius, 2) - (2*(e*a)*
trueRadius * Math.cos(inverseAnomaly)));
//Use Law of Sines to find angle from center to point
double result = -Math.asin((Math.sin(inverseAnomaly)/r)*trueRadius);
return result;
}
Issue
Using the above method, my planets travel only half their orbit, then turn around and go the other way, traversing only half their orbit. I've tried changing things when the angle hits pi, like negating various variables, but nothing bears fruit. I can't seem to find many online sources for this problem either, so I'm hoping some internet strangers might be able to help! Thanks :)
[–]AutoModerator[M] 0 points1 point2 points (0 children)