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.

Attachment 24408

Thanks.

Printable View

- Aug 2nd 2012, 12:21 PMmplusGet 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.

Attachment 24408

Thanks. - Aug 2nd 2012, 12:29 PMPlatoRe: Get angle from 2 points
- Aug 2nd 2012, 12:29 PMAmerRe: 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) - Aug 2nd 2012, 02:51 PMmplusRe: 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. - Aug 2nd 2012, 02:59 PMskeeterRe: Get angle from 2 points
- Aug 2nd 2012, 03:32 PMmplusRe: Get angle from 2 points
No its for a programming language.

- Aug 2nd 2012, 04:01 PMPlatoRe: Get angle from 2 points
- Aug 2nd 2012, 05:54 PMmplusRe: 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? - Aug 2nd 2012, 10:46 PMPhoenix999Re: 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. - Aug 3rd 2012, 01:09 AMemakarovRe: Get angle from 2 points
- Aug 3rd 2012, 04:41 AMHallsofIvyRe: 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"?

- Aug 3rd 2012, 05:56 AMmplusRe: 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.

Attachment 24410 - Aug 3rd 2012, 06:05 AMemakarovRe: 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)? - Aug 3rd 2012, 06:57 AMmplusRe: 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. - Aug 3rd 2012, 07:04 AMemakarovRe: 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.