将 R 笛卡尔坐标转换为重心坐标

Converting in R cartesian coordinates to barycentric ones

我有三个参考向量

a ( 0, 0, 1 )
b ( 0, 1, 0 )
c ( 1, 0, 0 )

并且会有

这样的测量值
x( 0, 0.5, 0.3 )

我想在 2D 图形中将其绘制为三角形,其边对应于 a、b 和 c。

在 Matlab 中有一个简单的函数可以做到这一点

http://fr.mathworks.com/help/matlab/ref/triangulation.cartesiantobarycentric.html?s_tid=gn_loc_drop

有没有人知道 R 中的等价物或者我应该实施数学?

当然,您可以在笛卡尔坐标系和重心坐标系之间来回切换。

购物车:

library(geometry)

## Define simplex in 2D (i.e. a triangle)
X <- rbind(
            c( 0, 0, 1 ),
            c( 0, 1, 0 ),
            c( 1, 0, 0 ))

## Cartesian cooridinates of points
beta <- rbind(c( 0, 0.5, 0.3 ),
              c(0.1, 0.8, 0.1),
              c(0.1, 0.8, 0.1))

## Plot triangle and points
trimesh(rbind(1:3), X)
text(X[,1], X[,2], 1:3) # Label vertices
P <- bary2cart(X, beta)

Bary 的购物车:

## Define simplex in 2D (i.e. a triangle)
X <- rbind(c(0, 0),
           c(0, 1),
           c(1, 0))
## Cartesian cooridinates of points
P <- rbind(c(0.5, 0.5),
           c(0.1, 0.8))
## Plot triangle and points
trimesh(rbind(1:3), X)
text(X[,1], X[,2], 1:3) # Label vertices
points(P)
cart2bary(X, P)