dual-quat-to-mat4

1.0.1 • Public • Published

dual-quat-to-mat4 npm version Build Status

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

  1. Start with some dual quaternion bone data from your character's armature
  2. Grab the dual quaternion for the right hand bone
  3. Convert the right hand bone's dual quaternion into a 4x4 matrix using dual-quat-to-mat4
  4. Use this 4x4 matrix to transform a baseball model view matrix.
  5. 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

Package Sidebar

Install

npm i dual-quat-to-mat4

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

5.97 kB

Total Files

5

Last publish

Collaborators

  • chinedufn
  • kevzettler