Skip to content
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
merged 28 commits into from
Oct 4, 2013
Merged

Moon #1189

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5eec408
Add Moon.
bagnell Sep 23, 2013
0bf52b2
Merge branch 'master' into moon
bagnell Sep 25, 2013
809a83c
Merge branch 'materials' into moon
bagnell Sep 25, 2013
8586aca
Fix after merge.
bagnell Sep 25, 2013
7c1b04b
Merge branch 'materials' into moon
bagnell Sep 25, 2013
9edaa86
Add tests.
bagnell Sep 25, 2013
14b7eac
Merge branch 'master' into moon
bagnell Sep 25, 2013
6347d03
Add moon to scene like sun, stars, and atmosphere.
bagnell Sep 25, 2013
a3ea3e5
Add more tests for moon orientation.
bagnell Sep 26, 2013
64b8105
Fix tests after moving moon to the scene.
bagnell Sep 26, 2013
c28c176
Add moon rendering tests.
bagnell Sep 26, 2013
be39424
Update CHANGES.md.
bagnell Sep 26, 2013
6bbf61f
Merge branch 'master' into moon
bagnell Sep 26, 2013
64d7211
Updates based on review.
bagnell Sep 26, 2013
09ad9c4
Add an option to use the Sun as the only light source on the moon.
bagnell Sep 26, 2013
0d025f1
Fix test
pjcozzi Sep 26, 2013
1acf71c
CHANGES.md tweak
pjcozzi Sep 26, 2013
23eace2
Doc tweaks
pjcozzi Sep 26, 2013
99fdf64
Merge branch 'master' into moon
bagnell Sep 26, 2013
476948e
Merge branch 'master' into moon
bagnell Oct 2, 2013
f9b811b
Fix CHANGES.md after merge.
bagnell Oct 2, 2013
0ecc4f0
Draw moon in the multifrustum.
bagnell Oct 2, 2013
42bc959
Merge branch 'master' into moon
bagnell Oct 3, 2013
c4d6693
Updates based on review.
bagnell Oct 3, 2013
74b6c25
Merge branch 'master' into moon
bagnell Oct 3, 2013
c4459a2
Merge branch 'master' into moon
bagnell Oct 4, 2013
d712c93
Write depth for moon when EXT_frag_depth extension is available.
bagnell Oct 4, 2013
78ce9c1
Update tests.
bagnell Oct 4, 2013
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Beta Releases

Code that previously looked like `matrix.toArray();` should now look like `Matrix3.toArray(matrix);`.

* Added `Moon` for drawing the moon, and `IauOrientationAxes` for computing the Moon's orientation.
* Added `Appearances` tab to Sandcastle with an example for each geometry appearance.
* Added `options` argument to the `EllipsoidPrimitive` constructor.
* Added a user-defined `id` to all primitives for use with picking. For example:
Expand Down
Binary file added Source/Assets/Textures/moonSmall.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Source/Core/Ellipsoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ define([
*/
Ellipsoid.UNIT_SPHERE = freezeObject(new Ellipsoid(1.0, 1.0, 1.0));

/**
* An Ellipsoid instance initialized to a sphere with the lunar radius.
* @memberof Ellipsoid
*/
Ellipsoid.MOON = freezeObject(new Ellipsoid(CesiumMath.LUNAR_RADIUS, CesiumMath.LUNAR_RADIUS, CesiumMath.LUNAR_RADIUS));

/**
* @memberof Ellipsoid
* @returns {Cartesian3} The radii of the ellipsoid.
Expand Down
138 changes: 138 additions & 0 deletions Source/Core/Iau2000Orientation.js
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;
});
107 changes: 107 additions & 0 deletions Source/Core/IauOrientationAxes.js
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) {
Copy link
Contributor

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 to Iau2000Orientation.ComputeMoon. I would also doc Iau2000Orientation 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.

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;
});
51 changes: 51 additions & 0 deletions Source/Core/IauOrientationParameters.js
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;
});
9 changes: 9 additions & 0 deletions Source/Core/Math.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ define([
*/
CesiumMath.SOLAR_RADIUS = 6.955e8;

/**
* The mean radius of the moon, according to the "Report of the IAU/IAG Working Group on
* Cartographic Coordinates and Rotational Elements of the Planets and satellites: 2000",
* Celestial Mechanics 82: 83-110, 2002.
* @type {Number}
* @constant
*/
CesiumMath.LUNAR_RADIUS = 1737400.0;

/**
* 64 * 1024
* @type {Number}
Expand Down
Loading