# Thread: Get angle from 2 points

1. ## Get angle from 2 points

Hi,

How can I get the angle from 2 xy coordinates?

Point 1 (2,1), Point 2 (4,5). What I want is the angle from/between point1 to point2.

Thanks.

2. ## Re: Get angle from 2 points

Originally Posted by mplus
Hi,

How can I get the angle from 2 xy coordinates?

Point 1 (2,1), Point 2 (4,5). What I want is the angle from/between point1 to point2.

There is no angle between two points.
An angle is the union of two rays with common endpoints.

3. ## Re: Get angle from 2 points

you mean the angle which made from the line that pass from the two points with the x-axis (cute angle, < 90 )?? if that so
tan ( angle ) = slope
slope of that line is 4/2 = 2
so the angle will be arctan(2)

4. ## Re: Get angle from 2 points

Yes what Amer said is what I meat.

But atan(2) = 1.107. The answer I was looking is between 30-40degrees (pure by looking at it).

I hope it describes it better.

5. ## Re: Get angle from 2 points

Originally Posted by mplus
Yes what Amer said is what I meat.

But atan(2) = 1.107. The answer I was looking is between 30-40degrees (pure by looking at it).

I hope it describes it better.
atan(2) = 1.107 radians .. check the mode of your calculator and change it to degrees if you want degrees

6. ## Re: Get angle from 2 points

No its for a programming language.

7. ## Re: Get angle from 2 points

Originally Posted by mplus
Yes what Amer said is what I meat.

But atan(2) = 1.107. The answer I was looking is between 30-40degrees (pure by looking at it).
Well there are still mathematical dinosaurs who still use degrees.
For those left behind you want $\frac{\arctan(2)\cdot 180^o}{\pi}=63.435^o.$

8. ## Re: Get angle from 2 points

Yes I can to that conclusion too of 63 degrees. But the answer doesn't look correct. The answer should be somewhere between 30-40 at the most.

So whats wrong?

9. ## Re: Get angle from 2 points

If you slide the line over till it hits the y axis, it looks around 63 degrees to me.

I to am trying to create a function that can calculate degrees from a graph for the purpose of a script in Script-fu for GIMP. However, the problem is the slope of 90 degrees is y/0, which creates some difficulty when writing a function.

Any input is appreciated.

Thank you.

10. ## Re: Get angle from 2 points

Originally Posted by mplus
Yes I can to that conclusion too of 63 degrees. But the answer doesn't look correct. The answer should be somewhere between 30-40 at the most.
Please explain why you think so.

11. ## Re: Get angle from 2 points

The angle, as shown in your picture, is clearly larger than 40 degrees. Where did you get the condition that it must be "between 30-40 at the most"?

12. ## Re: Get angle from 2 points

I updated the image.

If you were to place point1 at 0,0 so in the center it definitely isn't over 45degrees.

13. ## Re: Get angle from 2 points

Are you aware that, as customary in mathematics and as stated explicitly in post #3, the angles are measured between the line in question and the x-axis (the horizontal one)?

14. ## Re: Get angle from 2 points

Well I was hoping to get the degrees starting at the 0 degrees.

I can do 63-90 = 27degrees. But I was hoping to get a formula which starts at 0 degrees, the upper y axis.

15. ## Re: Get angle from 2 points

You can either subtract the found angle from 90 or take the arctangent of Δx / Δy instead of Δy / Δx. Here Δx is the difference of the x-coordinates and similarly for y.

Page 1 of 2 12 Last