Check out the bookstore at IRBS.com
| Home | Mailing Lists | Bookstore | Weather | Tide Predictions | Bowditch |

Re: Azimuth Equation revisited

From: Herbert Prinz (no email)
Date: Fri Oct 21 2005 - 14:10:14 EDT

  • Next message: Bill: "Azimuth Formula Questions"

    T. Shanklin wrote:

    > But I am still wondering why the equation worked just fine for all the
    > other values and only started giving me error messages after LHA>345
    > degrees. All my Zn calculations were fine until then.

    What do you mean by "fine"? That you did not get an error message? I
    can't imagine that the results were correct. Did you check this?

    > Further, while we are on the subject: What exactly is meant by Step 3 on
    > pg 279 of the N.A.? Is it simply that if the value calculated for X is
    > greater than 1, then X is assigned the value +1, and hence when A is
    > calculated (cos-1 X) it is simply 0 degrees True, and 180 degrees True if
    > the value of X is less than -1 (hence = -1)?

    Ecactly. Rounding errors may cause the argument of the arccos function
    to be out of the permissable range, which would certainly blow up your
    program and raise an error message.

    > And what is defensive coding?
    > Am I correct to assume simply putting in the If clause in my
    > programming to
    > insure that if X>+1, then set it equal to +1 &c.?

    Yes. Defensive coding means not to make any assumptions about anything
    that you don't know. Don't rely on some assumed internal decimal
    precision or rounding mechanisms. Don't expect the implementation of
    trig or exp functions to be accurate to the last digit. Don't expect
    that the sun will never be exactly in the zenith, or that you will never
    be on the pole. Don't even expect that the sun will never be in the
    zenith when you are on the pole.

    Herbert Prinz


  • Next message: Bill: "Azimuth Formula Questions"



    | Home | Mailing Lists | Bookstore | Weather | Tide Predictions | Bowditch | Trawlerworld |