# Thread: What is the difference between arctan and atan?

1. ## What is the difference between arctan and atan?

What is the difference between arctan and atan?

Thank you.

2. ## Re: What is the difference between arctan and atan?

The spelling...

3. ## 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.

4. ## 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".

5. ## 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 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).

6. ## 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.

7. ## 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)).

8. ## 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?

9. ## Re: What is the difference between arctan and atan?

(atan 1) gives me .7853981634

10. ## Re: What is the difference between arctan and atan?

(atan 0.5) gives me .463647609

11. ## 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!

,

,

,

,

,

# atan or arctan

Click on a term to search for related topics.