View source: R/align_contour.R
mesh_orient_by_contour_pca | R Documentation |
Re-orients a mesh and a specified contour so that the contour is as well aligned to the xy axes as possible. This is achieved by first applying a PCA on the input contour and then rotating the mesh using the same rotation matrix.
This may be useful if there is a need to orient a flake, for instance, or a specific surface component, such as the ventral part, using only edge landmarks.
mesh_orient_by_contour_pca(coords.o, mesh, npts = 100)
coords.o |
A Nx3 matrix-like object containing ordered xyz coordinates defining a closed contour, one coordinate per row. |
mesh |
An object of class mesh3d to reorient. |
npts |
Number of equidistant points to sample along the given contour. This is so that each contour section is given equal weight in the PCA. The default is 100. |
A list containing the re-oriented mesh (mesh), the re-oriented input contour (contour), the re-oriented re-sampled contour (contour.res), and the PCA-derived rotation matrix (rot.mx) used for the reorientation.
KNOWN ISSUES
The re-sampled contour points in the output are not guaranteed to be on the mesh surface. In fact, they most likely won't be; if you want to ensure that they are, create a surface path first (see the sPathConnect function), and re-sample that.
Cornel M. Pop
sPathConnect, orient_by_vectors
## Not run:
library(rgl)
data(demoFlake2)
m.rec <- mesh_recenter(demoFlake2$mesh, demoFlake2$lms)
m.rot <- mesh_orient_by_contour_pca(m.rec$coords, m.rec$mesh, npts=100)
view3d(theta=0, phi=0)
shade3d(m.rot$mesh, color="green")
points3d(m.rot$contour, color="red", size=5)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.