Convert between Cartesian and polar coordinates

pth_to_cartesian(mat_polar, chroma_min = 1e-04)

pth_to_polar(mat_cartesian)

Arguments

mat_polar

matrix with columns for luminance, chroma, hue.

chroma_min

numeric "trick" used to preserve the hue at zero chroma, using a value small enough not to affect color-perception.

mat_cartesian

matrix with columns for luminance, blue-yellow, green-red.

Value

matrix with same dimension as the input matrix.

Examples

  polar <- matrix(c(50, 0, 45), ncol = 3)
  cart <- pth_to_cartesian(polar)
  polar_new <- pth_to_polar(cart)
  # notice the chroma value has an artificial floor
  # using an imperceptible (color) difference
  print(polar)
#>      [,1] [,2] [,3]
#> [1,]   50    0   45
  print(cart)
#>      [,1]         [,2]         [,3]
#> [1,]   50 7.071068e-05 7.071068e-05
  print(polar_new)
#>      [,1]  [,2] [,3]
#> [1,]   50 1e-04   45