- Home /
Finding the Euler angles of an object's rotation in terms of a different set of axes
I am running a Unity project that tracks the positions and rotations of objects as they move around on a terrain. I need to output the positions and rotations of these objects in terms of a different set of world axes. Specifically, my terrain represents a real world location. I need to report the positions and rotations of these objects in terms of GLOBAL space rather than unity space. So an object moving along the Unity vertical axis would not be moving solely along the Global vertical axis (unless you were at the poles), therefore I must convert this y-movement to some combination of x-y-z movement.
I have this positional transformation working, but am struggling to do the same with the rotation. I need to find the Euler angles of an objects rotation with respect to the Global x-y-z axes. The only real data I have to work with is the normal vector of the terrain with respect to the global earth axis. For example, if I had my terrain on the intersection of the prime meridian and the equator, my normal vector would be (1,0,0).
The expected result is that an object sitting on the intersection of the equator and prime meridian rotating about its local y axis would report rotations about the global x axis.
I feel like there must be a simple way to do this, but my lack of experience with rotations and quaternions is stumping me pretty hard here.