SunSphere displays an image of the earth showing the sunrise and sunset terminator. It uses your local timezone (which must have been set correctly) to approximate your local longitude and give the impression that you are looking down on the earth from above the equator.
SunSphere requires Java 1.1 support.
SunSphere is documented in the following sections.
To add SunSphere, add the following HTML to your web page:
<applet
codebase="http://www.vmeng.com/minow/sunsphere/MRJ"
archive=SunSphereMRJ.jar
code="org.minow.applets.sunsphere.SunSphere.class"
width=190
height=220
>
<param name=bgcolor value="#FFFFFF" >
<param name=textcolor value="#000000" >
<param name=autostart value="true" >
<param name=latitudegrab value="false" >
<param name=latitude value ="0.0" >
<param name=latitudeincrement value="15.0" >
<param name=latitudespin value ="0.0" >
<param name=longitude value="123.45" >
<param name=longitudeincrement value="15.0" >
<param name=longitudespin value="1.0" >
<param name=spininterval value="1000" >
The SunSphere Applet is displayed here if your browser
supports Java.
</applet>
You may specify the following optional parameters.
bgcolor
textcolor
autostart
true
or false
. If
true
, the image starts rotating immediately.
latitudegrab
true
or false
. If
true
, the grabbing the globe with the mouse
lets you move or spin it in both latitude (North/South)
and longitude (East/West). This requires about ten
times as much computation per pixel for each rotation
step.
latitude
latitudeincrement
latitudespin
longitude
longitudeincrement
longitudespin
spininterval
JD = Modified Julian Date | The Modified Julian Date is the number of days since midnight, November 17, 1858. |
UT = 0 |
Set the estimated event (sunrise, sunset, twilight) time to midnight. |
UT0 = 0 |
Set the computed event (sunrise, sunset, twilight) time to noon. |
while (abs(UT - UT0) > 0.0008) { |
Continue until the the estimates are satisfactorily close together. |
T <- (JD + UT/24 - 2451545.0)/36525. |
Using the current time estimate, compute the number of centuries since the ephemeris epoch of January 0, 2000. |
L <- 280.460 + 36000.770 * T |
Compute the solar mean longitude in degrees. |
G <- 357.528 + 35999.050 * T |
Compute the solar mean anomaly in degrees. |
M <- L + 1.915 * sin (G) + 0.020 * sin (2*G) |
Compute the ecliptic longitude in degrees. |
e <- 23.4393 - 0.01300 * T |
Compute the obliquity of the ecliptic in degrees. |
E <- -1.915 * sin (G) |
Compute the equation of time. |
GHA <- 15*UT -180 + E |
Compute the Greenwich Hour Angle in degrees. |
DEC <- arcsin(- sin (e) * sin (M)) |
Compute the the sun's declination in degrees. |
HA <- arccos( |
Compute the hour-angle at UT (the current estimate) |
UT <- UT0 |
Compute the time of sunrise, sunset, or twilight. riseSet
is +1.0 for morning (rising) and -1.0 for evening (setting). The
result is in hours. |
} |
Continue until the UT and UT0 estimates are close together. |
return (UT) |
Return the computed event time. |
To show twilight and night, the program shades the map by computing the time of sunrise and sunset at the prime meridian (0° longitude) (i.e., Greenwich, England) for every degree of latitude. Since Java provides the Universal Time, it is a simple matter to convert the sunrise time and current Universal Time to the longitude of the the sunrise terminator. The program computes sunrise, sunset, and twilight for every latitude represented in the original image, sorts the data so it progresses across the map, and uses a Java image filter class to create a properly-shaded image.
SunrisePixels.java performs this computation once a minute. After running, the program redraws the map. It is fairly compute-intensive.
When these vectors have been computed, the program can rotate the image very quickly in the East to West direction, as it doesn't need to recompute the trignometric "sphere to circle" projection. Unfortunately, to rotate North or South, the vectors must be rebuilt whenever the latitude changes. Can you do better?
pixel = mouse point |
Detemine the location of the mouse point with respect to the sphere. This value ranges from zero to the sphere diameter, with increasing values to the right and down. |
x = (double) (pixel.x - sphereRadius); |
Convert the horizontal pixel coordinate to a value that ranges from (-radius) to (+radius) from left to right. |
y = (double) (sphereRadius - pixel.y); |
Convert the vertical pixel coordinate to a value that ranges from (-radius) to (+radius) from bottom to top. Note that this is opposite the Java coordinate convention. |
rho = sqrt((x * x) + (y * y)); |
Compute the length of the vector from the origin
to the indicated point. If this is greater than the
radius of the sphere, return an error. Alternatively,
you can force the value to the radius. If rho
is zero, the user clicked on the origin: return latitude
0.0, longitude 0.0 to avoid computing arctan(0.0 / 0.0)
below. |
C = arcsin(rho / sphereRadius);
|
Compute the latitude and longitude with respect to the origin. As noted above, the algorithm must detect a click on the origin to avoid dividing by zero. |
It is not quite correct, but good enough for now.
This is beginning to grow out of control. Remind me to stop listening to friendly requests for new features.
This is incomplete: many new features aren't described in the BeanInfo. Later, perhaps.