Description Usage Arguments Details Value Note Author(s) See Also Examples
Given the Cartesian coordinates of one or more points, compute the barycentric coordinates of these points with respect to a simplex.
1 | cart2bary(X, P)
|
X |
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. |
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{β}\mathbf{X}
where \mathbf{β} is a N+1 vector of the barycentric coordinates. A criterion on \mathbf{β} is that
∑_iβ_i = 1
Now partition the simplex into its first N rows \mathbf{X}_N and its N+1th row \mathbf{X}_{N+1}. Partition the barycentric coordinates into the first N columns \mathbf{β}_N and the N+1th column β_{N+1}. This allows us to write
\mathbf{P - X}_{N+1} = \mathbf{β}_N\mathbf{X}_N + \mathbf{β}_{N+1}\mathbf{X}_{N+1} - \mathbf{X}_{N+1}
which can be written
\mathbf{P - X}_{N+1} = \mathbf{β}_N(\mathbf{X}_N - \mathbf{1}\mathbf{X}_{N+1})
where \mathbf{1} is a N-by-1 matrix of ones. We can then solve for \mathbf{β}_N:
\mathbf{β}_N = (\mathbf{P - X}_{N+1})(\mathbf{X}_N - \mathbf{1}\mathbf{X}_{N+1})^{-1}
and compute
β_{N+1} = 1 - ∑_{i=1}^Nβ_i
This can be generalised for multiple values of \mathbf{P}, one per row.
M-by-N+1 matrix in which each row is the
barycentric coordinates of corresponding row of P
. If the
simplex is degenerate a warning is issued and the function returns
NULL
.
Based on the Octave function by David Bateman.
David Sterratt
bary2cart
1 2 3 4 5 6 7 8 9 10 11 12 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.