Learn R Programming

geometry (version 0.3-2)

cart2bary: Conversion of Cartesian to Barycentric coordinates.

Description

Given the Cartesian coordinates of one or more points, with compute the barycentric coordinates of these points with respect to a simplex.

Usage

cart2bary(T, P)

Arguments

T
Reference simplex in $N$ dimensions represented by a $N+1$-by-$N$ matrix
P
$M$-by-$N$ matrix in which each row is the Cartesian coordinates of a point.

Value

  • $M$-by-$N$ matrix in which each row is the Cartesian coordinates of corresponding row of P

Details

Given a reference simplex in $N$ dimensions represented by a $N+1$-by-$N$ matrix an arbitrary point $\mathbf{P}$ in Cartesian coordinates, represented by a 1-by-$N$ row vector, can be written as $$\mathbf{P} = \mathbf{\beta}\mathbf{T}$$ where $\mathbf{\beta}$ is a $N+1$ vector of the barycentric coordinates. A criterion on $\mathbf{\beta}$ is that $$\sum_i\beta_i = 1$$ Now partition the simplex into its first $N$ rows $\mathbf{T}_N$ and its $N+1$th row $\mathbf{T}_{N+1}$. Partition the barycentric coordinates into the first $N$ columns $\mathbf{\beta}_N$ and the $N+1$th column $\beta_{N+1}$. This allows us to write $$\mathbf{P - T}_{N+1} = \mathbf{\beta}_N\mathbf{T}_N + \mathbf{\beta}_{N+1}\mathbf{T}_{N+1} - \mathbf{T}_{N+1}$$ which can be written $$\mathbf{P - T}_{N+1} = \mathbf{\beta}_N(\mathbf{T}_N - \mathbf{1}\mathbf{T}_{N+1})$$ where $\mathbf{1}$ is a $N$-by-1 matrix of ones. We can then solve for $\mathbf{\beta}_N$: $$\mathbf{\beta}_N = \mathbf{P - T}_{N+1}(\mathbf{T}_N - \mathbf{1}\mathbf{T}_{N+1})^{-1}$$ and compute $$\beta_{N+1} = 1 - \sum_{i=1}^N\beta_i$$ This can be generalised for multiple values of $\mathbf{P}$, one per row.