problem turning observer precise angle and axis
Posted: 11.04.2011, 01:37
Hi celestians,
First a little background.
I am attempting to create a full dome planetarium movie using celestia. In order to achieve a 180 degree field of view I need to have four different views of each scene (front, up, left and right). It does not seem to be possible to achieve this using celestia's in built movie capture function because slight timing differences make it difficult to allign the various parts of each scene.
I have written a celx script that saves a series of screen shots which I can successfully process into a full dome movie. This part of the project is working well.
My problem.
In one scene I want the observer's orientation to move from the earth to the moon. I have found the vectors from obs to earth and from obs to moon and found the angle between them. I have then found the cross product of that angle and used it as the axis for the turn. I then divide the angle by the number of frames required and use this in a loop to take the screen shots. The problem is that it dosn't work. The observer turns but the axis is wrong. Also the axis of the turn alters depending on the location (latitude and longitude) above earth. I think the problem must relate to my poor understanding of reference frames but I have tried all I can think of and seem to be getting nowhere.
I have attached a section of script that shows the problem. Any help would be greatly appreciated.
BTW, I am using Celestia Portable 1.6.0
Thanks
First a little background.
I am attempting to create a full dome planetarium movie using celestia. In order to achieve a 180 degree field of view I need to have four different views of each scene (front, up, left and right). It does not seem to be possible to achieve this using celestia's in built movie capture function because slight timing differences make it difficult to allign the various parts of each scene.
I have written a celx script that saves a series of screen shots which I can successfully process into a full dome movie. This part of the project is working well.
My problem.
In one scene I want the observer's orientation to move from the earth to the moon. I have found the vectors from obs to earth and from obs to moon and found the angle between them. I have then found the cross product of that angle and used it as the axis for the turn. I then divide the angle by the number of frames required and use this in a loop to take the screen shots. The problem is that it dosn't work. The observer turns but the axis is wrong. Also the axis of the turn alters depending on the location (latitude and longitude) above earth. I think the problem must relate to my poor understanding of reference frames but I have tried all I can think of and seem to be getting nowhere.
I have attached a section of script that shows the problem. Any help would be greatly appreciated.
Code: Select all
function rotate_obs(rotangle, rotaxis, rottime)
-- Rotangle is the angle between origin and target
-- Rotaxis is the cross product of the vectors obs to origin and obs to target
-- Rottime is the duration of the rotation in seconds
local obs = celestia:getobserver()
-- Rotsteps sets number of steps for required frame rate
local rotsteps = 24 * rottime
local stepangle=rotangle/rotsteps
local rot = celestia:newrotation(rotaxis, stepangle)
local rotsteptime = rottime/rotsteps
for i = 1, rotsteps do
obs:rotate(rot)
wait(rotsteptime)
end
end
uly_to_km = 9460730.4725808
celestia:settime(2455505.77)
celestia:settimescale(0)
obs=celestia:getobserver()
sun=celestia:find("Sol")
earth = celestia:find("Sol/Earth")
moon= celestia:find("Sol/Earth/Moon")
obs:synchronous(earth)
alt=12000+earth:radius()
longitude=math.rad(147)
latitude=math.rad(-41)
obs:gotolonglat(earth,longitude,latitude,alt,1)
wait(2)
obspos=obs:getposition()
moonpos=moon:getposition()
earthpos=earth:getposition()
orig_vec=obspos-earthpos
orig_vecn=orig_vec:normalize()
target_vec=obspos-moonpos
target_vecn=target_vec:normalize()
rotation_angle=math.acos(orig_vecn * target_vecn)
axis_vector=(target_vecn ^ orig_vecn)
rotationtime=5
celestia:setrenderflags{markers = true}
celestia:mark(moon)
rotate_obs(rotation_angle,axis_vector,rotationtime)
wait(10)
BTW, I am using Celestia Portable 1.6.0
Thanks