Does this Angle difference Function look correct? :S

BlueIshDan

☠
Local time
Today, 08:34
Joined
May 15, 2014
Messages
1,121
I need help again! Can anyone verify that this function I made is correct?

Code:
' Return the difference between the two angles.
Public Function AngleDifference(ByVal angle_one As Integer, ByVal angle_two As Integer) As Integer
    Dim d As Integer: d = Abs(angle_one  - angle_two) Mod 360
    AngleDifference = IIf(d > 180, 360 - d, d)
End Function

Research Links:
JavaVersionCode
% Operator In Java is Mod in VBA
 
It looks fine but what is the formula?
I suppose this Java example is what you looked at:
Code:
int d = Math.abs(a - b) % 360;
int r = d > 180 ? 360 - d : d;
It's best to include the formula as well so we can do comparisons.
 
My apologies, I meant to provide it and yes that is the correct formula :)
 
Just for fun, I am reading the text book Engineering With Excel by Ronald W. Larson
Pearson - Prentice Hall during my Light Rail commute.
Yeah, I know it is Excel, but it covers the formulas and even VBA among many other things. It has a dozen pages out of 650 about Trig.
If you need to move the angles into resolving force (two forces at different angles), it has some great examples on page 184.
For example: multiple Horizontal and Vertical components of combined forces added together.

Looks like you are indeed on track for the question asked.

Also:
http://spreadsheets.about.com/od/excelfunctions/qt/070822_radians.htm
VBA in Excel (VBA in Access) easily converts Degrees to Radians.
It is easier to perform math on Radians. Perform summary operations, then convert the Radians back to Degrees. This link has is a short overview.

B.T.W. Reading a book with this title on the rail, you get the entire section of seats around you to stay empty. It is "very geeky". :)
 
Last edited:
Thank you very much for your detailed response. Do you know if doing math with these Radians supports rotating and scaling?

Edit: Blah sorry, thinking of a different thread of mine lol! THANKS!
 
About 3 weeks away from vacation. I can't wait!
First real vacation in about 6 years. WAUUGHA
 

Users who are viewing this thread

Back
Top Bottom