Learn R Programming

beadarrayMSV (version 1.0.3)

cart2pol: Transformation from Cartesian to polar coordinates

Description

Cartesian coordiantes are transformed to polar coordinates using a specified distance measure

Usage

cart2pol(x, y, dist = "euclidean", pNorm = NULL)

Arguments

x
Cartesian abscissa value
y
Cartesian ordinate value
dist
One of manhattan, euclidean (default), or minkowski, defining which distance measure to use
pNorm
The exponent p in the p-norm (Minkowski) distance

Value

  • A list holding the polar coordinates
  • rSignal intensity
  • thPolar angle

Details

The Manhattan distance is the special case of the Minkowski distance of norm 1, the Euclidean distance equals the Minkowski distance of norm 2. The unit circle of the Minkowski distance changes from a diamond shape (1-norm), through an Euclidean circle (2-norm), to a square (infinity-norm) as pNorm increases from 1 to infinity. Any norm between 2 and infinity results in a unit circle resembling a square with more or less rounded corners.

For non-transformed signal, the 1-norm is the most accurate representation, however a higher norm is called for after root- or log-transformations.

See Also

preprocessBeadSet, setNormOptions

Examples

Run this code
## Points defining a 4-norm unit-circle in the first quadrant
x <- seq(0,1,.01)^(1/4)
y <- (1-x^4)^(1/4)

## Polar coordinates using different distance-measures
eucl <- cart2pol(x,y)
mink <- cart2pol(x,y,'minkowski',4)

## Plot in cartesian coordinates
dev.new()
plot(x,y,type='b',main='4-norm unit circle')

## Plot polar coordinates on cartesian axes
dev.new()
plot(eucl$th,eucl$r,type='b',col='red',xlab='theta',ylab='r')
points(mink$th,mink$r,type='b',col='blue')
title(main='Euclidean (red) and 4-norm (blue) distance')

Run the code above in your browser using DataLab