tag:blogger.com,1999:blog-6672560504141734407.post2775909560005262839..comments2023-02-25T07:27:15.038-06:00Comments on Taking Dot Net "Old School": Calculating the average of two angles (two bearings actually)Lee Saundershttp://www.blogger.com/profile/02660551995265335503noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-6672560504141734407.post-50714728401717239012016-05-03T09:43:59.394-05:002016-05-03T09:43:59.394-05:00Thanks! I believe there is a typo above in the exa...Thanks! I believe there is a typo above in the example: 354 degrees should be 345 degrees.<br />I used this example to translate a VB equivalent. Here it is if anyone else is interested:<br /><br />Public Function AverageBearing(ByVal BearingA As Double, ByVal BearingB As Double) As Double<br /> Dim TempBearing As Double<br /> Dim FinalBearing As Double<br /> If BearingA > BearingB Then<br /> TempBearing = BearingA<br /> BearingA = BearingB<br /> BearingB = TempBearing<br /> End If<br /> If (BearingB - BearingA) > 180 Then BearingB = BearingB - 360<br /> FinalBearing = (BearingB + BearingA) / 2<br /> If FinalBearing < 0 Then FinalBearing = FinalBearing + 360<br /> AverageBearing = FinalBearing<br />End FunctionAnonymousnoreply@blogger.com