【问题标题】:How to set maximum length of triangle side in Delaunay triangulation?如何在 Delaunay 三角剖分中设置三角形边的最大长度?
【发布时间】:2013-07-14 09:08:13
【问题描述】:

如何从 Delaunay 三角剖分中删除大于我需要的距离?

示例数据:

x<-rep(1:12, c(2,2,7,9,10,5,4,6,10,10,9,4))
y<-c(1,2,1,2,1:3,5:8,1:9,1:10,2,7:10,8:11,7:12,3:12,3:12,4:12,5,8:10)
x_plus<-seq(0.2:0.8, by=0.1)
x<-x+sample(x_plus, 78, replace=TRUE)
y<-y+sample(x_plus, 78, replace=TRUE)

绘制地图:

plot(x,y)

Delaunay 三角剖分 with tri.mesh() - package(tripack)

my.triangles<-tri.mesh(x,y)
plot(my.triangles, do.points=FALSE, lwd=0.2)
points(x,y, col = "blue", pch=20)

我怎样才能只提取较短的距离?我不需要那些大的,你肯定知道我的意思是什么距离。 在 tri.mesh() 函数中是否有一些论点可以做到这一点? 或者可以在它之后完成?

距离是否存储在这个对象中?

my.triangles

triangulation nodes with neigbours:
node: (x,y): neighbours
1: (1.4,1.7) [5]: 2 3 4 11 12 
2: (2,3) [6]: 1 4 7 8 9 11 
3: (3,1.8) [4]: 1 4 5 12 
.
.
.
76: (12.4,8.8) [5]: 68 69 70 75 77 
77: (12.9,9.9) [6]: 70 71 72 75 76 78 
78: (13,11) [4]: 72 73 74 77 
number of nodes: 78 
number of arcs: 221 
number of boundary nodes: 10 
boundary nodes:  1 11 12 45 56 66 74 75 77 78 
number of triangles: 144 
number of constraints: 0 

【问题讨论】:

  • 您能否让您的示例可重现?包裹 tripolt 似乎无法从 CRAN 获得。
  • 对不起,是包:trippack
  • 删除三角形/边的具体标准是什么?

标签: r extract delaunay


【解决方案1】:

文档 (?tri) 建议分段的格式为 r$tlist[k] -- r$tlist[r$tlptr[k]]:您可以删除超出某个阈值的分段。

r <- tri.mesh(x,y)
k <- seq_len( r$tlnew - 1 )
i <- r$tlist[k]          
j <- r$tlist[r$tlptr[k]]
keep <- i > 0
i <- abs( i[ keep ] )
j <- abs( j[ keep ] )
plot( x, y )
segments( r$x[i], r$y[i], r$x[j], r$y[j], col="grey" )
distances <- sqrt( ( r$x[i] - r$x[j] ) ^ 2 + ( r$y[i] - r$y[j] ) ^ 2 )
threshold <- 2.5  # Choose the threshold manually
i <- i[ distances < threshold ]
j <- j[ distances < threshold ]
segments( r$x[i], r$y[i], r$x[j], r$y[j], lwd = 2 )

【讨论】:

    猜你喜欢
    • 2016-02-08
    • 2014-01-21
    • 1970-01-01
    • 2015-01-07
    • 2011-07-15
    • 1970-01-01
    • 2012-03-04
    • 2010-12-23
    • 2019-04-18
    相关资源
    最近更新 更多