X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 20 Dec 2019 03:53 PM by  Ben Castellani
Discrepancy in calculation of ATAN
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Dulci Avouris



New Member


Posts:51
New Member


--
17 Dec 2019 01:21 PM
    Hello!

    I found that when I use the ATAN function and input two arguments that I get a different result than if I first divide the arguments, and then calculate ATAN.

    i.e:

    theta = ATAN(num, den)/4 = -0.54489
    num = -2.48664
    den = -1.7322

    VS

    angle = (-2.48664)/(-1.7322) = 1.43454
    theta = ATAN (angle)/4 = 0.24051

    This angle is being used in a varimax rotation, and with a different result for theta, the resultant rotation is not correct.

    Please clarify what is happening here!

    Thank you.

    Ben Castellani



    Basic Member


    Posts:130
    Basic Member


    --
    20 Dec 2019 03:53 PM
    IDL is behaving properly. Try this to prove it:

    Y = -2.48664
    X = -1.7322
    DIV = Y/X

    theta = ATAN(Y,X)
    theta1 = ATAN(DIV)

    print, theta*180/!pi
    print, theta1*180/!pi

    You will get:

    -124.861
    55.1388

    The first value is where you input Y and X directly. IDL knows both are negative, so the resulting angle is the in the 3rd quadrant (-124.861 degrees). However, when you do the division on your own and enter it, the negatives are not known to ATAN and the angle resolve is 180 degrees rotates in the 1st quadrant (55.1388 degrees). Remember that tangent calculations require context to know which quadrant is correct.
    You are not authorized to post a reply.