Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.

Commit

Permalink
Version 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruesc committed May 1, 2020
1 parent bbf7dff commit 85ef5be
Show file tree
Hide file tree
Showing 11 changed files with 5,760 additions and 5,956 deletions.
18 changes: 5 additions & 13 deletions build/math-ds.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* math-ds v1.2.0 build Fri May 01 2020
* math-ds v1.2.1 build Fri May 01 2020
* https://github.com/vanruesc/math-ds
* Copyright 2020 Raoul van Rüschen
* @license Zlib
Expand Down Expand Up @@ -682,10 +682,10 @@ class Vector3 {

angleTo(v) {

const theta = this.dot(v) / (Math.sqrt(this.lengthSquared() * v.lengthSquared()));
const denominator = Math.sqrt(this.lengthSquared() * v.lengthSquared());

// Clamp to avoid numerical problems.
return Math.acos(Math.min(Math.max(theta, -1), 1));
return (denominator === 0.0) ? (Math.PI * 0.5) :
Math.acos(Math.min(Math.max(this.dot(v) / denominator, -1), 1));

}

Expand Down Expand Up @@ -2388,15 +2388,7 @@ class Vector2 {

angle() {

let angle = Math.atan2(this.y, this.x);

if(angle < 0) {

angle += 2 * Math.PI;

}

return angle;
return Math.atan2(-this.y, -this.x) + Math.PI;

}

Expand Down
14 changes: 4 additions & 10 deletions build/math-ds.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* math-ds v1.2.0 build Fri May 01 2020
* math-ds v1.2.1 build Fri May 01 2020
* https://github.com/vanruesc/math-ds
* Copyright 2020 Raoul van Rüschen
* @license Zlib
Expand Down Expand Up @@ -351,8 +351,8 @@
}, {
key: "angleTo",
value: function angleTo(v) {
var theta = this.dot(v) / Math.sqrt(this.lengthSquared() * v.lengthSquared());
return Math.acos(Math.min(Math.max(theta, -1), 1));
var denominator = Math.sqrt(this.lengthSquared() * v.lengthSquared());
return denominator === 0.0 ? Math.PI * 0.5 : Math.acos(Math.min(Math.max(this.dot(v) / denominator, -1), 1));
}
}, {
key: "manhattanLength",
Expand Down Expand Up @@ -1064,13 +1064,7 @@
}, {
key: "angle",
value: function angle() {
var angle = Math.atan2(this.y, this.x);

if (angle < 0) {
angle += 2 * Math.PI;
}

return angle;
return Math.atan2(-this.y, -this.x) + Math.PI;
}
}, {
key: "lerp",
Expand Down
4 changes: 2 additions & 2 deletions build/math-ds.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 85ef5be

Please sign in to comment.