npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

squat

v0.1.0

Published

simple quaternion library

Downloads

3

Readme

squat: simple quaternion library

A simple quaternion library for JavaScript.

API documentation

squat's API assumes quaternions are represented as an array of four numbers. Given such an array q, a quaternion is:

q[0] + q[1]*i + q[2]*j + q[3]*k

Functions that return a quaternion typically have an optional argument, at the end of the argument list, which serves as an "out" parameter. If the caller passes an object (like an Array, or a Float64Array) via this argument, the function will set the '0', '1', '2', and '3' properties on the object with the computed quaternion's component values. This can be used to recycle space in a preallocated chunk of memory in an array buffer and avoid allocating space for return values.

squat.add(q1, q2, [out])

Adds two quaternions.

squat.mul(q1, q2, [out])

Multiplies two quaternions.

Note: quaternion multiplication is noncommutative.

squat.scale(q, x, [out])

Scales the quaternion q by the scalar value x, multiplying each component by the scalar.

squat.conjugate(q, [out])

Computes the conjugate of a quaternion.

squat.inverse(q, [out])

Computes the inverse, or reciprocal, of a quaternion.

squat.length(q)

Computes the length of a quaternion. Also known as the "norm".

squat.normalized(q, [out])

Normalizes a quaternion so its length is equal to 1. The result of normalizing a zero quaternion is undefined.

squat.real(q)

Provides the real part of a quaternion, as a number.

squat.vect(q)

Provides the vector part of a quaternion, as a three-element array.

squat.zero([out])

Provides an empty quaternion, with all components set to zero.

squat.from_axis_angle(axis, angle, [out])

Constructs a rotation quaternion, given an axis and angle. The axis should be an array or array-like object holding three numbers. The angle is in radians.

squat.angle(q)

Extracts the angle part, in radians, from a rotation quaternion.

squat.axis(q)

Extracts the axis part, as an array of three numbers, from a rotation quaternion.

License

This library is released under an MIT license.