SDK Question createVessel in left handed system rotations

shacharm

New member
Joined
Sep 15, 2012
Messages
10
Reaction score
0
Points
0
Am I doing this correctly?
I want to create a vessel in a known (lat, lon, h) location.
I want it to look Down on the moon surface

I've developed the rotation matrix by extracting the directions of north-east-up according to Orbiter's left handed system
X = East
Y = Up
Z = North
hence ENU


It's consistent with rotating and swapping Y <-> Z by transforming the rotation matrix as given in
http://what-when-how.com/the-3-d-gl...derivation-the-3-d-global-spatial-data-model/



In the SDK, createvessel uses arot

Did I understand conrrectly, that arot are the yaw/pitch/roll of the matrix
ENU -> ECLIPTIC ? (where ENU is the local frame of the vessel)
and is this calculation correct?



* Eventually, my code for computing these angles would be:


Code:
void Global2Local(VECTOR3& ypr, double lat, double lon)
{
	/*
		
                               Y(ecliptic)
				|                                         Up (y)
				|                            North (z)    /
				|                                     \  /
				|      \/_   >---------------->        \/_____ East (x)
				|      / .											
				|   r /  .
				|    /   .
				|   /    .
				|  /     .
				| /\     .
				|/t |________________________    Z(ecliptic)
	  		       /p\ /     .
                              /__/\      .
                             /     \     .
                            /       \ 	 .
                           /	     \   .
                          / 	      \  .
			 /	       \ .
			/		\.		
			X(ecliptic)

	*/

	MATRIX3 ENU2ECLIPTIC = _M(
		-sin(lon),	cos(lon)*cos(lat),	-cos(lon)*sin(lat),  
		0,			sin(lat),			cos(lat), 
		cos(lon),	sin(lon)*cos(lat),	-sin(lon)*sin(lat));
	
	ypr.x = atan(ENU2ECLIPTIC.m23/ENU2ECLIPTIC.m33);
	ypr.y = -asin(ENU2ECLIPTIC.m13);
	ypr.z = atan(ENU2ECLIPTIC.m12/ENU2ECLIPTIC.m11);

}
 
Last edited:

tblaxland

O-F Administrator
Administrator
Addon Developer
Webmaster
Joined
Jan 1, 2008
Messages
7,320
Reaction score
25
Points
113
Location
Sydney, Australia
The surface frame is not aligned with the ecliptic frame. The two frames differ by: 1. The rotation matrix of the planet wrt the ecliptic frame; and 2. The rotation matrix of the surface frame wrt to the planet.

The rotation matrix of the planet wrt to the ecliptic can be obtained using the API (sorry, don't have the reference manual handy so I can't give you the functions).

The rotation matrix of the surface frame wrt the planet can be calculated from the surface frame's origin (lat, lon) and the rotation axis of the planet (that's the z-axis in planet's frame IIRC).

If you set your vessel's rotation matrix to be equal to the rotation matrix of the surface frame wrt the ecliptic frame, then your vessel will be aligned such that the nose is pointing north, the right wing is pointing east and the pilot's head is pointing up (assuming the vessel follows Orbiter's convention for these things - not all do). I'm not clear whether or not that is the orientation you are trying to acheive.
 

shacharm

New member
Joined
Sep 15, 2012
Messages
10
Reaction score
0
Points
0
Yes, I am trying to put my vessel in the East-North-Up position, as you've stated.

about rotations, I've found:

* in oapiCreateVessel there's the paramater to insert the 3 angles of rotation.
* I've found
1) oapiGetPlanetObliquityMatrix: "Returns a rotation matrix which performs the transformation from the planet's tilted coordinates into global coordinates."
2) oapiGetPlanetObliquity: "Returns the obliquity of the planet's rotation axis (the angle between the rotation axis and the ecliptic zenith). "

but no where in the documentation does it say what are the proper rotations between frames?
 
Last edited:

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,637
Reaction score
2,353
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
thank you for the reply
however, I couldn't find - how do I get the surface rotation matrix ?

Its a simple rotation matrix based on:

  • Time since epoch
  • Orientation of the planets axis in space
  • Rotation speed of the planet
Technically, you would also have to correct between geographic coordinates and geocentric coordinates. We are still not sure what orbiter uses there in which context. Geographic coordinates are based on a reference ellipsoid, with equatorial bulge, geocentric coordinates use a sphere as reference geometry.

Since it changes over time, you would need to calculate the matrix for the time that you need.
 

shacharm

New member
Joined
Sep 15, 2012
Messages
10
Reaction score
0
Points
0
Now I'm more confused.
Looked for any formal definitions of axes in the documentation, found bits n bytes.

I want to create a vessel above the moon, that would just look to the north
I am doing it with the oapiCreateVessel() function

apparently, oapiCreateVessel() rotates from ECLIPTIC to LOCAL - by the documentation.

the documentation Also states that the rotation of the Planet
IS NOT THE Z AXIS, but the Y AXIS.

so I am not even sure how to get the surface rotation matrix compared to the ecliptic axis....
 
Top