mesh_recenter: Recenter mesh coordinates

View source: R/mesh_recenter.R

mesh_recenterR Documentation

Recenter mesh coordinates

Description

Transforms a mesh so that its center is at the origin (0, 0, 0); it does so by subtracting the average x, y, and z coordinates from all vertices. The same transformation can be applied to the optional set of coordinates to preserve spatial relationships between the mesh and these coordinates.

Usage

mesh_recenter(mesh, coords = NA)

Arguments

mesh

An object of class mesh3d representing the 3D mesh.

coords

(Optional) An Nx3 matrix-like object containing xyz coordinates, one coordinate per row. Default is NA.

Value

A list containing the translated mesh (mesh) and coordinates (coords)

TODO

Add tests

Author(s)

Cornel M. Pop

Examples

## Not run: 
library(rgl)
data(demoFlake2)
res <- mesh_recenter(demoFlake2$mesh, demoFlake2$lms)
view3d(theta=0, phi=0)
shade3d(res$mesh, color="green")
points3d(res$coords, color="red", size=5)

## End(Not run)


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