gl-matrix's vec3, split into smaller pieces
JavaScript
Clone or download
Latest commit 219dbe7 Apr 21, 2018
Permalink
Failed to load latest commit information.
test Fix vector length in exactEquals tests Feb 8, 2018
.gitignore first commit Nov 15, 2014
.npmignore first commit Nov 15, 2014
LICENSE.md first commit Nov 15, 2014
README.md Fix readme anchor links Mar 30, 2018
add.js first commit Nov 15, 2014
angle.js first commit Nov 15, 2014
ceil.js Add floor, ceil, round functions Feb 6, 2018
clone.js first commit Nov 15, 2014
copy.js first commit Nov 15, 2014
create.js first commit Nov 15, 2014
cross.js first commit Nov 15, 2014
dist.js Add dist, div, len, mul, sqrDist, sqrLen, sub aliases Feb 6, 2018
distance.js first commit Nov 15, 2014
div.js Add dist, div, len, mul, sqrDist, sqrLen, sub aliases Feb 6, 2018
divide.js first commit Nov 15, 2014
dot.js first commit Nov 15, 2014
epsilon.js Add equals and exactEquals Feb 6, 2018
equals.js Fix incorrect jsdoc types Feb 8, 2018
exactEquals.js Fix incorrect jsdoc types Feb 8, 2018
floor.js Add floor, ceil, round functions Feb 6, 2018
forEach.js first commit Nov 15, 2014
fromValues.js first commit Nov 15, 2014
index.js Add floor, ceil, round functions Feb 6, 2018
inverse.js first commit Nov 15, 2014
len.js Add dist, div, len, mul, sqrDist, sqrLen, sub aliases Feb 6, 2018
length.js first commit Nov 15, 2014
lerp.js first commit Nov 15, 2014
max.js first commit Nov 15, 2014
min.js first commit Nov 15, 2014
mul.js Add dist, div, len, mul, sqrDist, sqrLen, sub aliases Feb 6, 2018
multiply.js first commit Nov 15, 2014
negate.js first commit Nov 15, 2014
normalize.js first commit Nov 15, 2014
package.json v1.1.3 Apr 21, 2018
random.js first commit Nov 15, 2014
rotateX.js Fix sin/cos in rotateX Apr 21, 2018
rotateY.js Remove temporary array allocation from rotation functions Apr 17, 2018
rotateZ.js Remove temporary array allocation from rotation functions Apr 17, 2018
round.js Add floor, ceil, round functions Feb 6, 2018
scale.js first commit Nov 15, 2014
scaleAndAdd.js first commit Nov 15, 2014
set.js first commit Nov 15, 2014
sqrDist.js Add dist, div, len, mul, sqrDist, sqrLen, sub aliases Feb 6, 2018
sqrLen.js Add dist, div, len, mul, sqrDist, sqrLen, sub aliases Feb 6, 2018
squaredDistance.js first commit Nov 15, 2014
squaredLength.js first commit Nov 15, 2014
sub.js Add dist, div, len, mul, sqrDist, sqrLen, sub aliases Feb 6, 2018
subtract.js first commit Nov 15, 2014
transformMat3.js first commit Nov 15, 2014
transformMat4.js first commit Nov 15, 2014
transformQuat.js first commit Nov 15, 2014

README.md

gl-vec3

stable

Part of a fork of @toji's gl-matrix split into smaller pieces: this package contains glMatrix.vec3.

Usage

NPM

vec3 = require('gl-vec3')

Will load all of the module's functionality and expose it on a single object. Note that any of the methods may also be required directly from their files.

For example, the following are equivalent:

var scale = require('gl-vec3').scale
var scale = require('gl-vec3/scale')

API

add(out:vec3, a:vec3, b:vec3)

Adds two vec3's

angle(a:vec3, b:vec3)

Get the angle between two 3D vectors

ceil(out:vec3, a:vec3)

Math.ceil the components of a vec3

clone(a:vec3)

Creates a new vec3 initialized with values from an existing vector

copy(out:vec3, a:vec3)

Copy the values from one vec3 to another

create()

Creates a new, empty vec3

cross(out:vec3, a:vec3, b:vec3)

Computes the cross product of two vec3's

distance(a:vec3, b:vec3)

Calculates the euclidian distance between two vec3's. Aliased as dist

divide(out:vec3, a:vec3, b:vec3)

Divides two vec3's. Aliased as div

dot(a:vec3, b:vec3)

Calculates the dot product of two vec3's

equals(a:vec3, b:vec3)

Returns whether or not the vectors have approximately the same elements in the same position.

exactEquals(a:vec3, b:vec3)

Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)

floor(out:vec3, a:vec3)

Math.floor the components of a vec3

forEach(a:Array, stride:Number, offset:Number, count:Number, fn:Function, [arg]:Object)

Perform some operation over an array of vec3s.

fromValues(x:Number, y:Number, z:Number)

Creates a new vec3 initialized with the given values

inverse(out:vec3, a:vec3)

Returns the inverse of the components of a vec3

length(a:vec3)

Calculates the length of a vec3. Aliased as len

lerp(out:vec3, a:vec3, b:vec3, t:Number)

Performs a linear interpolation between two vec3's

max(out:vec3, a:vec3, b:vec3)

Returns the maximum of two vec3's

min(out:vec3, a:vec3, b:vec3)

Returns the minimum of two vec3's

multiply(out:vec3, a:vec3, b:vec3)

Multiplies two vec3's. Aliased as mul

negate(out:vec3, a:vec3)

Negates the components of a vec3

normalize(out:vec3, a:vec3)

Normalize a vec3

random(out:vec3, [scale]:Number)

Generates a random vector with the given scale

rotateX(out:vec3, a:vec3, b:vec3, c:Number)

Rotate a 3D vector around the x-axis

rotateY(out:vec3, a:vec3, b:vec3, c:Number)

Rotate a 3D vector around the y-axis

rotateZ(out:vec3, a:vec3, b:vec3, c:Number)

Rotate a 3D vector around the z-axis

round(out:vec3, a:vec3)

Math.round the components of a vec3

scale(out:vec3, a:vec3, b:Number)

Scales a vec3 by a scalar number

scaleAndAdd(out:vec3, a:vec3, b:vec3, scale:Number)

Adds two vec3's after scaling the second operand by a scalar value

set(out:vec3, x:Number, y:Number, z:Number)

Set the components of a vec3 to the given values

squaredDistance(a:vec3, b:vec3)

Calculates the squared euclidian distance between two vec3's. Aliased as sqrDist

squaredLength(a:vec3)

Calculates the squared length of a vec3. Aliased as sqrLen

subtract(out:vec3, a:vec3, b:vec3)

Subtracts vector b from vector a. Aliased as sub

transformMat3(out:vec3, a:vec3, m:mat3)

Transforms the vec3 with a mat3.

transformMat4(out:vec3, a:vec3, m:mat4)

Transforms the vec3 with a mat4. 4th vector component is implicitly '1'

transformQuat(out:vec3, a:vec3, q:quat)

Transforms the vec3 with a quat

License

zlib. See LICENSE.md for details.