2016-09-18 90 views
1

我有三个参考矢量中的R笛卡尔转换坐标重心那些

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

并且将具有测量值,例如

x(0, 0.5, 0.3) 

,我想在一个二维图形绘制如三角形,谁边将对应于a,b和c。

在Matlab中有一个简单明了的功能做

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

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

回答

4

当然,你可以在笛卡儿和重心之间来回走动。

巴里购物车:

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) 

enter image description here

车到巴里:

## 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) 
相关问题