bravotango
asked on
Java Trigonometry
This is really a math problem but I am trying to get the sin for angles in compass bearings.
Azimuth starts from North and bearings are from 0 to 359 degrees. All goes well from 0 to 90 but then the results are incorrect due to the fact that java math requires angles in radians and higher angles return minus results. What would be the best solution to get around this. Should I break the compass into quadrants and return results to their specific quadrant?
Azimuth starts from North and bearings are from 0 to 359 degrees. All goes well from 0 to 90 but then the results are incorrect due to the fact that java math requires angles in radians and higher angles return minus results. What would be the best solution to get around this. Should I break the compass into quadrants and return results to their specific quadrant?
Is your question about how to convert degrees to radians?
radians = degrees*pi/180
where pi = 4*atan2(1,1) = 3.141592653589793238462643 383279...
radians = degrees*pi/180
where pi = 4*atan2(1,1) = 3.141592653589793238462643
the sine of some angles ARE neative.
ASKER
Thanks for the comments.. I think I am on a better understanding of my problem now.
I found this comment on a very good site regarding solar problems.
The warning about trigonometric functions expecting angles expressed in radians still applies. Note that the azimuth needs to be expressed as a value between 0º and 360º, or -180º and 180º. To do this, consider that the tangent of an angle is y/x. Typically, programming languages and spreadsheets include arctangent functions that require both the x and y coordinates to be specified so the function can consider the sign of each component to determine the proper quadrant for the result.
I just need to work out how to do this.
I found this comment on a very good site regarding solar problems.
The warning about trigonometric functions expecting angles expressed in radians still applies. Note that the azimuth needs to be expressed as a value between 0º and 360º, or -180º and 180º. To do this, consider that the tangent of an angle is y/x. Typically, programming languages and spreadsheets include arctangent functions that require both the x and y coordinates to be specified so the function can consider the sign of each component to determine the proper quadrant for the result.
I just need to work out how to do this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the solution ozo. I am headed in the right direction now!!
For SIN
SIN(180-x) = SIN(x)
SIN(180+x) = -SIN(x) of course you have to convert to radians
SIN(90-x) = COS(x)
SIN(90+x) = COS(x)