|
SunSphereImage 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. You can reposition the image by clicking or grabbing it with the mouse. Opt-clicking (Mac) or Alt-clicking (Windows), or Control-clicking displays the time of sunrise and sunset for the nearest city to the mouse. Click the "spin" button (if visible) to rotate the globe continuously. You can also grab the globe with the mouse and spin it directly. You'll see that city lights "twinkle" because the transformation from the underlying map to the globe reveals different patterns of the yellow city color. You can spin the globe faster or slower (or in the wrong direction) by dragging it with the mouse. Because rotating and spinning with latitude changes requires much more computation than longitude-only, you need to enable these features by clicking on the 'i' button or double-clicking near the globe image to display the option dialog. This dialog also lets you enable or disable the dynamic cloud display. SunSphereImage is a large applet and takes a while to load and start running; give it time. The SunSphereImage Applet requires complete Java 1.1 support and does not run on some versions of Netscape Navigator on MacOS. Click here for a simpler applet that should work on all browsers that support Java.
If you find bugs in this program (or make improvements), please contact me.
|
<appletcodebase="http://www.shiggy.com/SunSphereImage"archive=SunSphereImage.jarcode="org.minow.SunSphereImage.SunSphereImage.class"width=240height=340><param name="bgcolor" value="#EEEEFF" >The SunSphere Applet is displayed here if your browser supports Java. SunSphereImage requires complete Java 1.1 support.</applet>
bgcolor | A value that matches the background color of your web page. A value of #000099 looks nice, for example. |
fgcolor | The desired text (foreground) color. This is really only useful if you also specify a background color. |
image | The name of the image file. The applet looks for the image file in your document folder (directory) and, if it is not in that folder, it looks in the folder containing the applet code archive. |
autostart | "true" to start spinning the globe when the applet starts. |
cityfile | The name of an XML formatted file that contains the names of all cities, their location, and timezones. The applet looks for the city file in your document folder (directory) and, if it is not in that folder, it looks in the folder containing the applet code archive. |
cloudfile | The name of an image file containing the latest cloud image. Do not specify to fetch the cloud image from the University of Wisconsin server. If set, an auxiliary process, such as a "crontab" script running on a Unix system, will provide a timely local copy of the University of Wisconsin file. See the cloud image description for more information. |
getcloudimage | "true" to fetch the current cloud image. See the cloud image description for more information. |
showbuttons | "true" to show the "spin" and "info" buttons (default). "false" to hide these buttons. If false, you can call up the configuration dialog by double-clicking near (but not in) the globe image.. |
showclock | "true" to show the analog clock (default). False to hide the clock. |
hinttime | The number of seconds to show the user-interface hint (default 30). Set to zero to hide the hint at startup.. |
latitude | The initial latitude of the center of the globe in fractional degrees. North is positive. |
longitude | The initial longitude of the center of the globe in fractional degrees. East is positive. |
latitudespin |
The initial latitude spin (North/South). To enable latitude spins,
both the enablelatitudespin
and autostart parameters must
be true. Latitude spins are computationally intensive.
|
longitudespin | The initial longitude spin (East/West). Latitude spins are very fast to compute. The value should be negative to spin in the "natural" direction of the Earth's rotation. |
enablelatitudespin |
True to enable spinning the globe in a North/South direction.
this is computationally intensive. The
autostart controls all
spinning.
|
spininterval | The time between each spin cycle in milliseconds.. |
If SunSphereImage runs as an application on a computer that is directly connected to the Internet, it can download an up-to-date satellite cloud image from a University of Wisconsin server. To access this server, you must either run SunSphereImage as an application from your local system or set your browser's Java security preferences to allow applets "unrestricted network access." Note that this will increase the risk that a rogue Java applet performs some unwanted action (it does not allow Java applets to read files on your local system, however).
As an alternative, you can specify a local file in the applet parameter list and provide an external mechanism, such as a "crontab" script, that maintains a timely image on your web server.
By default, the cloud image display feature is enabled if SunSphereImage runs as an application and disabled if it runs as an applet. You can explicitly enable or disable it using the option dialog or applet parameter list.
To show twilight and night, the program shades the map by computing the altitude of the sun at every pixel. If the sun is below the horizon, the algorithm darkens the pixel. (This is, actually, slightly inaccurate: shading should begin when the sun is 20° above the horizon.)
SunriseFilter.java performs this computation once a minute using support functions in SunEphemeris.java. While the filter operation is moderately compute-intensive, the implementation uses several vectors to pre-compute most of the data and this is not a performance bottleneck.
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. This takes about ten times longer than a purely horizontal rotation. By default, the image can only be rotated horizontally: use the option dialog to override the default.
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. |
src.zip archive.
SunSphereImage uses several additional files:
SunSphere was created using MRJ
Mac OS Runtime for Java.
Copyright © 1996-2000 Martin Minow. All Rights Reserved.