Home ] Up ] Next ]


Animating the sun and moon.

There are currently 3 methods of positioning the sun in the sky.

  1. Manually enter the sun heading and pitch
  2. The Solaris plugin to manually position the sun in an image for any given latitude/longitude/date/time.
  3. Specifying a start and end position for the sun in Terranim or Campath.

The position of the sun can be specified for each frame in the script file, but unfortunately the GUI script generators only use a linear interpolation between a start and end position.  The Solaris plugin is great for positioning the sun on an earth-based terrain but it is only usable for still images.  The solution is relatively obvious... take the math used by the Solaris plugin and add it to a database/spread sheet to calculate the position of the sun in each frame.

I located an algorithm for doing just this at "Astronomy Answers: Position of the Sun". At first glance it looks a bit daunting but it's relatively straight forward if you take it slowly.  Given the amount of effort required to program all of these equations into a database I decided to include all of the planets in my database just in case I ever want to use DEMs from other planets... e.g. Mars is pretty popular at the moment.

Animating the moon and stars

I haven't actually looked up the math for this yet, and I don't intend to for a while.  Technically the moon does move through the sky at a different rate to the stars, but for the sake of simplicity I'll just use the position of the sun (for earth's moon).

The same heading and altitude values can be used for the yaw and roll angles in the initial transformation of a 360°x180° star map to match the motion of the moon.

The sun below the horizon

Sunrise and sunset still remains a problem from a rendering point of view.  At negative sun altitudes the sunlight strength automatically becomes 0. This creates a sudden change in lighting for which there is no fool proof work around. If you have a high camera position the sun may be visible at negative altitudes but it will not appear to be casting any light. In this situation you're pretty much screwed for now.

If the sun disappears behind the terrain before it hits negative altitudes then it may be possible to work around this by:

  1. setting the sun altitude to 0.01° for all altitudes <= 0.01°
  2. morphing the size of the sun to 0 once it hits the horizon.
  3. morphing the lighting settings to simulate the change in the sky as the sun sinks below the horizon.

This is relatively straightforward as far as programming the script is concerned but it does require some careful planning to get a realistic morph of the lighting conditions.  So far I haven't tested this concept yet... but I'm reasonably confident it will work OK.

Maths and databases/spreadsheets.

Alas I have had a wee set back in my own database as Filemaker Pro does not have an arcsine function which is required for the final calculation of azimuth.  So I went off to Excel and started again... but the accuracy of calculations in Excel is not up to the task with small rounding errors creeping in at various stages causing the end result to be up to 1/2 a degree out.  Maybe the poms used Excel to help land their robot on Mars  ;-)


Home ] Up ] Next ]


This page, its contents and style, are the responsibility of the author and do not represent the views, policies or opinions of The University of Melbourne. All photographs © Ben Kreunen 2000

Ben Kreunen <bernardk@unimelb.edu.au>
Department of Pathology
Last modified: 13-Aug-2003