README
dual-quat-to-mat4
Convert a 4x4 matrix into a dual quaternion. Useful for skeletal animation
Background / Initial Motivation
dual-quat-to-mat4
's initial motivation was to be used to convert a bone's dual quaternion into a matrix in order to use it to position a model relative to your bone.
For example, let's say you have an armature that you blended between two keyframes using skeletal-animation-system. You now want to render a baseball in your armature's hand
- Start with some dual quaternion bone data from your character's armature
- Grab the dual quaternion for the right hand bone
- Convert the right hand bone's dual quaternion into a 4x4 matrix using
dual-quat-to-mat4
- Use this 4x4 matrix to transform a baseball model view matrix.
- Your baseball will now be rendered with it's origin at your right hand bone
- (Or at some offset from that bone if you factor that into your model view matrix)
To Install
$ npm install --save dual-quat-to-mat4
Usage
var dualQuatToMat4 = require('dual-quat-to-mat4')
var matrix = []
var dualQuat = dualQuatToMat4(matrix, [0, 0, 0, 1, 0, 0, 0, 0])
console.log(matrix)
// [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
API
-> dualQuatToMat4(out, dualQuat)Array[16]
out
Required
Type: Array[*]
An allocated array that will get elements [0] through [15] set as your output matrix
dualQuat
Required
Type: Array[8]
The dual quaternion that you want to convert into a 4x4 matrix
See Also
References
License
MIT