convertCoordinates {ODEnetwork}R Documentation

Converts coordinates between cartesian and polar

Description

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

Usage

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

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")
}

[Package ODEnetwork version 1.3.2 Index]