Skip to content

datatypesjs/face

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face

Class for 2-faces to use as facets of polyhedrons. Also called a "polygonal face".

Installation

npm install --save @datatypes/face

Usage

import Point from '@datatypes/point'
import Face from '@datatypes/face'

const vertices = [
	new Point(1, 0, 0),
	new Point(0, 1, 0),
	new Point(0, 0, 1)
]

const face = new Face(vertices)
	.calculateNormal()
	.calculateSurfaceArea()

console.log(face.toObject())

Output:

{
	vertices: [
		{x: 1, y: 0, z: 0},
		{x: 0, y: 1, z: 0},
		{x: 0, y: 0, z: 1}
	],
	normal: {
		x: 0.5773502691896258,
		y: 0.5773502691896258,
		z: 0.5773502691896258
	},
	surfaceArea: 0.8660254037844386
}

For a more detailed listing of available features check out the tests.

About

Class for 2-faces to use as facets of polyhedrons and polygon meshes.

Resources

Stars

Watchers

Forks

Packages

No packages published