Page 1 of 1

Help with Orientation/Rotation

Posted: 25.09.2010, 21:11
by Lithis
I am working on a script to show the Big Dipper from different positions in space. I have written a script that moves from star to star while keeping the view pointed at the Big Dipper. However, the view rotates in a way that I don’t like. While moving from star to star, I only want the camera to yaw and pitch; I don’t want it to roll. Basically, I am trying to recreate the photos on my Big Dipper webpage. Here is my current script:

Code: Select all

function asseenfrom(observer, name, travelduration, waitduration)
   travelduration = travelduration or 10
   waitduration = waitduration or 7

   observer:goto(celestia:find(name), travelduration)
   wait(0.75 * travelduration)
   -- A travelduration coefficient of 0.325 is good when the travelduration is 5.
   -- A travelduration coefficient of 0.3 is good when the travelduration is 10.
   -- A travelduration coefficient of 0.25 is good when the travelduration is 30.
   celestia:flash("As seen from " .. name, waitduration +
         (0.0001*travelduration^2 - 0.0065*travelduration + 0.355)
         * travelduration)
   wait(0.5 * waitduration)
   celestia:setrenderflags{constellations = true}
   -- celestia:showconstellations()
   wait(0.5 * waitduration)
   celestia:setrenderflags{constellations = false}
end

-- Set time to 3:43 AM CDT on July 21.
celestia:settime(celestia:utctotdb(2011, 7, 21, 8, 43, 0))

-- TODO: Select nothing.
-- TODO: Follow nothing.
celestia:unmarkall()

-- celestia:settextcolor(177/256, 177/256, 254/256)

-- celestia:hideconstellations()
celestia:setconstellationcolor(0.125, 0.125, 0)
celestia:setconstellationcolor(0.4, 0.4, 0, {"Ursa Major"})
-- celestia:showconstellations{"Ursa Major"}

-- Brighten the stars of the Big Dipper.
celestia:setrenderflags{markers = true}
for i, star in ipairs({"Alkaid", "Mizar", "Alioth", "Megrez", "Phecda", "Merak", "Dubhe"}) do
   celestia:find(star):mark("white", "disk", 5, 0.75)
end

-- Mark Castor and Pollux so they can be seen from Aldebaran.
for i, star in ipairs({"Castor", "Pollux"}) do
   celestia:find(star):mark("purple", "filledsquare", 7, 0.75)
end

observer = celestia:getobserver()

-- Always remain looking at the Big Dipper.
-- The view from Duluth is not horizontal if Phecda is tracked here.
observer:track(celestia:find("Phecda"))

-- asseenfrom(observer, "Sol/Earth")
earth = celestia:find("Sol/Earth")
observer:synchronous(earth)
observer:gotolonglat(earth, math.rad(-92.098194), math.rad(46.786939), earth:radius() * 2, 0)
-- Without this wait, the observer does not go to the above latitude and longitude.
wait(0)
observer:gotosurface(earth)
wait(5)
celestia:flash("As seen from Duluth")
wait(5)

-- Always remain looking at the Big Dipper.
-- The view from Duluth is horizontal if Phecda is tracked here.
--observer:track(celestia:find("Phecda"))

asseenfrom(observer, "Regulus")
asseenfrom(observer, "Pollux")
asseenfrom(observer, "Castor")
asseenfrom(observer, "Aldebaran")
asseenfrom(observer, "Sol/Earth")

(Don’t worry about the math and waiting in asseenfrom(). They just make text appear and disappear exactly when I want it to. The goto() is the only line in asseenfrom() that is relevant to my questions.)

From Earth, I want the Big Dipper to appear as from Duluth, MN, USA (about 47W 92N) at 3:43 AM on July 21st, which is close to horizontal and upright. If I start tracking Phecda before going to Earth’s surface, then I don’t end up horizontal on the surface. The horizon is diagonal when “As seen from Duluth” appears toward the beginning of the script. If I don’t start tracking Phecda until after going to Earth’s surface, then I do stand horizontally on the surface. However, the Big Dipper does not stay centered on the screen when I do this. How can I land horizontally on the Earth while tracking Phecda?

As the camera moves from Earth or star to star, I don’t want the zenith to change. The view from each star should be identical to the matching photo from the above webpage. How do I perform a goto without rolling?

I might want to change the object that I’m tracking because I don’t like how Phecda never moves in my current script. It would be nice to track a point between Phecda and Megrez so they both revolve as the camera moves about. I don’t know the best way to achieve this; whether to create a position in my script or to add an invisible star that is between them to the star catalog and then track it. Would this make my goals easier or more difficult, or would it be the same?

Re: Help with Orientation/Rotation

Posted: 25.09.2010, 22:53
by selden
I believe you'll need to use the getorientation and setorientation methods to keep your viewpoint oriented the way you want. They're described in the Wikibook at
http://en.wikibooks.org/wiki/Celestia/C ... rientation

.

Re: Help with Orientation/Rotation

Posted: 26.09.2010, 00:58
by Lithis
Thanks for the reply. I’m going to make a movie of this, so I want the movement to be smooth. setorientation() instantly sets the orientation at a single moment, but I want the orientation to stay set throughout the entire journey from star to star. If I’m overlooking some possibility of setorientaion(), please let me know.

I first tried writing a CEL script that used the up parameter to the goto command to select what direction I wanted to point up after the movement, but it rolled one way during the first half of the movement and then rolled back the other way the second half instead of not rolling at all. So I rewrote my script as the above CELX, hoping to have more control.

I have also tried using the version of goto() that takes a table. If I set both initialOrientation and finalOrientation to observer:getorientation(), then the camera does not rotate at all. However, I want the camera to yaw and pitch to track an object, just not roll. Perhaps using this function with the right rotation is what I want, but I don’t know how to get the right rotation. Can I pass a rotation to goto() that will keep an object (or position) centered in the camera’s view, without rolling, while moving from star to star?

Alternatively (or additionally), do I need to do something with frames to keep myself from rolling while moving through space?

Re: Help with Orientation/Rotation

Posted: 27.09.2010, 19:59
by Marco Klunder
Hello Lithis,

I think using the obs:goto{table} method is the method to use here.

What you can try, to determine the right target orientation, is to first manually goto the position and orientation you want.
Then using the [Ctrl] + [c] keys, you can save the CELURL.
Copy that CELURL into a text document, to readout the orientation and position.
(Mind to be in the Universal frame of reference when saving the CELURL).

Then you can use the celestia:newposition() and celestia:newrotation() methods to determine the target position and target orientation to be used in the obs:goto{table} method. The documentation of these methods in WIKI also mention how to obtain the values from the CELURL.

Marco