Learn R Programming

FREddyPro (version 1.0)

polar2cart: Polar to cartesian

Description

Converts polar co-ordinates to the cartesian system.

Usage

polar2cart(x, y, dist, bearing, as.deg = FALSE)

Arguments

x
The X cartesian co-ordinate of the point of origin.
y
The y cartesian co-ordinate of the point of origin.
dist
The distance (m) of each point from the point of origin.
bearing
The polar bearing of each point to convert.
as.deg
Logical. If true the polar bearing is in degrees.

Examples

Run this code
## Close any previously open graphic devices
graphics.off()

## Load the data
data(fluxes)

## Set the point of origin
x=0;y=0

## Use wind direction, distance and distance from the tower to convert
## to cartesian co-ordinates
pol<-polar2cart(x,y,fluxes$x_90.,fluxes$wind_dir,as.deg=TRUE)

## Plot the distance from the tower
plot(pol,xlab='X (m)',ylab='Y (m)',pch=16,cex=0.6)

## Add also the tower point
points(0,0,col=2,pch=16,cex=1.2)

Run the code above in your browser using DataLab