Aiken, Greg wrote: > > Note that for 'input' angles (ie, column 1 values) of 0 through 'less than > 180', the angle returned by 'atan2' (ie, the last column) EXACTLY MATCHES > the 'input' angle (ie, column 1 exactly matches the last column). > > Note that for 'input' angles of 180 through 360, the angle returned by > 'atan2' DOES NOT MATCH the 'input' angle (ie, column 1 does not exactly > match the last column). > > My questions are; > > 1. Why is this happenning? Because the returned angle from atan2 can be reported as either a positive angle or a negative angle. The function has been programmed to return the value that has the smallest absoulute value. For example, 345 degrees is equivalent to -15 degrees. Since 15 is smaller than 345, the programmer assumed that the user would prefer to see the answer as -15 rather than 345. It is an arbitrary choice, but a faily standard one if you delve into numerical standards. > > 2. Would it be incorrect of me to assume (just because it looks so in this > sparse sample data set) that if I constrain my evaluations to be in the > range of 0 through 90, that I will always have EXACT results, or does the > possibility of error still exist, even though it is not evident from this > sparse sample data set? I don't think your results are as exact as the printout implies. You have a rough approximation for pi (22/7). When the angle gets returned as a negative value, your print format breaks down, and more accuracy is displayed. But if you were using a sufficiently accurate value of pi, the results in the 0 through 90 range (as well as the 0 through 180 range) would come back with same value that was started with. > > 3. How have others traditionally solved this problem? If you don't want negative angles returned, then add 360 to the result if the result < 0. > > ===== Want to unsubscribe from this list? > ===== Send mail with body "unsubscribe" to macperl-request@macperl.org -- Richard L. Grubb Boeing Wichita ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org