-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release v2.5.0
- Loading branch information
Showing
33 changed files
with
986 additions
and
620 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// affineplane.point2.almostEqual(p, q[, epsilon]) | ||
// | ||
// Test if points are almost equal by the margin of epsilon. | ||
// | ||
// Parameters | ||
// p | ||
// a point2 | ||
// q | ||
// a point2 | ||
// epsilon | ||
// optional number, default to affineplane.epsilon. | ||
// .. Set to 0 for strict comparison. | ||
// | ||
// Return | ||
// a boolean | ||
// | ||
module.exports = require('../vec2/almostEqual') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const epsilon = require('../epsilon') | ||
|
||
module.exports = (v, w) => { | ||
// affineplane.vec2.independent(v, w) | ||
// | ||
// Test if the two vectors are [linearly independent]( | ||
// https://en.wikipedia.org/wiki/Linear_independence) or almost so | ||
// within the margin of affineplane.epsilon. | ||
// | ||
// Parameters: | ||
// v | ||
// a vec2 | ||
// w | ||
// a vec2 | ||
// | ||
// Return | ||
// a boolean, true if vectors are independent. | ||
// | ||
|
||
// Dependent when determinant is zero | ||
// | v.x w.x | | ||
// | v.y w.y | | ||
// | ||
return Math.abs(v.x * w.y - v.y * w.x) > epsilon | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const epsilon = require('../epsilon') | ||
const cross = require('./cross') | ||
const abs = Math.abs | ||
|
||
module.exports = (v, w) => { | ||
// affineplane.vec3.independent(v, w) | ||
// | ||
// Test if the two vectors are [linearly independent]( | ||
// https://en.wikipedia.org/wiki/Linear_independence) or almost so | ||
// within the margin of affineplane.epsilon. | ||
// | ||
// Parameters: | ||
// v | ||
// a vec3 | ||
// w | ||
// a vec3 | ||
// | ||
// Return | ||
// a boolean, true if vectors are independent. | ||
// | ||
|
||
// Dependent when the cross product is zero. | ||
// Independnet when non-zero | ||
const c = cross(v, w) | ||
return abs(c.x) + abs(c.y) + abs(c.z) > epsilon | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = function (vec, tr) { | ||
// affineplane.vec3.transformBy(vec, tr) | ||
// | ||
// Transform a vector. Translation does not affect the vector. | ||
// | ||
// Parameters | ||
// vec | ||
// a vec3 | ||
// tr | ||
// a helm3 | ||
// | ||
// Return | ||
// a vec3, the transformed vector | ||
// | ||
return { | ||
x: tr.a * vec.x - tr.b * vec.y, | ||
y: tr.b * vec.x + tr.a * vec.y, | ||
z: vec.z | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const point2 = require('../../lib/point2') | ||
|
||
module.exports = (ts) => { | ||
ts.test('case: margin', (t) => { | ||
const p = { x: 0, y: 0 } | ||
const q = { x: 3, y: 3 } | ||
t.false(point2.almostEqual(p, q, 1)) | ||
t.false(point2.almostEqual(p, q, 5)) | ||
t.true(point2.almostEqual(p, q, 6)) | ||
|
||
t.end() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const affineplane = require('../../index') | ||
const vec2 = affineplane.vec2 | ||
|
||
module.exports = (ts) => { | ||
ts.test('case: basic independency', (t) => { | ||
t.false( | ||
vec2.independent( | ||
{ x: 0, y: 0 }, | ||
{ x: 0, y: 0 } | ||
), | ||
'zero vectors dependent' | ||
) | ||
|
||
t.true( | ||
vec2.independent( | ||
{ x: 1, y: 1 }, | ||
{ x: 2, y: 1 } | ||
), | ||
'vectors have different direction' | ||
) | ||
|
||
t.false( | ||
vec2.independent( | ||
{ x: -1, y: -1 }, | ||
{ x: 2, y: 2 } | ||
), | ||
'vectors have opposite direction' | ||
) | ||
|
||
t.end() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const affineplane = require('../../index') | ||
const vec2 = affineplane.vec2 | ||
|
||
module.exports = (ts) => { | ||
ts.test('case: basic transformation', (t) => { | ||
t.almostEqual( | ||
vec2.transformBy({ x: 0, y: 0 }, { a: 1, b: 2, x: 3, y: 4 }), | ||
{ x: 0, y: 0 }, | ||
'zero vector remains zero' | ||
) | ||
|
||
const rot90 = { a: 0, b: 1, x: 0, y: 0 } | ||
t.almostEqual( | ||
vec2.transformBy({ x: 1, y: -1 }, rot90), | ||
{ x: 1, y: 1 }, | ||
'vector is rotated' | ||
) | ||
|
||
const rot90tran = { a: 0, b: 1, x: 5, y: 5 } | ||
t.almostEqual( | ||
vec2.transformBy({ x: 1, y: -1 }, rot90tran), | ||
{ x: 1, y: 1 }, | ||
'translation does not affect' | ||
) | ||
|
||
const singular = { a: 0, b: 0, x: 0, y: 0 } | ||
t.almostEqual( | ||
vec2.transformBy({ x: 1, y: -1 }, singular), | ||
{ x: 0, y: 0 }, | ||
'singular transform results zero vector' | ||
) | ||
|
||
t.end() | ||
}) | ||
} |
Oops, something went wrong.