geom-center-and-normalize

2.0.0 • Public • Published

geom-center-and-normalize

Center a simplicial complex geometry's positions and scale them to fill 1x1x1 bounding box.

Installation

npm install geom-center-and-normalize

Usage

import centerAndNormalize from "geom-center-and-normalize";

const positions = new Float32Array([
  // p1 [x, y, z]
  1, 1, 1,
  // p2 [x, y, z]
  2, 2, 2,
  // p3 [x, y, z]
  3, 5, 3,
]);
const normalizedPositions = centerAndNormalize(positions);
// => Float32Array(9) [
//   -0.25, -0.5, -0.25,
//   0, -0.25, 0,
//   0.25, 0.5, 0.25,
// ]

API

centerAndNormalize(positions): positions

Parameters

  • positions: TypedArray|Array – simplicial complex geometry positions (eg. new Float32Array([x, y, z, x, y, z, ...]) or new Array([x, y, z], [x, y, z], ...))

Returns

  • positions: TypedArray|Array – The positions parameter array updated, centered at [0, 0, 0] and normalized to a unit bounding box [-0.5, -0.5, -0.5] x [0.5, 0.5, 0.5].

License

MIT. See license file.

Install

npm i geom-center-and-normalize

DownloadsWeekly Downloads

7

Version

2.0.0

License

MIT

Unpacked Size

4.59 kB

Total Files

6

Last publish

Collaborators

  • vorg