The documentation (?tri
) suggests that the segments are of the form r$tlist[k] -- r$tlist[r$tlptr[k]]
: you can remove those beyond some threshold.
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 )