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

@xloxlolex/quaternion-math

v1.1.0

Published

Fast and easy-to-use Quaternion Math library powered by TypeScript

Downloads

19

Readme

TypeScript Quaternion Math

Fast and easy-to-use Quaternion Math library powered by TypeScript

Logo

Installation

Install @xloxlolex/quaternion-math with npm

  mkdir my-project
  cd my-project
  npm install @xloxlolex/quaternion-math

Usage

Import

import { Quaternion } from '@xloxlolex/quaternion-math';

Constructor

// Creates a new Quaternion with given x, y, z and w components.
// All components are optional and, if not specified, will be set to Quaternion.identity by default.
Quaternion(x?: number, y?: number, z?: number, w?: number);

Static Variables

Quaternion.identity; // Quaternion(0, 0, 0, 1).

Static Methods

// Create a Quaternion from Euler angles.
Quaternion.Euler(v: Vector3): Quaternion;

// Normalizes a Quaternion.
Quaternion.Normalize(q: Quaternion): Quaternion;

// Returns the angle in degrees from one Quaternion to another.
Quaternion.Angle(from: Quaternion, to: Quaternion): number;

// Returns a copy of a Quaternion with its magnitude clamped to maxLength.
Quaternion.ClampMagnitude(quaternion: Quaternion, maxLength: number): Quaternion;

// Rotates a Quaternion towards another with a max degree of maxDegreesDelta.
Quaternion.RotateTowards(from: Quaternion, to: Quaternion, maxDegreesDelta: number): Quaternion;

// Spherical Linear Interpolation between two Quaternions. If t is lower than 0, return "from". If t is greater than 1, return "to".
Quaternion.Slerp(from: Quaternion, to: Quaternion, t: number): Quaternion;

// Spherical Linear Interpolation between two Quaternions.
Quaternion.SlerpUnclamped(from: Quaternion, to: Quaternion, t: number): Quaternion;

// Rotates a point with a given rotation.
Quaternion.RotatePoint(rotation: Quaternion, point: Vector3): Vector3;

// The dot product between two Quaternions.
Quaternion.Dot(lhs: Quaternion, rhs: Quaternion): number;

// Returns the length of a given Quaternion.
Quaternion.Magnitude(quaternion: Quaternion): number;

// Add two Quaternions.
Quaternion.Add(lhs: Quaternion, rhs: Quaternion): Quaternion;

// Subtract two Quaternions.
Quaternion.Subtract(lhs: Quaternion, rhs: Quaternion): Quaternion;

// Combines rotations lhs and rhs.
Quaternion.Multiply(lhs: Quaternion, rhs: Quaternion): Quaternion;

// Divides two Quaternions (lhs / rhs).
Quaternion.Divide(lhs: Quaternion, rhs: Quaternion): Quaternion;

// Checks whether the lhs and the rhs Quaternions are the same.
Quaternion.Equals(lhs: Quaternion, rhs: Quaternion): Quaternion;

Public Variables

var quaternion = new Quaternion();

quaternion.x; // X component of the Quaternion.
quaternion.y; // Y component of the Quaternion.
quaternion.z; // Z component of the Quaternion.
quaternion.w; // W component of the Quaternion.

quaternion.normalized; // Returns this Quaternion with a magnitude of 1 (Read Only).
quaternion.magnitude; // Returns the length of this Quaternion.
quaternion.sqrMagnitude; // Returns the squared length of this Quaternion.
quaternion.conjugate; // Returns the conjugate of this Quaternion.
quaternion.inverse; // Returns the inverse of this Quaternion.
quaternion.eulerAngles; // Returns the Euler angles representation of this Quaternion.

Public Methods

var quaternion = new Quaternion();

// Add a Quaternion to this Quaternion.
quaternion.Add(other: Quaternion): void;

// Subtract a Quaternion from this Quaternion.
quaternion.Subtract(other: Quaternion): void;

// Combines rotations between this Quaternion and another.
quaternion.Multiply(other: Quaternion): void;

// Divides two Quaternions (this / other).
quaternion.Divide(other: Quaternion): void;

// Checks whether this Quaternion and another are the same.
quaternion.Equals(other: Quaternion): boolean;

Dependencies

Authors

License

MIT

Support

For support, email [email protected].