- 自从我发布这个以来,我一直在努力,终于可以开发代码了
- 任何人都可以使用它。
-这是横截面轮廓
Y=c(-30,-2,0,8,20,31)
Z=c(30,10,2,9,30,39)
-在横截面内创建点网格
- 选择 y 和 z 网格间距
ygrid= 50 #cm
zgrid= 20 #cm
Ym = seq(min(Y),max(Y),ygrid/100#y 沿截面的网格坐标
创建插值函数
f_z=approxfun(Y,Z)
Zm = f_z(Ym) #interpolated z coordinates of the section perimeter
plot(Ym, Zm,type="b")
我们观察到的海浪的深度。速度或Q放电
Depth_study = 6.05
创建从剖面床到研究深度的不同深度
Depthm = seq(Z_bed,Depth_study,zgrid/100) # different water depths w/r to 0,0 point
现在对于不同的深度,取出 Zm 的索引
list_points_mesh<-vector(("list"),length =length(Depthm))
Y_mesh<-vector(("list"),length =length(Depthm))
Z_mesh<-vector(("list"),length =length(Depthm))
for (j in 1:length(Depthm)) {
list_points_mesh[[j]] = which(Zm<=Depthm[j]) #gives indice of all the points which are below Depthm elevation
Y_mesh[[j]] = Ym[list_points_mesh[[j]]] #now we create pair of points using the indices
Z_mesh[[j]]= rep(Depthm[j],length(list_points_mesh[[j]]))
}
由于答案以列表的形式出现,我们通过 unlist func 将它们取出。
ym=unlist(Y_mesh) #y coord of the grid points
zm=unlist(Z_mesh) #z // // // //
mesh_coord <- data.frame(ym,zm) #list of points inside the section
points(ym,zm,pch=".")