Results 1 to 11 of 11

Math Help - What is the difference between arctan and atan?

  1. #1
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    13

    What is the difference between arctan and atan?

    What is the difference between arctan and atan?

    Thank you.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Prove It's Avatar
    Joined
    Aug 2008
    Posts
    10,964
    Thanks
    1008

    Re: What is the difference between arctan and atan?

    The spelling...
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    13

    Re: What is the difference between arctan and atan?

    I ask because I was given this formula to calculate the degree of a slope(m):

    If m is equal to or more than 0 then that angle is = arctan(m)
    if m is less then that angle is = pi + arctan(m)

    I having problems making this work in the code I'm writing. The code demands 1 argument (e.g. atan -1) to function. Should I be using "atan 1" in the above formula.

    Thanks.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor

    Joined
    Apr 2005
    Posts
    14,973
    Thanks
    1121

    Re: What is the difference between arctan and atan?

    "atan(x)" will return a negative number for x< 0. If you want the angle between 90 and 180, after y= atan(x) add the code "if y< 0 then y= 180- y".
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor

    Joined
    Mar 2011
    From
    Tejas
    Posts
    3,150
    Thanks
    591

    Re: What is the difference between arctan and atan?

    if a slope is between 0 and 90 degrees (that is: 0 and π/2 radians); if we have a line that lies in the first and third quadrants only, such lines have "positive slope".

    because lines through the origin go "both ways" away from the origin, angles in the range (in radians) 0 to -π/2 represent the "same slopes" as angles in the range π/2 to π radians.

    as i understand it, "atan" is the function implemented by programming languages such as C++ for arctan, and returns values (in radians) in the range: -π/2 ≤ atan(x) ≤ π/2. if you want these values in degrees, you must calculate atan(x*180/π). as HallsofIvy pointed out above, if you want the slope degree expressed as a positive number, you need an extra line of code:

    if y = atan(x*180/π) < 0, then y → 180 - y (i have used an arrow to indicate a new assignment for the variable y) if your output is to be in degrees

    if y = atan(x) < 0, then y → π - y, if your output is to be in radians.

    you CAN put the "if" branch before calculating atan:

    if m < 0, slopeangle → π + atan(m)
    else slopeangle → atan(m)

    (if your output is supposed to be in radians)

    if m < 0, slopeangle → 180 + atan(180*m/π)
    else slopeangle → atan(180*m/π)

    (if your output is supposed to be in degrees).

    in the above i have assigned a value to "slopeangle" which will probably have to be declared earlier in the code (as type real, for example).
    Last edited by Deveno; August 5th 2012 at 08:20 AM.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    13

    Re: What is the difference between arctan and atan?

    Thank you both for responding. I've read through your posts and tried to absorb everything I can. This is truly a learning experience for me and I appreciate your help. I want to add, I have spent days trying to figure this issue out for myself. Googled extensively looking for any examples, reviewing tutorials and reviewing other peoples scripts. I found nothing that I could use. I am not a math wizard and am a little (understatement) introverted, so it takes me a little longer than most to understand the information given. But once I get it, it sticks and stays.

    I should have been more specific from the beginning, but I was hesitant because of a previous post I made and the response I received.

    I am trying to write a script for a image manipulation program called GIMP. The script makes random lines on the image and I need to make sure the brush angle is set to the angle of the line.

    So within the code, GIMP generates a random line which I can then extract the x1, y1, x2, y2 coordinates. From this I get the slope(m).

    Information I think (but am not certain) is relevant to help answer my question:

    First, in a sense there is really only one quadrant. In an image 400 pixels wide and 250 pixels in height. There are no negative coordinates, but I would assume it could still create negative slopes. - run/ rise or run/-rise.



    The brush degrees are described as follows:



    I'm not certain how to properly describe it, the angles can be drawn on any part of the image:



    Does any of this change what you have previously posted? Please excuse my ignorance.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    13

    Re: What is the difference between arctan and atan?

    Additionally, Script-fu for GIMP requires an argument (e.g. atan -1) to function. Should I be using "atan 1" in the above formula. I simply can't use (atan(slope)).
    Follow Math Help Forum on Facebook and Google+

  8. #8
    MHF Contributor

    Joined
    Apr 2005
    Posts
    14,973
    Thanks
    1121

    Re: What is the difference between arctan and atan?

    I'm puzzled by why you are saying that. Of course atan requires an argument. It is a function and gives different results for different arguments.v Using "atan(1)" will always give you 45 degrees, the arctan of 1. If you want to get the angle a line makes then you MUST use the slope as the argument. Why do you say you cannot?
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    13

    Re: What is the difference between arctan and atan?

    (atan 1) gives me .7853981634
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    13

    Re: What is the difference between arctan and atan?

    (atan 0.5) gives me .463647609
    Follow Math Help Forum on Facebook and Google+

  11. #11
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    13

    Re: What is the difference between arctan and atan?

    Thank you HallsofIvy & Deveno. Without your help I wouldn't have been able to continue to Google research this problem. It was your input that lead me to find the formula I needed. Which is:

    (180 * Arctan(slope) )/ Pi

    or in Script-fu

    (/ (* 180 (atan slope)) *pi*))

    or more specifically

    (set! slope (/ (- y2 y1)(- x2 x1)))
    (set! angle (/ (* 180 (atan slope)) *pi*))

    Thank you again for all your time. It is truly appreciated and I am humbled by your dedication to solving other peoples difficulties. Karma is on your side!
    Last edited by Phoenix999; August 5th 2012 at 05:46 PM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. arctan(y) = x^2 + C, y = ?
    Posted in the Trigonometry Forum
    Replies: 2
    Last Post: October 17th 2010, 03:39 AM
  2. arctan ?
    Posted in the Trigonometry Forum
    Replies: 6
    Last Post: August 24th 2009, 03:38 PM
  3. precalculating atan values
    Posted in the Trigonometry Forum
    Replies: 0
    Last Post: January 24th 2009, 12:26 AM
  4. Regarding ATan/ARCTAN
    Posted in the Trigonometry Forum
    Replies: 2
    Last Post: August 24th 2008, 08:58 PM
  5. arctan(x)
    Posted in the LaTeX Help Forum
    Replies: 6
    Last Post: June 2nd 2008, 08:51 PM

Search Tags


/mathhelpforum @mathhelpforum