mesh_orient_by_contour_pca: Orient a mesh using a contour

View source: R/align_contour.R

mesh_orient_by_contour_pcaR Documentation

Orient a mesh using a contour

Description

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.

Usage

mesh_orient_by_contour_pca(coords.o, mesh, npts = 100)

Arguments

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.

Value

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.

Note

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.

Author(s)

Cornel M. Pop

See Also

sPathConnect, orient_by_vectors

Examples

## 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)

cornelmpop/Lithics3D documentation built on Feb. 10, 2024, 11:54 p.m.