On Wed, 3 Nov 2004 10:17:34 -0500
David Megginson <[EMAIL PROTECTED]> wrote:
> I'm fixing the magnetic compass instrument to make its behaviour more
> realistic.  I'm starting with the northernly turning error, and found
> a useful site that actually gives an equation:
>   http://williams.best.vwh.net/compass/node4.html
> Here's the equation (radians for all angles):
>   Hc: indicated compass heading
>   Hm: actual magnetic heading
>   phi: bank angle (right positive; the original web page uses theta)
>   mu: magnetic dip angle (down positive)
>   Hc = atan2(sin(Hm)cos(phi) - tan(mu)sin(phi), cos(Hm))
> The result is very realistic as far as bank/turning errors go, much
> better than anything I've seen in a desktop sim.  I've checked in the
> changes so that others can take a look.
> The problem is that this equation assumes that pitch (theta) is 0. 
> Now, I need to adapt this equation to incorporate theta as well, so
> that the compass will show an error when the nose is pitched up or
> down relative to the earth's surface.
> I imagine that the problem is fairly obvious to people with a basic
> knowledge of geometry and trig, but unfortunately, I am not one of
> those people.  I would be very grateful for someone could reply with
> an adaption of the above equation integrating theta.

A simple adaptation doesn't really work.  Using the variables as you've
defined them, and taking theta to be positive for pitched up, write

Hc = atan2(a, b)


a = cos(phi)sin(Hm)cos(mu) - sin(phi)cos(theta)sin(mu)
    - sin(phi)sin(theta)cos(mu)cos(Hm)

b = cos(theta)cos(Hm)cos(mu) - sin(theta)sin(mu)

I'd appreciate it if someone would check my matrix multiplication
(Euler rotations), but I'm pretty sure this is correct.  It reduces
to the equation you gave for the case of zero pitch (theta = 0).

The way to solve this problem is to imagine not that you're changing
the attitude of the plane, but that you're changing the orientation
of the vector instead.  So you start with the plane heading magnetic
north; the plane's aligned with the B vector in the XY plane (+X = east,
+Y = north) but the vector has a -Z component.  Rotating the plane
to a magnetic heading Hm is equivalent to rotating the XY components
of the B vector counterclockwise Hm.  Then pitching the plane up/down
corresponds to rotating the YZ components of the vector.  Then banking
the plane corresponds to rotating the XZ components of the vector.

You have to do it in this order.  I first tried it by creating the
state described on the web page you gave (plane at magnetic heading
Hm, and banked).  I then tried to apply the pitch.  But that won't
give you the right answer because pitching the plane up and down
in its own reference frame won't correspond to what we call pitch
since the plane is already banked.


Chris Metzler                   [EMAIL PROTECTED]
                (remove "snip-me." to email)

"As a child I understood how to give; I have forgotten this grace since I
have become civilized." - Chief Luther Standing Bear

Attachment: pgpBGhx0JxHeH.pgp
Description: PGP signature

Flightgear-devel mailing list

Reply via email to