toji/gl-matrix — pull request #24 by sinisterchipmunk (2012-05-02 18:26:12+00:00)
Title: additional functions for quat4

Hi,

This pull request adds the following:

- `quat4.fromRotationMatrix` - creates or sets a quat4 from a 3x3 rotation matrix; aliased as `mat3.toQuat4`
- `quat4.fromAxes` - creates or sets a quat4 from `vec3`s which together produce a 3D space
- `quat4.identity` - creates or sets an identity quat4
- `quat4.fromAngleAxis` - creates or sets a quat4 from an angle in radians and a `vec3` axis
- `quat4.toAngleAxis` - sets the first 3 components of a `vec4` to the quat's XYZ axis, and its 4th component to the quat's angle

Also added `Math.invsqrt`, which is used by `quat4.toAngleAxis`. This tries to use an optimized version (see http://jsperf.com/inverse-square-root/5) and falls back to `1 / Math.sqrt(num)` if necessary.

Tests are in `spec/quat4_spec.js` and are passing.