quat-from-unit-vec3
v1.0.0
Published
creates a quaternion from two unit vectors
Downloads
2,237
Maintainers
Readme
quat-from-unit-vec3
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
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.