[R] Get bearing for cartesian coordinates

Bill.Venables at csiro.au Bill.Venables at csiro.au
Tue Jul 28 08:04:39 CEST 2009


I think all you need is 

bearing <- function(x, y) atan2(y, x)*180/pi

This gives the bearing in degrees from the origin.  If you wanted the bearing from some other point, just take the differences:

bearing <- function(x, y, origin = c(x=0,y=0)) 
	atan2(y-origin["y"], x-origin["x"])*180/pi


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of pecardoso
Sent: Tuesday, 28 July 2009 9:40 AM
To: r-help at r-project.org
Subject: [R] Get bearing for cartesian coordinates

Is it possible to get bearing in degrees from Cartesian (not lat long) coordinates?


	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list