quat-from-unit-vec3

creates a quaternion from two unit vectors

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
quat-from-unit-vec3
001.0.07 years ago7 years agoMinified + gzip package size for quat-from-unit-vec3 in KB

Readme

quat-from-unit-vec3
stable
Creates a quaternion from two (normalized) unit vectors. Adapted from this blog post.

Install

npm install quat-from-unit-vec3 --save

Example

var fromUnitVec3 = require('quat-from-unit-vec3')

var vecA = [0, 0, 0]
var vecB = [0, 0, 1]
var quat = fromUnitVec3([], vecA, vecB)
//=> [ 0, 0, 0, 1 ]

Usage

NPM

quat = fromUnitVec3(quat, a, b)

Forms a quaternion from two normalized unit vectors, a and b (3-component arrays). The value is stored in quat (a 4-component array) and returned.

License

MIT, see LICENSE.md for details.