【问题标题】:Converting in R cartesian coordinates to barycentric ones将 R 笛卡尔坐标转换为重心坐标
【发布时间】:2016-09-18 09:34:09
【问题描述】:

我有三个参考向量

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 中的等价物吗?或者我应该实现数学吗?

【问题讨论】:

    标签: r math coordinates cartesian-coordinates


    【解决方案1】:

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

    Bary 到购物车:

    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)
    

    购物车到巴里:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-23
      • 2017-10-10
      相关资源
      最近更新 更多