![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Chit Chat The place for open discussions. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I want to calculate rate of change of track acorss ground (in degrees). You could call it rate of turn.
OK, it's simple....all you do is subtract the incoming reading from the privious one. Well not quite.......all is dandy until you sweep over the 360 degrees line. If you were turning clockwise you could get 359 - 1 = 358, where what you really want is '2'. Any ideas how you do this would be appriciated. Many thanks, Ben |
|
||||
|
If you take the difference of the incoming reading - previous reading you get a value.
Clockwise turning is positive and counterclockwise turning is negative. In your example: incoming reading 1° previous reading 359° so 1 - 359 = -358° This means a counterclockwise turning of 358° But this also means a clockwise turning of 2° The following code will give you the turn in +/- 180° Code:
DeltaDir = Direction(i) - Direction(i-1) If Abs(DeltaDir) > 180 Then If DeltaDir < 0 Then DeltaDir = DeltaDir + 360 Else DeltaDir = DeltaDir - 360 End If End If
__________________
Klaus Switzerland |
|
||||
|
Are you really shure ?
In the case when incoming reading 150° previous reading 120° DeltaDir=150-120=30 in your example DeltaDir<180 Then DeltaDir = DeltaDir + 360 = 390 Do you want that ? That's not what I want, I want results between -180 to + 180 In my code the result remains 30 because Abs(DeltaDir) is less than 180 Best regards.
__________________
Klaus Switzerland Last edited by klaus : 07-06-2009 at 10:02 AM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Math help please | cdeane | Chit Chat | 2 | 04-02-2009 05:45 PM |
| db2000 math functions | maXim | Italian Forum | 0 | 12-01-2008 11:24 AM |
| Small math-trainer | token | Share Your Creations | 3 | 07-17-2008 07:29 PM |
| Fixed Point Math | im4retro | Questions & Help Needed | 3 | 05-31-2008 07:13 AM |
| Help with Math function | go4saint | Questions & Help Needed | 2 | 03-31-2008 10:15 AM |