Coder Social home page Coder Social logo

gl-quat's Introduction

gl-quat

stable

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

Usage

NPM

quat = require('gl-quat')

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 slerp = require('gl-quat').slerp
var slerp = require('gl-quat/slerp')

API

calculateW(out:quat, a:quat)

Calculates the W component of a quat from the X, Y, and Z components. Assumes that quaternion is 1 unit in length. Any existing W component will be ignored.

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

Adds two quat's

conjugate(out:quat, a:quat)

Calculates the conjugate of a quat If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.

copy(out:quat, a:quat)

Copy the values from one quat to another

create()

Creates a new identity quat

dot(a:quat, b:quat)

Calculates the dot product of two quat's

fromMat3(out:quat, m:mat3)

Creates a quaternion from the given 3x3 rotation matrix.

NOTE: The resultant quaternion is not normalized, so you should be sure to renormalize the quaternion yourself where necessary.

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

identity(out:quat)

Set a quat to the identity quaternion

invert(out:quat, a:quat)

Calculates the inverse of a quat

length(a:quat)

Calculates the length of a quat

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

Performs a linear interpolation between two quat's

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

Multiplies two quat's

normalize(out:quat, a:quat)

Normalize a quat

rotateX(out:quat, a:quat, rad:number)

Rotates a quaternion by the given angle about the X axis

rotateY(out:quat, a:quat, rad:number)

Rotates a quaternion by the given angle about the Y axis

rotateZ(out:quat, a:quat, rad:number)

Rotates a quaternion by the given angle about the Z axis

rotationTo(out:quat, a:vec3, b:vec3)

Sets a quaternion to represent the shortest rotation from one vector to another.

Both vectors are assumed to be unit length.

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

Scales a quat by a scalar number

set(out:quat, x:Number, y:Number, z:Number, w:Number)

Set the components of a quat to the given values

setAxes(view:vec3, right:vec3, up:vec3)

Sets the specified quaternion with values corresponding to the given axes. Each axis is a vec3 and is expected to be unit length and perpendicular to all other specified axes.

setAxisAngle(out:quat, axis:vec3, rad:Number)

Sets a quat from the given angle and rotation axis, then returns it.

slerp(out:quat, a:quat, b:quat, t:Number)

Performs a spherical linear interpolation between two quat

sqlerp(out:quat, a:quat, b:quat, c:quat, d:quat, t:Number)

Performs a spherical linear interpolation with two control points

squaredLength(a:quat)

Calculates the squared length of a quat

License

MIT. See LICENSE.md for details.

gl-quat's People

Contributors

mattdesl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gl-quat's Issues

question

Hiya! I think it's neat how you can do require('gl-quat/slerp') and only get the one function you actually need. I think this is the basis for 'include only what you use' in JS, since we don't have a linker to pull in only what we need. I see what's going on in the index.js file, with numerous requires. Is that something NPM does? I couldn't find documentation on that feature; if there is some, can you point me in the right direction?

Wouldn't all of those require's occur at once, or does browserify handle the pruning of unused requires?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.