StevenK Posted March 30, 2014 Report Share Posted March 30, 2014 Hey everyone. Im trying to get the Magnetic and True heading for the aircraft into C# I have the Offset - 0580 I have also used this Offset - 02A0 Both give different results. I just cant work out the formular to get the correct headding. Anyone mind helping me on this one. Link to comment Share on other sites More sharing options...
Paul Henty Posted March 30, 2014 Report Share Posted March 30, 2014 Hi Steven, Below is the code with all the conversion formulas. As you can see, once you've converted the true heading and magnetic variation to degrees you just need to subtract the magvar from the true heading to get the magnetic heading. Take care when declaring the offsets, note the different sizes and the fact that the true heading is Unsigned. private Offset<uint> headingTrue = new Offset<uint>(0x0580); private Offset<short> magVar = new Offset<short>(0x02A0); private void someMethod() { // after calling process() double headingDegreesTrue = (double)headingTrue.Value * 360.0 / (65536.0 * 65536.0); double magVarDegrees = (double)magVar.Value * 360.0 / 65536.0; double headingDegreesMagnetic = headingDegreesTrue - magVarDegrees; // mag heading may now be < 0 or > 360, so we need to normalise headingDegreesMagnetic %= 360; } I've 'spelt it out' there, you can obviously combine some of the steps to make the code shorter. Paul Link to comment Share on other sites More sharing options...
StevenK Posted March 30, 2014 Author Report Share Posted March 30, 2014 Ooooo Many thanks Paul I will give this a go and let you know how it works out :) Link to comment Share on other sites More sharing options...
StevenK Posted March 30, 2014 Author Report Share Posted March 30, 2014 Paul that is perfect Just what i was after Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now