JSPM

triangle-normal

0.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 235
  • Score
    100M100P100Q89790F
  • License MIT

Get the normal vector of a 3D triangle

Package Exports

  • triangle-normal

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (triangle-normal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

triangle-normal experimental

Takes a list of vertices in a triangle, and returns the normal vector for that triangle. Doesn't handle degenerate triangles.

Installation

triangle-normal

Usage

require('triangle-normal')(vertices..., [output])

The first 9 arguments are for the points on your triangle, with an optional output array to set the resulting parameters. If an ouput is not supplied, a new array will be created, and either way this array will be returned as the result of the function, e.g.:

var normal = require('triangle-normal')
var output = [0, 0, 0]

var vectors = [
    { x: 0, y: 0, z: 0 }
  , { x: 1, y: 0, z: 0 }
  , { x: 0, y: 1, z: 0 }
]

normal(
  vectors[0].x, vectors[0].y, vectors[0].z,
  vectors[1].x, vectors[1].y, vectors[1].z,
  vectors[2].x, vectors[2].y, vectors[2].z,
  output
)