pts <- matrix(c(
-33.0534, -10.6213, -21.8328,
-34.7526, -25.5089, -14.5390,
-41.2002, -10.4606, -22.0032,
-46.4717, -10.3567, -22.1134,
-51.7431, -10.2528, -22.2237,
-57.0146, -10.1488, -22.3339,
-62.2860, -10.0449, -22.4442,
-67.5575, -9.9410, -22.5544
), ncol = 3, byrow = TRUE)
curve <- catmull_rom_3d(pts)
print(curve)
# Sample 100 evenly spaced points along the curve
smooth <- curve$get_points(100)
head(smooth)
# Evaluate the curve at t = 0.5 (midpoint)
curve$get_point(0.5)
# get closest point on curve
curve$get_closest_t(c(-49, -10, -22))
plot(curve, use_rgl = FALSE)
Run the code above in your browser using DataLab