Skip to content

Commit 410551a

Browse files
committed
Release v1.6
1 parent 2bedf48 commit 410551a

12 files changed

+4344
-1517
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
node_modules

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Robert Eisele
3+
Copyright (c) 2025 Robert Eisele
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+36-44
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
[![NPM Package](https://img.shields.io/npm/v/quaternion.svg?style=flat)](https://npmjs.org/package/quaternion "View this project on npm")
44
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
55

6-
Quaternion.js is a well tested JavaScript library for 3D rotations. Quaternions can be used everywhere, from the rotation calculation of your mobile phone over computer games to the rotation of satellites and all by avoiding the [Gimbal lock](https://en.wikipedia.org/wiki/Gimbal_lock). The library comes with examples to make you get started much quicker without worrying about the math behind.
6+
Quaternion.js is a well tested JavaScript library for 3D rotations. Quaternions can be used everywhere, from the rotation calculation of your mobile phone over computer games to the rotation of satellites and all by avoiding the [Gimbal lock](https://en.wikipedia.org/wiki/Gimbal_lock). The library comes with examples to make you get started much quicker without worrying about the math behind. But if you care, have a look at the [Quaternion Introduction](https://raw.org/book/algebra/quaternions/).
77

88

9-
# Examples
9+
## Examples
1010

1111
```js
1212
var Quaternion = require('quaternion');
@@ -34,8 +34,8 @@ window.addEventListener("deviceorientation", function(ev) {
3434
```
3535

3636

37-
Parser
38-
===
37+
## Parser
38+
3939

4040
Any function (see below) as well as the constructor of the *Quaternion* class parses its input like this.
4141

@@ -100,8 +100,8 @@ new Quaternion("i");
100100
```
101101

102102

103-
Functions
104-
===
103+
## Functions
104+
105105

106106
Every stated parameter *n* in the following list of functions behaves in the same way as the constructor examples above
107107

@@ -223,7 +223,7 @@ Clones the actual object
223223

224224
Array rotateVector(v)
225225
---
226-
Rotates a 3 component vector, represented as an array by the current quaternion
226+
Rotates a 3 component vector, represented as an array by the current quaternion in an [efficient manner](https://raw.org/proof/vector-rotation-using-quaternions/).
227227

228228
Quaternion slerp(q)(pct)
229229
---
@@ -243,7 +243,7 @@ Quaternion.fromEuler(ϕ, θ, ψ[, order="ZXY"]) / Quaternion.fromEulerLogical(ψ
243243
---
244244
Euler angles are probably the reason to use quaternions. The definition is mostly sloppy and you can only decide how it was defined based on the matrix representation. A `ZXY` in one definition is the multiplication order read from right to left and in another the execution order from left to right. Quaternion.js provides two functions, `fromEulerLogical()`, where the angles and order are applied from left to right (logical application order) and `fromEuler()` which reverses the order of the argument list (technical multiplication order).
245245

246-
So for `fromEulerLogical(ϕ, θ, ψ, "ZXY")`, for example means first rotate around Z by ϕ then around X by θ and then around Y by ψ (`RotY(ψ)RotX(θ)RotZ(ϕ)`).
246+
So for `fromEulerLogical(ϕ, θ, ψ, "ZXY")`, for example means first rotate around Z axis by ϕ then around X axis by θ and then around axis Y by ψ (`RotY(ψ)RotX(θ)RotZ(ϕ)`).
247247

248248
The order of `fromEuler()` can take the string value `ZXY (default), XYZ / RPY, YXZ, ZYX / YPR, YZX, XZY, ZYZ, ZXZ, YXY, YZY, XYX, XZX`.
249249

@@ -262,18 +262,16 @@ The order of `fromEuler()` can take the string value `ZXY (default), XYZ / RPY,
262262
- `fromEuler(x, y, z, 'XZY') = ThreeJSfromEuler(x, z, y, 'XZY')`
263263

264264

265-
266-
267265
Quaternion.fromBetweenVectors(u, v)
268266
---
269-
Calculates the quaternion to rotate vector `u` onto vector `v`, represented as 3 element arrays.
267+
Calculates the quaternion to rotate vector `u` onto vector `v`, represented as 3 element arrays, which can be done [elegantly using quaternions](https://raw.org/proof/quaternion-from-two-vectors/).
270268

271269
Quaternion.random()
272270
---
273271
Gets a spherical random number
274272

275-
Constants
276-
===
273+
## Constants
274+
277275

278276
Quaternion.ZERO
279277
---
@@ -298,53 +296,47 @@ An imaginary number k instance
298296

299297

300298

301-
Installation
302-
===
303-
Installing Quaternion.js is as easy as cloning this repo or use one of the following commands:
299+
## Installation
304300

305-
```
306-
bower install quaternion
307-
```
308-
or
301+
Installing Quaternion.js is as easy as cloning this repo or use one of the following command:
309302

310-
```
303+
304+
```bash
311305
npm install quaternion
312306
```
313307

314-
Using Quaternion.js with the browser
315-
===
316-
```html
317-
<script src="quaternion.js"></script>
318-
<script>
319-
console.log(Quaternion("1 + 2i - 3j + 4k"));
320-
</script>
321-
```
308+
## Using Quaternion.js with the browser
322309

323-
Using Quaternion.js with require.js
324-
===
325310
```html
326-
<script src="require.js"></script>
311+
<script src="quaternion.min.js"></script>
327312
<script>
328-
requirejs(['quaternion.js'],
329-
function(Quaternion) {
330313
console.log(Quaternion("1 + 2i - 3j + 4k"));
331-
});
332314
</script>
333315
```
334-
Coding Style
335-
===
316+
317+
318+
##Coding Style
319+
336320
As every library I publish, Quaternion.js is also built to be as small as possible after compressing it with Google Closure Compiler in advanced mode. Thus the coding style orientates a little on maxing-out the compression rate. Please make sure you keep this style if you plan to extend the library.
337321

338-
Testing
339-
===
340-
If you plan to enhance the library, make sure you add test cases and all the previous tests are passing. You can test the library with
322+
##Building the library
323+
324+
After cloning the Git repository run:
325+
326+
```
327+
npm install
328+
npm run build
329+
```
330+
331+
##Run a test
332+
333+
Testing the source against the shipped test suite is as easy as
341334

342335
```
343-
npm test
336+
npm run test
344337
```
345338

339+
## Copyright and licensing
346340

347-
Copyright and licensing
348-
===
349-
Copyright (c) 2023, [Robert Eisele](https://raw.org/)
341+
Copyright (c) 2025, [Robert Eisele](https://raw.org/)
350342
Licensed under the MIT license.

0 commit comments

Comments
 (0)