Learn R Programming

trifield (version 1.0)

xy2abc: Ternary projection of x, y coordinates

Description

Projects x, y coordinates on the unit square to a, b, c ternary ordinates

Usage

xy2abc(xy)

Arguments

xy
A matrix of coordinates, one per row, on the unit square

Value

  • A matrix of a, b, c triples

See Also

abc2xy

Examples

Run this code
## The function is currently defined as
function(xy)
{
	tmat = c(sqrt(3) / 2, -0.5, 0, 1)
	dim(tmat) = rep(2, 2)
	res = as.matrix(xy) %*% tmat
	res = cbind(res[,2], 1 - rowSums(res), res[,1])
	colnames(res) = c("a", "b", "c")
	res
  }

Run the code above in your browser using DataLab