-
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
Moon #1189
Merged
Moon #1189
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5eec408
Add Moon.
bagnell 0bf52b2
Merge branch 'master' into moon
bagnell 809a83c
Merge branch 'materials' into moon
bagnell 8586aca
Fix after merge.
bagnell 7c1b04b
Merge branch 'materials' into moon
bagnell 9edaa86
Add tests.
bagnell 14b7eac
Merge branch 'master' into moon
bagnell 6347d03
Add moon to scene like sun, stars, and atmosphere.
bagnell a3ea3e5
Add more tests for moon orientation.
bagnell 64b8105
Fix tests after moving moon to the scene.
bagnell c28c176
Add moon rendering tests.
bagnell be39424
Update CHANGES.md.
bagnell 6bbf61f
Merge branch 'master' into moon
bagnell 64d7211
Updates based on review.
bagnell 09ad9c4
Add an option to use the Sun as the only light source on the moon.
bagnell 0d025f1
Fix test
pjcozzi 1acf71c
CHANGES.md tweak
pjcozzi 23eace2
Doc tweaks
pjcozzi 99fdf64
Merge branch 'master' into moon
bagnell 476948e
Merge branch 'master' into moon
bagnell f9b811b
Fix CHANGES.md after merge.
bagnell 0ecc4f0
Draw moon in the multifrustum.
bagnell 42bc959
Merge branch 'master' into moon
bagnell c4d6693
Updates based on review.
bagnell 74b6c25
Merge branch 'master' into moon
bagnell c4459a2
Merge branch 'master' into moon
bagnell d712c93
Write depth for moon when EXT_frag_depth extension is available.
bagnell 78ce9c1
Update tests.
bagnell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/*global define*/ | ||
define([ | ||
'./defined', | ||
'./IauOrientationParameters', | ||
'./JulianDate', | ||
'./Math', | ||
'./TimeConstants' | ||
], function( | ||
defined, | ||
IauOrientationParameters, | ||
JulianDate, | ||
CesiumMath, | ||
TimeConstants) { | ||
"use strict"; | ||
|
||
/** | ||
* This is a collection of the orientation information available for central bodies. | ||
* The data comes from the Report of the IAU/IAG Working Group on Cartographic | ||
* Coordinates and Rotational Elements: 2000. | ||
* @exports Iau2000Orientation | ||
* | ||
* @private | ||
*/ | ||
var Iau2000Orientation = {}; | ||
|
||
var TdtMinusTai = 32.184; | ||
var J2000d = 2451545.0; | ||
|
||
var c1 = -0.0529921; | ||
var c2 = -0.1059842; | ||
var c3 = 13.0120009; | ||
var c4 = 13.3407154; | ||
var c5 = 0.9856003; | ||
var c6 = 26.4057084; | ||
var c7 = 13.0649930; | ||
var c8 = 0.3287146; | ||
var c9 = 1.7484877; | ||
var c10 = -0.1589763; | ||
var c11 = 0.0036096; | ||
var c12 = 0.1643573; | ||
var c13 = 12.9590088; | ||
|
||
/** | ||
* Compute the orientation parameters for the Moon. | ||
* | ||
* @param {JulianDate} [date=new JulianDate()] The date to evaluate the parameters. | ||
* @param {IauOrientationParameters} [result] The object onto which to store the result. | ||
* | ||
* @returns {IauOrientationParameters} The modified result parameter or a new instance representing the orientation of the Earth's Moon. | ||
*/ | ||
Iau2000Orientation.ComputeMoon = function(date, result) { | ||
if (!defined(date)) { | ||
date = new JulianDate(); | ||
} | ||
|
||
var dateTT = date.addSeconds(TdtMinusTai); | ||
var d = dateTT.getTotalDays() - J2000d; | ||
var T = d / TimeConstants.DAYS_PER_JULIAN_CENTURY; | ||
|
||
var E1 = (125.045 + c1 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E2 = (250.089 + c2 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E3 = (260.008 + c3 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E4 = (176.625 + c4 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E5 = (357.529 + c5 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E6 = (311.589 + c6 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E7 = (134.963 + c7 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E8 = (276.617 + c8 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E9 = (34.226 + c9 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E10 = (15.134 + c10 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E11 = (119.743 + c11 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E12 = (239.961 + c12 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
var E13 = (25.053 + c13 * d) * CesiumMath.RADIANS_PER_DEGREE; | ||
|
||
var sinE1 = Math.sin(E1); | ||
var sinE2 = Math.sin(E2); | ||
var sinE3 = Math.sin(E3); | ||
var sinE4 = Math.sin(E4); | ||
var sinE5 = Math.sin(E5); | ||
var sinE6 = Math.sin(E6); | ||
var sinE7 = Math.sin(E7); | ||
var sinE8 = Math.sin(E8); | ||
var sinE9 = Math.sin(E9); | ||
var sinE10 = Math.sin(E10); | ||
var sinE11 = Math.sin(E11); | ||
var sinE12 = Math.sin(E12); | ||
var sinE13 = Math.sin(E13); | ||
|
||
var cosE1 = Math.cos(E1); | ||
var cosE2 = Math.cos(E2); | ||
var cosE3 = Math.cos(E3); | ||
var cosE4 = Math.cos(E4); | ||
var cosE5 = Math.cos(E5); | ||
var cosE6 = Math.cos(E6); | ||
var cosE7 = Math.cos(E7); | ||
var cosE8 = Math.cos(E8); | ||
var cosE9 = Math.cos(E9); | ||
var cosE10 = Math.cos(E10); | ||
var cosE11 = Math.cos(E11); | ||
var cosE12 = Math.cos(E12); | ||
var cosE13 = Math.cos(E13); | ||
|
||
var rightAscension = (269.9949 + 0.0031 * T - 3.8787 * sinE1 - 0.1204 * sinE2 + | ||
0.0700 * sinE3 - 0.0172 * sinE4 + 0.0072 * sinE6 - | ||
0.0052 * sinE10 + 0.0043 * sinE13) * | ||
CesiumMath.RADIANS_PER_DEGREE; | ||
var declination = (66.5392 + 0.013 * T + 1.5419 * cosE1 + 0.0239 * cosE2 - | ||
0.0278 * cosE3 + 0.0068 * cosE4 - 0.0029 * cosE6 + | ||
0.0009 * cosE7 + 0.0008 * cosE10 - 0.0009 * cosE13) * | ||
CesiumMath.RADIANS_PER_DEGREE; | ||
var rotation = (38.3213 + 13.17635815 * d - 1.4e-12 * d * d + 3.5610 * sinE1 + | ||
0.1208 * sinE2 - 0.0642 * sinE3 + 0.0158 * sinE4 + | ||
0.0252 * sinE5 - 0.0066 * sinE6 - 0.0047 * sinE7 - | ||
0.0046 * sinE8 + 0.0028 * sinE9 + 0.0052 * sinE10 + | ||
0.004 * sinE11 + 0.0019 * sinE12 - 0.0044 * sinE13) * | ||
CesiumMath.RADIANS_PER_DEGREE; | ||
|
||
var rotationRate = ((13.17635815 - 1.4e-12 * (2.0 * d)) + | ||
3.5610 * cosE1 * c1 + | ||
0.1208 * cosE2*c2 - 0.0642 * cosE3*c3 + 0.0158 * cosE4*c4 + | ||
0.0252 * cosE5*c5 - 0.0066 * cosE6*c6 - 0.0047 * cosE7*c7 - | ||
0.0046 * cosE8*c8 + 0.0028 * cosE9*c9 + 0.0052 * cosE10*c10 + | ||
0.004 * cosE11*c11 + 0.0019 * cosE12*c12 - 0.0044 * cosE13*c13) / | ||
86400.0 * CesiumMath.RADIANS_PER_DEGREE; | ||
|
||
if (!defined(result)) { | ||
result = new IauOrientationParameters(); | ||
} | ||
|
||
result.rightAscension = rightAscension; | ||
result.declination = declination; | ||
result.rotation = rotation; | ||
result.rotationRate = rotationRate; | ||
|
||
return result; | ||
}; | ||
|
||
return Iau2000Orientation; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/*global define*/ | ||
define([ | ||
'./Cartesian3', | ||
'./defined', | ||
'./DeveloperError', | ||
'./Iau2000Orientation', | ||
'./JulianDate', | ||
'./Math', | ||
'./Matrix3', | ||
'./Quaternion' | ||
], function( | ||
Cartesian3, | ||
defined, | ||
DeveloperError, | ||
Iau2000Orientation, | ||
JulianDate, | ||
CesiumMath, | ||
Matrix3, | ||
Quaternion) { | ||
"use strict"; | ||
|
||
/** | ||
* The Axes representing the orientation of a Central Body as represented by the data | ||
* from the IAU/IAG Working Group reports on rotational elements. | ||
* @alias IauOrientationAxes | ||
* @constructor | ||
* | ||
* @param {Function} [computeFunction] The function that computes the {@link IauOrientationParameters} given a {@link JulianDate}. | ||
* | ||
* @exception {DeveloperError} computeFunction is required. | ||
* | ||
* @see Iau2000Orientation | ||
*/ | ||
var IauOrientationAxes = function (computeFunction) { | ||
if (!defined(computeFunction) || typeof computeFunction !== 'function') { | ||
computeFunction = Iau2000Orientation.ComputeMoon; | ||
} | ||
|
||
this._computeFunction = computeFunction; | ||
}; | ||
|
||
var xAxisScratch = new Cartesian3(); | ||
var yAxisScratch = new Cartesian3(); | ||
var zAxisScratch = new Cartesian3(); | ||
|
||
function computeRotationMatrix(alpha, delta, result) { | ||
var xAxis = xAxisScratch; | ||
xAxis.x = Math.cos(alpha + CesiumMath.PI_OVER_TWO); | ||
xAxis.y = Math.sin(alpha + CesiumMath.PI_OVER_TWO); | ||
xAxis.z = 0.0; | ||
|
||
var cosDec = Math.cos(delta); | ||
|
||
var zAxis = zAxisScratch; | ||
zAxis.x = cosDec * Math.cos(alpha); | ||
zAxis.y = cosDec * Math.sin(alpha); | ||
zAxis.z = Math.sin(delta); | ||
|
||
var yAxis = Cartesian3.cross(zAxis, xAxis, yAxisScratch); | ||
|
||
if (!defined(result)) { | ||
result = new Matrix3(); | ||
} | ||
|
||
result[0] = xAxis.x; | ||
result[1] = yAxis.x; | ||
result[2] = zAxis.x; | ||
result[3] = xAxis.y; | ||
result[4] = yAxis.y; | ||
result[5] = zAxis.y; | ||
result[6] = xAxis.z; | ||
result[7] = yAxis.z; | ||
result[8] = zAxis.z; | ||
|
||
return result; | ||
} | ||
|
||
var rotMtxScratch = new Matrix3(); | ||
var quatScratch = new Quaternion(); | ||
|
||
/** | ||
* Computes a rotation from ICRF to a Central Body's Fixed axes. | ||
* @memberof IauOrientationAxes | ||
* | ||
* @param {JulianDate} date The date to evaluate the matrix. | ||
* @param {Matrix3} result The object onto which to store the result. | ||
* | ||
* @returns {Matrix} The modified result parameter or a new instance of the rotation from ICRF to Fixed. | ||
*/ | ||
IauOrientationAxes.prototype.evaluate = function(date, result) { | ||
if (!defined(date)) { | ||
date = new JulianDate(); | ||
} | ||
|
||
var alphaDeltaW = this._computeFunction(date); | ||
var precMtx = computeRotationMatrix(alphaDeltaW.rightAscension, alphaDeltaW.declination, result); | ||
|
||
var rot = CesiumMath.zeroToTwoPi(alphaDeltaW.rotation); | ||
var quat = Quaternion.fromAxisAngle(Cartesian3.UNIT_Z, rot, quatScratch); | ||
var rotMtx = Matrix3.fromQuaternion(quat, rotMtxScratch); | ||
|
||
var cbi2cbf = Matrix3.multiply(rotMtx, precMtx, precMtx); | ||
return cbi2cbf; | ||
}; | ||
|
||
return IauOrientationAxes; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*global define*/ | ||
define([ | ||
'./defined', | ||
'./DeveloperError' | ||
], function( | ||
defined, | ||
DeveloperError) { | ||
"use strict"; | ||
|
||
/** | ||
* A structure containing the orientation data computed at a particular time. The data | ||
* represents the direction of the pole of rotation and the rotation about that pole. | ||
* <p> | ||
* These parameters correspond to the parameters in the Report from the IAU/IAG Working Group | ||
* except that they are expressed in radians. | ||
* </p> | ||
* @exports IauOrientationParameters | ||
* | ||
* @private | ||
*/ | ||
var IauOrientationParameters = function(rightAscension, declination, rotation, rotationRate) { | ||
/** | ||
* The right ascension of the north pole of the body with respect to | ||
* the International Celestial Reference Frame, in radians. | ||
* @type {Number} | ||
*/ | ||
this.rightAscension = rightAscension; | ||
|
||
/** | ||
* The declination of the north pole of the body with respect to | ||
* the International Celestial Reference Frame, in radians. | ||
* @type {Number} | ||
*/ | ||
this.declination = declination; | ||
|
||
/** | ||
* The rotation about the north pole used to align a set of axes with | ||
* the meridian defined by the IAU report, in radians. | ||
* @type {Number} | ||
*/ | ||
this.rotation = rotation; | ||
|
||
/** | ||
* The instantaneous rotation rate about the north pole, in radians per second. | ||
* @type {Number} | ||
*/ | ||
this.rotationRate = rotationRate; | ||
}; | ||
|
||
return IauOrientationParameters; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we reasonably expect someone to implement another
computeFunction
in the near future?Let's default
computeFunction
toIau2000Orientation.ComputeMoon
. I would also docIau2000Orientation
as@private
; no need to cloud our interfaces and have to maintain interfaces, until we need to, for what virtually every user will see as an implementation detail.