Jump to content
The simFlight Network Forums

FSUIPC_Write in Visual Basic


Recommended Posts

you're probably overflowing the magvar variable

i use

MagVar = MagVar / 65536 * 360

what is the real magnetic variation where you're at? i'm betting that it is really -20, which will yield a number slightly higher than 360

so you will need a routine to take a heading that is larger than 360, and normalize it to a number between 0 and 359

jd

Link to comment
Share on other sites

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

If I do the final math I get -19.68761

Any ideas?

It's correct. It's about -20 degrees from north, which is another way of saying 340 which is what you were looking for.

To translate your -20 into 340 just add 360.

When you're working with headings this happen alot, sometimes you get negative headings, sometimes over they go over 360.

As JD says, you just need to write a function to normalise them. He posted one eariler in this thread, about 12 messages up. It's called norm360. You need to call that everytime you do maths on a heading and you want it in conventional 0-360 notation.

Paul

Link to comment
Share on other sites

The Plane Heading is returning .312 while at 340. The MagVar is returning 20.

If I do the final math I get -19.68761

Any ideas?

Yes, -19.68761 is correct. Think of the degrees round a circle, Counts 0 to 360 clockwise, 0 to -360 anticlockwise. -19.68761 is identical to 340.31239.

The problem is only that you are using signed numbers instead of unsigned numbers (the Heading is unsigned), but that's not your fault because VB stupidly doesn't support unsigned arithmetic.

Just add 360.0 when you have negative result.

This is not rocket science by the way, just elementary junior arithmetic.

Regards,

Pete

Link to comment
Share on other sites

Ah .. is that a later version? Last time I looked it didn't. Does it also support 16-bit (short) values too now?

VB has always supported 16-bit integers - they are called 'Integer'. 32-bit integers are called 'Long' in VB. 64-bit integers are not supported.

VB6 does not support unsigned 16-bit or 32-bit integers. The 8-bit integer (Byte) is treated as unsigned.

VB.NET 2003 added 64-Bit integers and changed the integer naming to the more usual:

16-Bit = Short

32-Bit = Integer

64-Bit = Long

VB.NET 2005 finally added support for unsigned Integers: UShort, UInteger and ULong.

Paul

Link to comment
Share on other sites

  • 10 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.