Re: [R] Angle between two points with coordinates

2016-01-29 Thread Gwennaël Bataille
Thank you very much for your quick answers! The %% operator seems the easiest way to go; it works perfectly. Best regards, Gwennaël Le 28/01/2016 20:39, William Dunlap a écrit : > In addition to the other fine answers, you might find it convenient > to represent the points as complex numbers an

Re: [R] Angle between two points with coordinates

2016-01-28 Thread William Dunlap via R-help
In addition to the other fine answers, you might find it convenient to represent the points as complex numbers and use the Arg function to get the angle (and abs() or Mod() the distance). > z <- complex(real=0.8660254, imaginary=0.5) > Arg(z) / base::pi * 180 [1] 30 > Arg(-z) / base::pi *

Re: [R] Angle between two points with coordinates

2016-01-28 Thread Dalthorp, Daniel
Gwennaël, Does the %% operator work for you? It gives x mod y (or the remainder after dividing x into y...result is guaranteed to be <=0 and >y) E.g. -150 %% 360 # 210 570 %% 360# 210 https://stat.ethz.ch/R-manual/R-devel/library/base/html/Arithmetic.html -Dan On Thu, Jan 28, 2

Re: [R] Angle between two points with coordinates

2016-01-28 Thread Jeff Newmiller
Functions return one value. Look at ?atan2 to address ambiguity in identifying angles. -- Sent from my phone. Please excuse my brevity. On January 28, 2016 9:09:53 AM PST, "Gwennaël Bataille" wrote: >Dear all, >I'd like to calculate the angle from one point (origin) to another >(target), wh

[R] Angle between two points with coordinates

2016-01-28 Thread Gwennaël Bataille
Dear all, I'd like to calculate the angle from one point (origin) to another (target), whatever their coordinates. But I encounter some problems (detailed below). The problem could be solved if one of you could answer positively to one of the following questions: 1) Is there a function in R c