polarToCart: Convert Polar Coordinates to Cartesian

View source: R/arithmetic.R

polarToCartR Documentation

Convert Polar Coordinates to Cartesian

Description

polarToCart calculates x and y coordinates of vector field from their polar representation (magnitude and angle).

Usage

polarToCart(magnitude, angle, x = "new", y = "new", degree = FALSE)

Arguments

magnitude

A 32- or 64-bit (32F or 64F) Image object corresponding to the magnitudes of the vector field.

angle

A 32- or 64-bit (32F or 64F) Image object corresponding to the angles of the vector field.

x

The location where the x coordinates should be stored. It can take 2 values:

  • "new":a new Image object is created and the results are stored inside (the default).

  • An Image object:the results are stored in another existing Image object. Note that an error will be thrown if x does not have the same dimensions, number of channels, and bit depth as magnitude and angle.

y

The location where the y coordinates should be stored. It can take 2 values:

  • "new":a new Image object is created and the results are stored inside (the default).

  • An Image object:the results are stored in another existing Image object. Note that an error will be thrown if y does not have the same dimensions, number of channels, and bit depth as magnitude and angle.

degree

A logical indicating whether the angles are measured in radians (the default) or degrees.

Value

If x="new" and y="new", the function returns a list containing two Image objects. If x and y are Image objects, the function returns nothing and modifies these Image objects in place.

Author(s)

Simon Garnier, garnier@njit.edu

See Also

polarToCart, spatialGradient

Examples

balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
field <- spatialGradient(balloon)
lapply(field, changeBitDepth, bitdepth = "32F", target = "self")
field_converted <- cartToPolar(field$dx, field$dy)
field_deconverted <- polarToCart(field_converted$magnitude, field_converted$angle)


swarm-lab/Rvision documentation built on Feb. 7, 2024, 4:59 a.m.