Question Equatorial to relative position

RisingFury

OBSP developer
Addon Developer
Joined
Aug 15, 2008
Messages
6,290
Reaction score
120
Points
153
Location
Among bits and Bytes...
I'm having trouble turning equatorial position (longitude, latitude, altitude) into planet relative coordinates, used by the VESSELSTATUS.rpos value.

I'd like to position a vessel at certain position on the planet, but I don't want it to be landed on the ground, so I can't use the vdata[0].x and vdata[0].y, or surf_lon and surf_lat on VESSELSTATUS2.

I need to transform equatorial position into VESSELSTATUS.rpos vector.

I tried oapiEquToLocal, which, from the explanation in the API led me to believe would do the trick, but it doesn't.

After that I started to guess how the coordinate system of a planet is oriented and tried to figure out an appropriate transformation, but now I give up. Could please someone explain...
 

Moach

Crazy dude with a rocket
Addon Developer
Joined
Aug 6, 2008
Messages
1,563
Reaction score
12
Points
38
Location
Vancouver, BC
well, if you think of lat/lon as angles, you should also be able think of them being used as "gimbals" to some extent...

so, if the "zero" lat/lon point (you know, off the african coast) is thought of as aligned to the Z axis, you can build a rotation matrix with lat and lon then use it to spin around from that point


then simply scale the resulting vector (assuming it's unit legth) by your radius or earth radius + altitude :rolleyes:

did i make sense?
 

RisingFury

OBSP developer
Addon Developer
Joined
Aug 15, 2008
Messages
6,290
Reaction score
120
Points
153
Location
Among bits and Bytes...
well, if you think of lat/lon as angles, you should also be able think of them being used as "gimbals" to some extent...

so, if the "zero" lat/lon point (you know, off the african coast) is thought of as aligned to the Z axis, you can build a rotation matrix with lat and lon then use it to spin around from that point


then simply scale the resulting vector (assuming it's unit legth) by your radius or earth radius + altitude :rolleyes:

did i make sense?


That's the problem. From what I've seen, planets don't have a rotating frame of reference, so the rotation matrix has to take into account the axial tilt of Earth and time of day. I'm having a problem constructing that matrix.

I thought there might be an easy Orbiter way of doing it. I hope I'm not wrong...
 

Hielor

Defender of Truth
Donator
Beta Tester
Joined
May 30, 2008
Messages
5,632
Reaction score
0
Points
0
That's the problem. From what I've seen, planets don't have a rotating frame of reference, so the rotation matrix has to take into account the axial tilt of Earth and time of day. I'm having a problem constructing that matrix.

I thought there might be an easy Orbiter way of doing it. I hope I'm not wrong...
You don't need to take into account the axial tilt, but you do need to take into account the time of day--that'll make it easier.
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,352
Reaction score
9
Points
0
Website
orbit.medphys.ucl.ac.uk
I need to transform equatorial position into VESSELSTATUS.rpos vector.

I tried oapiEquToLocal, which, from the explanation in the API led me to believe would do the trick, but it doesn't.
It does what it claims to do (I hope) but this is only halfway to what you need.
Remember that the VESSELSTATUS.rpos vector is not in planet local coordinates, but in planet-centered ecliptic coordinates. Therefore you have to take the result from oapiEquToLocal and rotate it into the ecliptic frame by multiplying with the planet's rotation matrix.
Alternatively, you could use oapiEquToGlobal, and subtract the planet's global position from the result.
 

shacharm

New member
Joined
Sep 15, 2012
Messages
10
Reaction score
0
Points
0
would like to add more information

Hi!
As I've battled this little annoyance myself, I'd like to share my results

I've created a vessel on the moon, roughly on the surface
using oapiEquToLocal(theMoon, lon, lat, range, &observerPosition);
I recieved:
(lat,lng) -> (X, Y, Z)
(0.000000,0.000008)->(1738007.021691,0.248463,0.000000)



However, using the method above
oapiEquToGlobal(theMoon, lon, lat, range, &gposSurfGlobalPoint); gposSurfGlobalPoint -= gposMoon;

I've gotten
Equatorial = (-1692619.117615,-20872.727713,-394047.280632)

Using Matlab, I've extracted the rotation matrix between these two vectors
r = vrrotvec([1738002.718203,0.155289,0.000000], [-1692612.355560,-20873.042428,-394057.328804])

>> m = vrrotvec2mat(r)

m =

-0.9739 0.0120 0.2267
-0.0120 0.9945 -0.1043
-0.2267 -0.1043 -0.9684




However, using orbiter method oapiGetRotationMatrix(theMoon, &rot);
I've gotten

matrix: [-0.973888,-0.006244,0.226945]
matrix: [-0.012009,0.999639,-0.024032]
matrix: [-0.226713,-0.026130,-0.973611]



there is ALMOST a unity between them
1.0000 -0.0000 -0.0000
-0.0000 0.9968 -0.0803
0.0000 0.0803 0.9968


extracting the Residue Angle using matlab,
[r1 r2 r3] = dcm2angle(A'*B)
r1 = 0
r2 = 0
r3 = -0.0804

-0.0804*180/pi = -4.6066 degress

Wikipedia says the inclination of the moon is 5.145°


Unless I've gotten something wrong, there's more rotation between these frames? and the 4.6 degrees' suppose to be the inclination (open question)


fix: I think the last angle is the angle of rotation between a stationary (planet-attached) axes and a stationary axes with a moving planet.
 
Last edited:
Top