Skip to main content
Home

A comprehensive math library for TypeScript applications

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
82%
Published
3 months ago (0.0.8)
class Quaternion
extends Vector4

A quaternion class for representing 3D rotations.

Quaternions are a mathematical concept used to represent rotations in 3D space. They offer advantages over Euler angles (avoiding gimbal lock) and rotation matrices (more compact and numerically stable).

This class extends Vector4, where:

  • x, y, z components represent the vector partbv
  • w component represents the scalar part

Examples

Example 1

// Create a quaternion from Euler angles (in degrees)
const rotation = Quaternion.fromEuler(45, 0, 30);

// Convert back to Euler angles
const euler = rotation.toEuler();

// Combine rotations using multiplication
const combined = Quaternion.multiply(rotation1, rotation2);

Methods

toEuler(): ReadonlySimpleVector3

Static Methods

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@g43/math

Import symbol

import { Quaternion } from "@g43/math";
or

Import directly with a jsr specifier

import { Quaternion } from "jsr:@g43/math";

Add Package

pnpm i jsr:@g43/math
or (using pnpm 10.8 or older)
pnpm dlx jsr add @g43/math

Import symbol

import { Quaternion } from "@g43/math";

Add Package

yarn add jsr:@g43/math
or (using Yarn 4.8 or older)
yarn dlx jsr add @g43/math

Import symbol

import { Quaternion } from "@g43/math";

Add Package

vlt install jsr:@g43/math

Import symbol

import { Quaternion } from "@g43/math";

Add Package

npx jsr add @g43/math

Import symbol

import { Quaternion } from "@g43/math";

Add Package

bunx jsr add @g43/math

Import symbol

import { Quaternion } from "@g43/math";