convertCoordinates: Converts coordinates between cartesian and polar

Description Usage Arguments Value Examples

View source: R/convertCoordinates.R

Description

Converts a given matrix with two rows from polar to cartesian coordinates and vice versa.

Usage

1
convertCoordinates(coords, convertto = "cartesian")

Arguments

coords

[matrix]
Matrix with two columns. Each row contains the pair (x, y) in cartesian coordinates or (radius, angle) in polar coordinates. The angle is given in radian [0, 2*pi]

convertto

[character]
Defines the target coordinate system for conversion. Options are "cartesian" and "polar". Default: "cartesian"

Value

a matrix with converted coordinates

Examples

1
2
3
4
if (interactive()) {
  coordsK <- rbind(c(3, 0), c(1, 3), c(0, 2), c(-3, 1), c(-1, 0), c(-1, -3), c(0, -2), c(2, -3))
  coordsP <- convertCoordinates(coordsK, "polar")
}

surmann/ODEnetwork documentation built on April 6, 2020, 8:53 p.m.