0

我正在尝试计算表示 R 中动物足迹的 3D 网格的对称平面。

我已经运行了下面的脚本,但不幸的是它在我的情况下不起作用。没有错误消息,但它只是没有在 rgl 窗口中绘制平面:

library(Rvcg)
library(rgl)

path_ply <- "/Volumes/eTrack/eTrack - Segmented 3D models"

filelist_ply1 <- list.files(path_ply, pattern = ".ply",full.names = TRUE)

i=1

filelist_ply1[i]

#Read 3D mesh (.ply)
Specimen <- vcgPlyRead(filelist_ply1[i], updateNormals = TRUE, 
clean = TRUE)

#Remove unwanted components
Specimen <- vcgIsolated(
Specimen,
facenum = NULL,
diameter = NULL,
split = FALSE,
keep = 1,
silent = FALSE)

X <- t(Specimen$vb[1:3,])

#Demeaning the variables
mean_vec <- colMeans(X)

X_demeaned <- matrix(NA, ncol = 3, nrow = length(X[,1]))
X_demeaned[, 1] <- X[, 1]-mean_vec[1]
X_demeaned[, 2] <- X[, 2]-mean_vec[2]
X_demeaned[, 3] <- X[, 3]-mean_vec[3]

cov.X=cov(X_demeaned)
eigen_vectors <- eigen((cov.X))$vectors
eigen_values  <- eigen((cov.X))$values
eigen_vectors
eigen_values

a <- eigen_vectors[1, 3]
b <- eigen_vectors[2, 3]
c <- eigen_vectors[3, 3]
d <- a * mean_vec[1] + b * mean_vec[2] + c * mean_vec[3]

open3d()
plot3d(X[, 1], X[, 2], X[, 3], type = "p", col = "red", size = 1)
rgl.planes(a, b, c, d, alpha=0.2, color = "#D95F02")
4

0 回答 0