SkyControl - Moon is spun 90 degrees

I just noticed that my SkyControl crescent moon is lying flat instead of vertical. In the screenshot, I would expect it to be spun 90 degrees.

Note that I have set the skycontrol axes to match my coordinate system (+x is east)

skyControl.getSunAndStars().setAxes(new Vector3f(0,0,-1),new Vector3f(0,1,0));

How do I fix this so the two points of the moon’s crescent are aligned vertically instead of horizontally?

1 Like

The points of the lunar crescent always point away from the sun, just like in Real Life. For them to be “aligned vertically” the sun would need to be near the horizon.

The SkyControl project has a GUI application named “TestSkyControl” that might be helpful for determining the astronomical circumstances (such as latitude, solar time, and lunar phase) you wish to portray.

1 Like

Well Today I Learned!

Another question: Is there a way to set the phase of the moon based on a given date? (and possibly observer location?).

1 Like

You can set the phase of the moon directly, as follows:

skyControl.setLunarPhase(newPreset);

This allows you to set one of 6 pre-defined phases, such as WANING_CRESCENT or FULL.

For more precise control, there’s an alternative setter that requires an off-screen renderer for the Moon:

    GlobeRenderer moonRenderer = new GlobeRenderer(
                    moonMaterial, format, equatorSamples, meridianSamples, resolution);
    stateManager.attach(moonRenderer);
    skyControl.setMoonRenderer(moonRenderer);

    skyControl.setPhase(phaseAngle, 0f);

Here phaseAngle is in the range 0 to 2π, with 0 producing a new moon and π producing a full moon.

Precise calculation of the moon’s phase is rather complicated. You can obtain the actual phase of the moon for a particular day using various web services such as:

If I wanted to calculate it precisely in Java I might use Jsofa.

5 Likes