簡體   English   中英

將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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM