-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compute sun and moon positions #677
Conversation
…nverting to Cartesian
adjusted time from TAI to TDB
var translation = computeSimonEarthMoonBarycenter(date); | ||
var axesTransformation = Quaternion.IDENTITY; | ||
var translated = result.subtract(translation); | ||
translated.rotate(axesTransformation, result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just skip this, because rotating a vector by identity results in the same vector.
var trueAnomaly = meanAnomalyToTrueAnomaly(meanLongitude - longitudeOfPerigee, eccentricity); | ||
var type = chooseOrbit(eccentricity, 0.0); | ||
if (type === 'Hyperbolic' && Math.abs(CesiumMath.NegativePiToPi(trueAnomaly)) >= Math.acos(- 1.0 / eccentricity)) { | ||
throw new DeveloperError('invalid trueAnomaly.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to include the full exception message from Components: "The true anomaly of the hyperbolic orbit lies outside of the bounds of the hyperbola." Yeah, I don't really know what that means, either. Also it shouldn't ever happen for the Simon model. But there's no reason not to throw the better error message if you're going to check for it.
if (type === 'Hyperbolic' && Math.abs(CesiumMath.NegativePiToPi(trueAnomaly)) >= Math.acos(- 1.0 / eccentricity)) { | ||
throw new DeveloperError('invalid trueAnomaly.'); | ||
} | ||
var perifocalToEquatorial = perifocalToCartesianMatrix(argumentOfPeriapsis, inclination, rightAscensionOfAscendingNode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate to say it, but there's an allocation here that needs to be changed to use a result parameter.
cleaned up more documentation
throw new DeveloperError('Kepler equation did not converge'); | ||
//TODO: Port 'DoubleFunctionExplorer' from STK components | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine. Kepler's equation is going to converge for the reasonable orbits of the Earth-moon barycenter and the Moon. At least it better! Since we'll probably never do it, let's change this TODO to just a regular explanation comment: "STK Components uses a numerical method to find the eccentric anomaly in the case that Kepler's equation does not converge. We don't expect that to ever be necessary for the reasonable orbits used here." We try to avoid TODOs in master (though there are some), instead preferring GitHub issues for thing we might actually do, and comments of explanation for things we probably won't.
* Gets a point describing the motion of the Earth. This point uses the Moon point and | ||
* the 1992 mu value (ratio between Moon and Earth masses) in Table 2 of the paper in order | ||
* to determine the position of the Earth relative to the Earth-Moon barycenter. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Earth-centered inertial frame" here, too.
@kring anything else? Your diff comments above got off by a few lines, but I think I caught everything you mentioned. |
* @return {Cartesian3} The result of the rotation | ||
* | ||
*/ | ||
Cartesian3.prototype.rotate = function(quaternion, result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove this, too, since it called the other one.
Almost done, just those couple of things left. Thanks for your patience with my endless comments. |
@kring I appreciate your thoroughness. Anything else? |
Tests pass, Sandcastle examples look good (especially the terrain one where you can see the sun and moon specular highlight), jsHint is happy. Code looks allocation-free! Just one last problem, I promise! I just noticed that |
@hpinkos just an FYI; we don't get automatic notification to every change, so when you are done with review comments, it's usually a good idea to write a quick "ready for another review" message. Otherwise @kring wouldn't know you finished the rename until he remembers to check. That being said, I'll let him merge this, since he's been the one reviewing it. |
Looks good. Thanks, @hpinkos! Merging. |
Resolves: #391 #337
Ported parts of Simon1994PlanetaryPositions, KeplarianElements and ModifiedKeplarianElements from components to compute the sun and moon positions. Updated UniformState to use the new sun and moon positions.