本文介绍了我如何导入和绘制R中的三角形网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想在R中绘制我的模型输出 这是一个三角网格,格式为 x1 y1 z1 x2 y2 z2 x3 y3 z3 value 每行都代表一个三角形,我想用 value 作为比例来绘制这些三角形。 mymesh< - 结构(C(0.91,0.45,13.93,14.26,14.15,14.36,14.36,14.61, 14.58,14.87,14.8,15.13,15.02,15.39,15.24,15.65 ,15.46, 15.9,15.69,16.16,0,0.79,12.45,12.64,12.34,12.46,12.24, 12.38,12.13,12.3,12.03,12.22,11.92,12.13,11.81,12.04, 11.69,11.94,11.57,11.84,0.0,208.71,208.69,210.7,210.68, 212.68,212.66,214.67,214.65,216.66,216.63,218.64,218.61, 220.62,220.59 ,222.61,222.57,224.59,224.56,0.45,1.5,14.15, 14.15,14.36,14.36,14.58,14.58,14.8,14.8,15.02,15.02, 15.24,15.24,15.46,15.46,15.69 ,15.69,15.92,15.92,0 0.79, 0,12.34,12.34,12.24,12.24,12.13,12.13,12.03,12.03,11.92, 11.92,11.81,11.81,11.69,11.69,11.57,11.57,11.45,11.45, 0,131.83,210.7,210.7,212.68,212.68,214.67,214.67,216.66, 216.66,218.64,218.64,220.62,220.62,222.61,222.61,224.59, 224.59,226.58,226.58 ,1.5%,0.75,14.26,14.36,14.36,14.61, 14.61,14.87,14.87,15.13,15.13,15.39,15.39,15.65,15.65, 15.9,15.9,16.16,16.16,16.42,0 ,1.3,12.64,12.46,12.46, 12.38,12.38,12.3,12.3,12.22,12.22,12.13,12.13,12.04, 12.04,11.94,11.94,11.84,11.84,11.74,131.83,131.83 ,208.69, 210.68,210.68,212.66,212.66,214.65,214.65,216.63,216.63, 218.61,218.61,220.59,220.59,222.57,222.57,224.56,224.56, 226.54,375.12 ,399.8,297.84,497.63,368.17,1113.19,979, 781.41,1202.21,1113.94,1293.77,1391.94,1364.52,1151.37, 1690.98,913.63,0,0,0,0)。 Dim = c(20L,10L),.Dimnames = list( NULL,c(x1,y1,z1,x2,y2,z2,x3, y3,z3,value))) 在 rgl , plot3D 和 misc3d 包中。然而,这些似乎是处理点而不是三角形(例如, rgl.points , rgl.linestrips , rgl.triangles 函数都将 x,y,z 作为输入,而不是三角形)。 如何使用R来绘制和着色此数据集中的三角形?解决方案我使用 shade3d 和 tmesh3d 函数从 rgl 。 它创建了两个单独的栏。不同的三角形颜色不同。看看下面的图。 rgl.open()i 顶点< (1),2(1),2(3),4(6) 3) shade3d(tmesh3d(顶点,索引),COL = 1) bg3d(颜色= 白色)为(I在2点20分){顶点< ; c(mymesh [i,1:3],1,mymesh [i,4:6],1,mymesh [i,7:9],1) indices shade3d(tmesh3d(vertices,indices),col = i)} I would like to plot my model output in RIt is a triangular mesh in the format x1 y1 z1 x2 y2 z2 x3 y3 z3 valueWhere each row represents a triangle, and I would like to plot these triangles with value as the scale.mymesh <- structure(c(0.91, 0.45, 13.93, 14.26, 14.15, 14.36, 14.36, 14.61, 14.58, 14.87, 14.8, 15.13, 15.02, 15.39, 15.24, 15.65, 15.46, 15.9, 15.69, 16.16, 0, 0.79, 12.45, 12.64, 12.34, 12.46, 12.24, 12.38, 12.13, 12.3, 12.03, 12.22, 11.92, 12.13, 11.81, 12.04, 11.69, 11.94, 11.57, 11.84, 0, 0, 208.71, 208.69, 210.7, 210.68, 212.68, 212.66, 214.67, 214.65, 216.66, 216.63, 218.64, 218.61, 220.62, 220.59, 222.61, 222.57, 224.59, 224.56, 0.45, 1.5, 14.15, 14.15, 14.36, 14.36, 14.58, 14.58, 14.8, 14.8, 15.02, 15.02, 15.24, 15.24, 15.46, 15.46, 15.69, 15.69, 15.92, 15.92, 0.79, 0, 12.34, 12.34, 12.24, 12.24, 12.13, 12.13, 12.03, 12.03, 11.92, 11.92, 11.81, 11.81, 11.69, 11.69, 11.57, 11.57, 11.45, 11.45, 0, 131.83, 210.7, 210.7, 212.68, 212.68, 214.67, 214.67, 216.66, 216.66, 218.64, 218.64, 220.62, 220.62, 222.61, 222.61, 224.59, 224.59, 226.58, 226.58, 1.5, 0.75, 14.26, 14.36, 14.36, 14.61, 14.61, 14.87, 14.87, 15.13, 15.13, 15.39, 15.39, 15.65, 15.65, 15.9, 15.9, 16.16, 16.16, 16.42, 0, 1.3, 12.64, 12.46, 12.46, 12.38, 12.38, 12.3, 12.3, 12.22, 12.22, 12.13, 12.13, 12.04, 12.04, 11.94, 11.94, 11.84, 11.84, 11.74, 131.83, 131.83, 208.69, 210.68, 210.68, 212.66, 212.66, 214.65, 214.65, 216.63, 216.63, 218.61, 218.61, 220.59, 220.59, 222.57, 222.57, 224.56, 224.56, 226.54, 375.12, 399.8, 297.84, 497.63, 368.17, 1113.19, 979, 781.41, 1202.21, 1113.94, 1293.77, 1391.94, 1364.52, 1151.37, 1690.98, 913.63, 0, 0, 0, 0), .Dim = c(20L, 10L), .Dimnames = list( NULL, c("x1", "y1", "z1", "x2", "y2", "z2", "x3", "y3", "z3", "value")))I have looked at the rgl, plot3D, and misc3d packages. However, these seem to be dealing with points rather than triangles (for example, the rgl.points, rgl.linestrips, and rgl.triangles functions all take x,y,z as inputs, rather than a triangle). How can I use R to plot and color the triangles in this dataset? 解决方案 I generated a plot using the shade3d and tmesh3d functions from rgl.It creates two separate bars. The different triangulars are coloured differently. Look at the plot below.rgl.open()i <- 1vertices <- c(mymesh[i,1:3],1,mymesh[i,4:6],1,mymesh[i,7:9],1)indices <- c( 1, 2, 3)shade3d( tmesh3d(vertices,indices) , col=1)bg3d(color = "white")for(i in 2:20){ vertices <- c(mymesh[i,1:3],1,mymesh[i,4:6],1,mymesh[i,7:9],1) indices <- c( 1, 2, 3) shade3d( tmesh3d(vertices,indices) , col= i) } 这篇关于我如何导入和绘制R中的三角形网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 02:57