Using plotly
and R
I want to check that an ellipsoid is a good fit to the data points.
library(plotrix)
library(plotly)
library(Rvcg)
Library(rgl)
df_r_n_r = read.csv('temp.csv', header = TRUE)
fig <- plot_ly(df_r_n_r,type = "scatter3d", mode="markers", x = ~x, y = ~y, z = ~z)
fig
D <- rbind(c(459.956, -34.198, -29.844), c(-34.198, 481.647, 1.505), c(-29.844, 1.505, 559.393))
A <- D %*% t(D)
Am <- solve(A)
o <- c(73.658, 420.551, -429.058)
r <- 1
sphr <- vcgSphere()
ell <- scale3d(transform3d(sphr, chol(Am)), r, r, r)
vs <- ell$vb[1:3,] + o
idx <- ell$it - 1
e_plot <- plot_ly(type="mesh3d",
x = vs[1,], y = vs[2,], z = vs[3,],
i = idx[1,], j = idx[2,], k = idx[3,],
opacity = 0.3)
I can plot the points using fig
and the ellipsoid using e_plot
, but how do I put them on the same plot so I can see how closely they fit.