I have a small video camera with an attached sensor. I can get from the sensor his acceleration, gyro and compass data. Knowing this data I need to rotate the camera so that it will look strictly north.

I know how to rotate the camera, but how to calculate the right angle?

How can I do it? Or where can I read about it? Or, if this is not a right place to ask such a question, what is the right place?


All coordinates are in an Earth-fixed inertial frame.The compass and accelerometer readings are unit vectors, and the gyroscope readings are in radians per second

  • 2
    What, precisely, is the form of the gyro and compass data?
    – whuber
    Jan 4, 2014 at 19:38
  • @whuber: XYZ vector
    – Flot2011
    Jan 5, 2014 at 8:43
  • 1
    Let me just double check the interpretation "XYZ vectors" in this context. You seem to saying that the "compass data" are a vector (X_c, Y_c, Z_c). (1) Is this the direction the camera is pointed? (2) In what frame are the coordinates? Are they in earth-centric Cartesian coordinates, in local geodetic coordinates, or perhaps are they coordinates of a northern direction relative to a dedicated camera frame? (3) Apparently the "gyro data" are also in the form (X_g, Y_g, Z_g). (4) What does this mean?
    – whuber
    Jan 5, 2014 at 15:34
  • @whuber: see my edited answer
    – Flot2011
    Jan 5, 2014 at 19:50
  • 1
    You're still not explaining this very well. Can you try to add a diagram showing the reference frames. In particular, some details of how you initialise the inertial sensors might help, and how the inertial frame varies relative to ECEF (or some local coordinate frame) over time. Also, are the compass measures really in an inertial frame?
    – BradHards
    Jan 5, 2014 at 22:08

1 Answer 1


These Q&As don't cover acceleration and gyroscopes, but they do concern true and magnetic north:


TN: true north
|     MN: magnetic north    
|     /         VH: vehical heading 
|    /        -^
|MD /      -^
|  / MB -^
| /  -^

True bearing = magnetic bearing (MB) + magnetic declination (MD)

Note: MN may be to West or East of TN

Regarding Earth-fixed and Inertial reference frames:

Earth-centered inertial (ECI) coordinate frames have their origins at the center of mass of the Earth. ECI frames are called inertial in contrast to the Earth-centered, Earth-fixed (ECEF) frames which rotate in inertial space in order to remain fixed with respect to the surface of the Earth.


For a possibly very useful Python library, see How To: Transform between the Earth Centered Fixed and Earth Centered Inertial reference frames

It shows how to use Analytical Graphics, Inc's Dynamic Geometry Library to compute the rotation between the Earth Centered Fixed (ECF) and Earth Centered Inertial (ECI) reference frames.

  • 1
    How would the original poster use the information in those links? We discourage link-only answers, even to our own stuff. Since it doesn't actually answer the question, perhaps it would be better as a comment against the original question.
    – BradHards
    Jan 4, 2014 at 22:53
  • I added more details and another reference. We cannot say if it answers the Q or not because (as you et al. have said) the Q is unclear, but i think we have the beginnings of an answer or at least some useful info.
    – Martin F
    Jan 6, 2014 at 1:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.