[R] Function to find angle between coordinates?

2009-09-01 Thread clair.crossup...@googlemail.com
Dear all, I was doing some self study and was wondering if a function already exists which allows one to determine the angle between points. e.g. given the following (x,y) coordinates input: (0,1); (0,0); (1,0) would result in: output: 90 degrees Best regards C.C.

Re: [R] Function to find angle between coordinates?

2009-09-01 Thread Gabor Grothendieck
That is if they have length 1 as is the case here. Normalize them to length 1, if not. On Tue, Sep 1, 2009 at 11:06 AM, Gabor Grothendieckggrothendi...@gmail.com wrote: Since the inner product of two vectors if the cos of the angle between them: A - c(0,1); O - c(0,0); B - c(1,0) acos((A-O)

Re: [R] Function to find angle between coordinates?

2009-09-01 Thread Erik Iverson
?atan2 is a possible starting point. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of clair.crossup...@googlemail.com Sent: Tuesday, September 01, 2009 8:09 AM To: r-help@r-project.org Subject: [R] Function to find angle between

Re: [R] Function to find angle between coordinates?

2009-09-01 Thread Gabor Grothendieck
Since the inner product of two vectors if the cos of the angle between them: A - c(0,1); O - c(0,0); B - c(1,0) acos((A-O) %*% (B-O)) * 180 / pi [,1] [1,] 90 On Tue, Sep 1, 2009 at 9:08 AM, clair.crossup...@googlemail.comclair.crossup...@googlemail.com wrote: Dear all, I was doing

Re: [R] Function to find angle between coordinates?

2009-09-01 Thread clair.crossup...@googlemail.com
Thank you very much, these were exactly what i needed! :-) C.C. On 1 Sep, 14:08, clair.crossup...@googlemail.com clair.crossup...@googlemail.com wrote: Dear all, I was doing some self study and was wondering if a function already exists which allows one to determine the angle between