pol2cart: Polar to Cartesian Coordinates

Description Usage Arguments Value Examples

Description

Polar to Cartesian Coordinates

Usage

1
2
pol2cart(phi, radius = 1L, measure = c("rad", "deg", "turn"),
  start = c("E", "N", "W", "S"), direction = c("ACW", "CW"))

Arguments

phi

[numeric]

radius

[numeric]

measure

[character(1)]
Measure of "phi" (degrees, radians, or turns)

start

[character(1)]
Start position, default is east ("E").

direction

[character(1)]
Anti-clockwise (default) or clockwise.

Value

[matrix]
Cartesian coordinates.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
all.equal(pol2cart(pi / 2), pol2cart(90, measure = "d"))
all.equal(pol2cart(pi / 2), pol2cart(1/4, measure = "t"))

oldpar <- par(pty = "s")
plot(pol2cart(1:360, measure = "d"), col = rainbow(360),
     xlim = c(-1, 1), ylim = c(-1, 1))
par(oldpar)

oldpar <- par(pty = "s")
plot(pol2cart(seq(0, 2, len = 500), seq(0, 1, len = 500), measure = "t"),
     col = rev(grey.colors(500)), pch = 16, xlim = c(-1, 1), ylim = c(-1, 1))
par(oldpar)

oldpar <- par(pty = "s")
plot(NA, xlim = c(-3, 3), ylim = c(-3, 3), xlab = "x", ylab = "y")
for (i in 1:360)
  points(matrix(rnorm(2, as.numeric(pol2cart(i, 2, m = "d")), 0.2), 1))
par(oldpar)

oldpar <- par(pty = "s")
plot(NA, xlim = c(-3, 3), ylim = c(-3, 3), xlab = "x", ylab = "y")
points(rnhyper(100, pol2cart(45, 2, m = "d"), sd = 0.5), col = 2)
points(rnhyper(100, pol2cart(45 + 225, 2, m = "d"), sd = 1), col = 3)
points(rnhyper(100, pol2cart(45 + 90, 2, m = "d"), sd = 0.5), col = 4)
points(pol2cart(45 + c(0, 90, 225), 2, m = "d"), pch = 4, lwd = 3)
lines(pol2cart(seq(0, 1, len = 400), 2, m = "t"))
par(oldpar)

aschersleben/NBCD documentation built on May 12, 2019, 4:32 a.m.