# guf.js **Repository Path**: bit2atom/guf.js ## Basic Information - **Project Name**: guf.js - **Description**: Geometry Utility Functions - **Primary Language**: JavaScript - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-29 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Geometry Utility Functions in Javascript ## Synopsis guf.js is a small collection of functions that calculate geometric properties of a mesh. The key feature it currently provides is normal calculation (face & vertex normals). ## Code Example ```js var guf = require('guf'); var positions = [[x,y,z], [x,y,z], [x,y,z], [x,y,z], ... ]; var cells = [[i0,i1,i2], [i0,i1,i2], [i0,i1,i2], ... ]; // Vertex Normals (Left Image) var vertexNormals = guf.vertexNormals( positions, cells ) ); // Face Normals (Right Image) var facePositions = []; var faceNormals = []; for( var i = 0; i < cells.length; i++ ) { var a = positions[ cells[ i ][ 0 ] ]; var b = positions[ cells[ i ][ 1 ] ]; var c = positions[ cells[ i ][ 2 ] ]; var n = guf.calculateNormal( a, b, c ); facePositions.push( a, b, c ); faceNormals.push( n, n, n ); } ```