Tough math question involving rotations

Hello all,

I’m trying to create Google Starmap-like controls for a mobile game, and I’m starting to regret skipping my Linear Algebra lectures. It’s become clear to me after doing some research, that the camera’s rotation is determined based on the phone’s accelerometer and 3D compass. These two orthogonal vectors (and their orthogonal cross-product) define the “phone space” relative to “local earth space.” I want to take this rotation of coordinate systems and apply it to the scene camera in order to make the screen a “window” into the virtual world. I’ve already solved the problem of getting the compass data (boo Unity for not getting this internally :frowning: ) but the best that I’ve come up with is a hack involving some dummy gimbal objects and the result of SensorManager.getOrientation() from the Android framework.

I know there are some Unity devs who know the math here, and I’m sure some users out there can also help, but my feeble uneducated brain can’t figure it out. Would anyone care to enlighten me?

Thanks in advance, and I was just kidding about the “boo Unity” part above. Writing the plugin took no time at all. Yaay Unity!

Thanks in advance for the help

I can help you on this in about 16 hours time if nobody else answers first. Sorry, I’ve been awake for 25 hours straight on just 5 hours sleep, and I probably still have another 5 or 6 hours to go before I see bed. I know this is an easy math problem, I just cannot for the life of me bring to mind the transform you need.

I would also suggest snagging these books, I use them as coursebooks for my students on various graphics programming, mathematics , and physics courses I teach.