# Construct target surface
sphere <- vcg_sphere()
target <- structure(
class = "mesh3d",
list(
vb = cbind(
sphere$vb[1:3, ] - c(0.8, 0, 0),
sphere$vb[1:3, ] + c(0.8, 0, 0)
),
it = cbind(
sphere$it[1:3, ],
sphere$it[1:3, ] + ncol(sphere$vb)
)
)
)
n_surfverts <- ncol(target$vb)
plane <- plane_geometry(width = 3, height = 3, shape = c(30, 30))
plane$vb <- plane$vb[1:3, , drop = FALSE] + c(0, 0, 2)
n_contacts <- ncol(plane$vb)
# First plot
x <- t(cbind(target$vb, plane$vb))
colnames(x) <- c('x', 'y', 'z')
graphics::pairs(
x = x, asp = 1,
col = c(
rep("black", n_surfverts),
rep("green", n_contacts)
),
pch = c(
rep(46, n_surfverts),
rep(20, n_contacts)
)
)
projected <- project_plane(
target = target, width = 3, height = 3, shape = c(30, 30),
initial_positions = t(plane$vb),
translate_first = TRUE, diagnostic = FALSE
)
y <- rbind(x, projected)
graphics::pairs(
x = y, asp = 1,
col = c(
rep("black", ncol(target$vb)),
rep("green", n_contacts),
rep("red", n_contacts)
),
pch = c(
rep(46, n_surfverts),
rep(1, n_contacts),
rep(20, n_contacts)
)
)
Run the code above in your browser using DataLab