## Sunday, June 24, 2012

### Changing Camera Reference in Gladius

‹prev | My Chain | next›

As of last night, I have a nice Gladius based simulation of planetary retrograde motion:

Retrograde motion is one of those things that baffled ancient astronomers, who watched the heavens night after night as planets sometime did odd things. Over the course of months, Mars moves through different constellations as it revolves around the Sun. But every now and then, as the Earth passes Mars in its orbit, Mars seems to go backward. That is it might move normally from Pisces, to Aries, to Taurus and then back to Aries.

It is easily explained with a heliocentric view of the solar system, but ancient astronomers assumed the Earth to be the center of the universe. Hence the bafflement.

We can laugh at our ancestors as simpletons. But for a false assumption, they were in many way far more sophisticated in understanding of the skies. Very rarely are many of use afforded the chance for a clear view of the stars, let alone do we take detailed notice of what transpires. In that sense we have the opposite problem of our ancestors—we have a good explanation of things like retrograde motion, but it is difficult for us to visualize what it might look like.

My simulation currently show retrograde motion from "above" the solar system (looking down on the northern hemisphere). Today I hope to shift the view to Earth looking out into space (away from the Sun).

So far I have yet to change from the camera angle in the cube example in Gladius. That is, the camera is established to look at 0,0,0 from the outset:
``````    space.add( new engine.simulation.Entity( "camera",
[
new engine.core.Transform( [0, 0, 0] ),
new cubicvr.Camera({
targeted: true
}),
new cubicvr.Light()
]
));``````
Instead, I shift the camera to Earth, rotate it 90° and move it back and above Earth:
``````    space.
findNamed( "camera" ).
setParent( space.findNamed( "earth" ) );

space.
findNamed( "camera" ).
findComponent("Transform").setRotation([3*Math.PI/2, 0, 0]);

space.
findNamed( "camera" ).
findComponent( "Transform" ).
setPosition( [0, 5, -1] );``````
That should give me a nice view as Mars moves across the sky. Only is doesn't.

Since I am fixed to Earth, the camera ends up spinning with Earth. I see Mars every now and then:

But I am not seeing retrograde motion.

Ah, shoot. I think I need to add reference points in the sky -- constellations if you will. I had thought that I could witness retrograde motion without them, but it seems not. I will pick back up there tomorrow.

Day #427