Skip to content

Commit

Permalink
fix trueAnomaly when r dot v < 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Stephens committed Jul 19, 2015
1 parent 18979ea commit 3fdbbf6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/orbit.js
Expand Up @@ -83,7 +83,8 @@ Orbit.prototype.argumentOfPeriapsis = function argumentOfPeriapsis() {

Orbit.prototype.trueAnomaly = function trueAnomaly() {
var e = this.eccentricity();
return toDeg(Math.acos(e.dot(this.r) / (e.norm() * this.r.norm())));
var u = toDeg(Math.acos(e.dot(this.r) / (e.norm() * this.r.norm())));
return this.r.dot(this.v) < 0 ? (360 - u) : u;
};

Orbit.prototype.periapsis = function periapsis() {
Expand Down

0 comments on commit 3fdbbf6

Please sign in to comment.