Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, Nov 03, 2004 at 04:02:19PM -0600, Jon S Berndt wrote: -atan2(-phi,theta) This looks *very* strange. An arc tangent of a quotient of angles?? Although it works out dimension-wise, I've never seen a quotient of angles in any formula. Cheers -Gerhard -- Gerhard Wesp o o Tel.: +41 (0) 43 5347636 Bachtobelstrasse 56 | http://www.cosy.sbg.ac.at/~gwesp/ CH-8045 Zuerich \_/ See homepage for email address! ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
-atan2(-phi,theta) This looks *very* strange. An arc tangent of a quotient of angles?? Although it works out dimension-wise, I've never seen a quotient of angles in any formula. Cheers -Gerhard Think of them as distances, really. It was meant to be the X and Y component of the rotated Z axis projected along the XY plane. Think of the angles in radians and project the unit vector components. Maybe it's not correct, I did it very quick, but qualitatively it seemed to work, and quantitatively it seemed correct for the few angles I checked. Jon ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
David Megginson wrote: I'm fixing the magnetic compass instrument to make its behaviour more realistic. Oh, my god, no more nice flight sim The trouble already began with the Beaver startup procedure ;-)) 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. Explaining in pictures is easier than dealing with single-line- equations :-) We'll see, Martin. -- Unix _IS_ user friendly - it's just selective about who its friends are ! -- ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 3 Nov 2004 15:36:33 + (UTC), Martin Spott [EMAIL PROTECTED] wrote: Explaining in pictures is easier than dealing with single-line- equations :-) We'll see, Multiple, sequential equations are welcome as well. Anything, really ... Thanks, David -- http://www.megginson.com/ ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
David Megginson wrote: On Wed, 3 Nov 2004 15:36:33 + (UTC), Martin Spott [EMAIL PROTECTED] wrote: Explaining in pictures is easier than dealing with single-line- equations :-) We'll see, Multiple, sequential equations are welcome as well. Anything, really ... Could you go into detail about what kind of compass/error we're talking ? Is it a conventional whiskey compass, so I assume no gyro driven instrument ? I mean how is it modelled or what is the cause ? That way it might be easier to come up with a formula/solution... My first VERY simple *guess* would be that it might be because of an imbalance in inertia of a compasses moving parts as soon as the pitch changes accordingly. --- Boris ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 03 Nov 2004 17:25:16 +0100 Boris Koenig [EMAIL PROTECTED] wrote: David Megginson wrote: On Wed, 3 Nov 2004 15:36:33 + (UTC), Martin Spott [EMAIL PROTECTED] wrote: Explaining in pictures is easier than dealing with single-line- equations :-) We'll see, Multiple, sequential equations are welcome as well. Anything, really ... Could you go into detail about what kind of compass/error we're talking ? The link that he gave goes into it in detail. -c -- 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 pgp3oE2zfBMM9.pgp Description: PGP signature ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
Boris Koenig wrote: My first VERY simple *guess* would be that it might be because of an imbalance in inertia of a compasses moving parts as soon as the pitch changes accordingly. It has to do with the fact that a whiskey compass has it's magentic 'detector' mountet parallel to the earth magnetic field of that area where the aircraft is supposed to be operated which means the detector has some orientation that is anything but parallel to the surface: http://www.phy6.org/Education/wfldline.html When you bank the aircraft then you'll encounter that the compass does not only point to the magnetic north, adding to that the 'detector' tries to orientate parallel to the magnetic field - which doesn't matter as long as you fly straight because the compass is adjusted accordingly. This results in the turning error, Martin. -- Unix _IS_ user friendly - it's just selective about who its friends are ! -- ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 03 Nov 2004 17:25:16 +0100, Boris Koenig [EMAIL PROTECTED] wrote: My first VERY simple *guess* would be that it might be because of an imbalance in inertia of a compasses moving parts as soon as the pitch changes accordingly. Other replies have pointed you to links explaining the turning error due to magnetic dip. It is quite dramatic in a real plane -- at my latitude (about 45 deg N), my compass can be more than 50 degrees off while the wings are banked, depending on the heading. You are correct, though, that there is also an overshoot error -- the compass will tend to overshoot and oscillate, rather than locking immediately onto a new heading. Alex already had code in place for that, and I plan to add it back in once I have the turning, pitch, and acceleration errors working. All the best, David -- http://www.megginson.com/ ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
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) with 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. -c -- 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 pgpBGhx0JxHeH.pgp Description: PGP signature ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 3 Nov 2004 14:04:05 -0500, Chris Metzler [EMAIL PROTECTED] wrote: 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) with 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) Thanks for all the work on that. I just tried it out, though, and it gives strange behaviour with negative (left) roll angles, even when pitch is close to 0. It's possible that I caused some confusion by using theta for pitch, when the original equation used it for roll -- here's the original equation from the Web page, translated into our normal phi/theta/psi variables, mu for magnetic dip, and preserving Hc for the indicated compass heading: Hc = atan2(sin(psi)cos(phi) - tan(mu)sin(phi), cos(psi)) In other words a = sin(psi)cos(phi) - tan(mu)sin(phi) b = cos(psi) Your suggested equation, using the same variable names, is a = cos(phi)sin(psi)cos(mu) - sin(phi)cos(theta)sin(mu) - sin(phi)sin(theta)cos(mu)cos(psi) b = cos(theta)cos(psi)cos(mu) - sin(theta)sin(mu) I'm really bad at this kind of thing, but when I set theta to 0, I end up with a = cos(phi)sin(psi)cos(mu) - sin(phi)sin(mu) b = cos(psi)cos(mu) Does that actually work out to the same thing by messing around with the trig? Thanks, and all the best, David -- http://www.megginson.com/ ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 3 Nov 2004 16:47:37 -0500 David Megginson [EMAIL PROTECTED] wrote: What does arctan(-phi/theta) give you? Jon ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 3 Nov 2004 16:47:37 -0500 David Megginson [EMAIL PROTECTED] wrote: After having scribbled for a LITTLE WHILE on the back of an envelope ;-) I am thinking that what you want is this: -atan2(-phi,theta) but I'll have to play a little bit more. I think this would give you the angle about the local vertical from the aircraft X axis to the most vertical ascent angle given the plane located by the aircraft X and Y axes. Jon ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 03 Nov 2004 16:02:19 -0600, Jon S Berndt [EMAIL PROTECTED] wrote: After having scribbled for a LITTLE WHILE on the back of an envelope ;-) I am thinking that what you want is this: -atan2(-phi,theta) but I'll have to play a little bit more. I think this would give you the angle about the local vertical from the aircraft X axis to the most vertical ascent angle given the plane located by the aircraft X and Y axes. I put it in a Perl script and played with it for different values of phi and theta, and all of the results looked reasonable. Now, how can I calculate the most vertical ascent angle itself? Thanks, and all the best, David -- http://www.megginson.com/ ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 3 Nov 2004 16:47:37 -0500 David Megginson [EMAIL PROTECTED] wrote: Thanks for all the work on that. I just tried it out, though, and it gives strange behaviour with negative (left) roll angles, even when pitch is close to 0. It's possible that I caused some confusion by using theta for pitch, when the original equation used it for roll -- here's the original equation from the Web page, translated into our normal phi/theta/psi variables, mu for magnetic dip, and preserving Hc for the indicated compass heading: Hc = atan2(sin(psi)cos(phi) - tan(mu)sin(phi), cos(psi)) In other words a = sin(psi)cos(phi) - tan(mu)sin(phi) b = cos(psi) Your suggested equation, using the same variable names, is a = cos(phi)sin(psi)cos(mu) - sin(phi)cos(theta)sin(mu) - sin(phi)sin(theta)cos(mu)cos(psi) b = cos(theta)cos(psi)cos(mu) - sin(theta)sin(mu) I'm really bad at this kind of thing, but when I set theta to 0, I end up with a = cos(phi)sin(psi)cos(mu) - sin(phi)sin(mu) b = cos(psi)cos(mu) Does that actually work out to the same thing by messing around with the trig? Yes, it does. Basically, just leave the cos(psi) in the denominator, and divide the cos(mu) that's in the denominator into a. In other words, cos(phi)sin(psi)cos(mu) - sin(phi)sin(mu) - cos(psi)cos(mu) = cos(phi)sin(psi)cos(mu)sin(phi)sin(mu) ---- --- cos(psi)cos(mu) cos(psi)cos(mu) (in the first term, cancel out the cos(mu) in the numerator and denominator; in the second term, take the sin(mu)/cos(mu) and replace it with a tan(mu) in the numerator) = cos(phi)sin(psi) sin(phi)tan(mu) - --- cos(psi) cos(psi) = (cos(phi)sin(psi) - sin(phi)tan(mu))/cos(psi) which is what you have above. So yeah, it does work out. I'll check my algebra again, but what are the chances that the strange behavior (you didn't describe what it was) you're seeing are numerical? In other words, when it occurs, what's the typical value of the argument of the arctan? -c -- 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 pgprkfqCL2EnT.pgp Description: PGP signature ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 03 Nov 2004 16:02:19 -0600 Jon S Berndt [EMAIL PROTECTED] wrote: On Wed, 3 Nov 2004 16:47:37 -0500 David Megginson [EMAIL PROTECTED] wrote: After having scribbled for a LITTLE WHILE on the back of an envelope ;-) I am thinking that what you want is this: -atan2(-phi,theta) Maybe I am missing what you are trying to do, but I just tried this in Excel: -atan2(theta,phi) which gives this: theta phi angle (from forward, positive clockwise) 45 0 0 45 -45 45 0 -45 90 -45 -45 135 -45 0 -180 -45 45 -135 0 45 -90 45 45 -45 0 0 BAD! 10 0 0 10 80 -82.87498365 80 10 -7.125016349 ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
David Megginson wrote: On Wed, 03 Nov 2004 16:02:19 -0600, Jon S Berndt [EMAIL PROTECTED] wrote: After having scribbled for a LITTLE WHILE on the back of an envelope ;-) I am thinking that what you want is this: -atan2(-phi,theta) but I'll have to play a little bit more. I think this would give you the angle about the local vertical from the aircraft X axis to the most vertical ascent angle given the plane located by the aircraft X and Y axes. I put it in a Perl script and played with it for different values of phi and theta, and all of the results looked reasonable. Now, how can I calculate the most vertical ascent angle itself? 1. a plane in the geometrical sense can be defined with a point and a vector that is perpedicular to that plane. Define a plane by picking your current location as the point, and pick the local up vector (opposite of the gravity vector) as your perpendicular vector. 2. define a vector as the x,y,z distances to the highest point on your rotated/pitched/yawed disk (which appears to be calculated with the atan2() formula above. 3. simgear/math/vector.hxx defines a function that maps/projects the vector from (2) onto the plane from (1) sgmap_vec_onto_cur_surface_plane() returning the mapped/projected vector as the result. Now you have a vector that lies on your horizontal plane, and a vector to your highest elevation point. All you need to do is find the angle between the two which off the top of my head is the arcsin of the dot product of the two vectors (probably normalized.) My linear algebra book is at home so this is all off the top of my head. Curt. -- Curtis Olsonhttp://www.flightgear.org/~curt HumanFIRST Program http://www.humanfirst.umn.edu/ FlightGear Project http://www.flightgear.org Unique text:2f585eeea02e2c79d7b1d8c4963bae2d ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 03 Nov 2004 16:17:24 -0600, Jon S Berndt [EMAIL PROTECTED] wrote: Maybe I am missing what you are trying to do, but I just tried this in Excel: -atan2(theta,phi) which gives this: theta phi angle (from forward, positive clockwise) 45 0 0 45 -45 45 0 -45 90 -45 -45 135 -45 0 -180 -45 45 -135 0 45 -90 45 45 -45 0 0 BAD! 10 0 0 10 80 -82.87498365 80 10 -7.125016349 Those look pretty reasonable for offsets from the aircraft's current heading. For example, if you're at 0 pitch a 45 degree right bank, uphill will be 90 degrees to the left of your current heading (-90). If you're pitched down 45 degrees and banked 45 degrees to the right, uphill will be 135 degrees to the left of your current heading; and so on. All the best, David -- http://www.megginson.com/ ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 3 Nov 2004 17:19:09 -0500 Chris Metzler [EMAIL PROTECTED] wrote: I'll check my algebra again, Checked; I can't find a mistake. As a third check, I ran it through Maple and got the same result. It appears to have the correct limiting behavior for both pitch -- 0 and roll -- 0 independently. And the problem seems straightforward to me. The compass needle is constrained to move on the horizontal plane in the aircraft's reference frame; the question is simply what's the (perpendicular) projection of the magnetic field vector onto that plane, and what direction does that point? You can move the plane by from level flight towards the north pole by yaw, then pitch, then roll; or you can do the opposite transformations on the magnetic field vector itself (same order, but opposite value of angles), and get the same relative orientation of the field vector to the aircraft. So I think this is analytically correct. What's the weird behavior? For what part of parameter space? -c -- 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 pgpWXAX5R5Qip.pgp Description: PGP signature ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
More: theta phi heading magnitude 45.00 0.000.0045.00 45.00 -45.00 45.0075.00 0.00 -45.00 90.0045.00 -45.00 -45.00 135.0075.00 -45.00 0.00 -180.0045.00 -45.00 45.00 -135.0075.00 0.00 45.00 -90.0045.00 45.00 45.00 -45.0075.00 45.00 0.000.0045.00 Not sure if this is really true, cause I have not yet figured out by longhand the ascent angle at 45/45 degrees, but it looks close if not right. The heading (as stated before) is: -ATAN2(theta,phi) The ascent angle magnitude is (where theta and phi are supplied in radians): 1.57 - ACOS(COS(theta)*(SIN(ABS(phi + ABS(theta) This might be able to be cleaned up considerably. Jon ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Plea for help: geometry/trigonometry problem
On Wed, 3 Nov 2004 20:16:08 -0500, David Megginson [EMAIL PROTECTED] wrote: I understand, logically, why this is happening: flying west with a magnetic dip of 71 and a bank of 20 to the south, I have an angle of over 90 degrees to the magnetic flow. I think I even remember the original article mentioning something like this, but I have no recollection of my airplane whiskey compass swinging around 180 degrees suddenly in real life -- if there's a window tomorrow before the low icing stuff moves in, I'll try to go up and take a look at what actually happens. To answer myself, here's the relevant part of the original web page: ==**== For steep turns, where the sum of the dip angle and bank angle exceeds 90 degrees, the compass will ``hang up''. The compass will refuse to turn through 360 degrees as the airplane makes a complete circle. It's easy to see why. Imagine being on a heading of East in the Northern hemisphere, and gradually increasing bank angle to the right. Initially, the north seeking end of the compass needle will point exactly North, towards the left wing tip. However, as the bank angle increases, a point is reached where the magnetic field becomes parallel to the airplane's vertical axis. Beyond this point, the compass needle will swing 180 degrees to point to the lower, right wingtip and the compass then indicates West instead of East! So it is not quite true to say there is no Northerly turning error on headings of East and West. Beyond the critical bank angle (equal to 90 minus the dip angle), the compass lags by 180 degrees when the airplane is banked toward the equator. ==**== Obviously, when the dip is over 70 degrees, it doesn't take a steep turn to cause this effect. The question is, does the compass hang up (i.e. bind and refuse to turn), or does it swing around? If it hangs up, that would explain why I haven't noticed the effect. Any comments from other pilots on the list, especially those who fly north of 40 in North America? Thanks, and all the best, David -- http://www.megginson.com/ ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
RE: [Flightgear-devel] Plea for help: geometry/trigonometry problem
Oops. ___ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d