# cart2pol: cart2pol In useful: A Collection of Handy, Useful Functions

## Description

Converts polar coordinates to cartesian coordinates

## Usage

 `1` ```cart2pol(x, y, degrees = FALSE) ```

## Arguments

 `x` The x-coordinate of the point `y` The y-coordinate of the point `degrees` Logical indicating if theta should be returned in degrees

## Details

Converts polar coordinates to cartesian coordinates using a simple conversion. The angle, `theta` must be in radians.

Somewhat inspired by http://www.r-bloggers.com/convert-polar-coordinates-to-cartesian/ and https://www.mathsisfun.com/polar-cartesian-coordinates.html

## Value

A data.frame holding the polar coordinates and the original (x,y) coordinates

Jared P. Lander

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21``` ```library(dplyr) x1 <- c(1, sqrt(3)/2, sqrt(2)/2, 1/2, 0) y1 <- c(0, 1/2, sqrt(2)/2, sqrt(3)/2, 1) d1 <- data_frame(x=x1, y=y1, Q='I') x2 <- c(0, -1/2, -sqrt(2)/2, -sqrt(3)/2, -1) y2 <- c(1, sqrt(3)/2, sqrt(2)/2, 1/2, 0) d2 <- data_frame(x=x2, y=y2, Q='II') x3 <- c(-1, -sqrt(3)/2, -sqrt(2)/2, -1/2, 0) y3 <- c(0, -1/2, -sqrt(2)/2, -sqrt(3)/2, -1) d3 <- data_frame(x=x3, y=y3, Q='III') x4 <- c(0, 1/2, sqrt(2)/2, sqrt(3)/2, 1) y4 <- c(-1, -sqrt(3)/2, -sqrt(2)/2, -1/2, 0) d4 <- data_frame(x=x4, y=y4, Q='IV') dAll <- bind_rows(d1, d2, d3, d4) cart2pol(dAll\$x, dAll\$y) cart2pol(dAll\$x, dAll\$y, degrees=TRUE) ```

useful documentation built on June 10, 2018, 1:04 a.m.