Skip to content

normalize_vertices

normalize_vertices(V, scale=1000.0)

Normalize vertices into the box [0, scale]^3.

The bounding box is translated to the origin and uniformly scaled so that its longest side has length scale:

VN = (V - offset) * factor

LibMAT works internally in [0, 1000]^3 (scale = 1000). Its functions normalize their inputs and return results in the input coordinates, so you only need this function to compare with data stored in that normalized frame (e.g. .ma files).

Parameters:

Name Type Description Default
V (n,3) numpy double array

Vertex positions.

required
scale float, optional (default 1000.0)

Length of the longest side of the bounding box after normalization.

1000.0

Returns:

Name Type Description
VN (n,3) numpy double array

Normalized vertex positions.

offset (3,) numpy double array

Minimum corner of the bounding box of V.

factor float

Uniform scaling factor.

Notes

C++: void libmat::normalize_vertices(V, scale, VN, offset, factor) in <libmat/normalize_vertices.h>.

Examples:

import libmat
V, T = libmat.read_tet_mesh("data/lblock.tet")
VN, offset, factor = libmat.normalize_vertices(V)
V_back = VN / factor + offset

C++

#include <libmat/normalize_vertices.h>

// Map vertices into the box [0, scale]^3 (uniform scaling, the longest side
// of the bounding box becomes `scale`). LibMAT works internally with
// scale = 1000:
//
//   VN = (V - offset) * factor
//
// Inputs:
//   V      #V by 3 vertex positions
//   scale  length of the longest side after normalization
// Outputs:
//   VN      #V by 3 normalized vertex positions
//   offset  1 by 3 translation (minimum corner of the bounding box of V)
//   factor  uniform scaling factor
void normalize_vertices(const Eigen::MatrixXd& V, double scale,
                        Eigen::MatrixXd& VN, Eigen::RowVector3d& offset,
                        double& factor);