-
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 2.18.0
- Loading branch information
Showing
13 changed files
with
269 additions
and
65 deletions.
There are no files selected for viewing
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,36 @@ | ||
module.exports = (box) => { | ||
// @affineplane.box2.getInnerSquare(box) | ||
// | ||
// Get the largest square that fits inside the box and has the same center. | ||
// | ||
// Parameters | ||
// box | ||
// a box2, in the reference basis. | ||
// | ||
// Return | ||
// a box2, in the reference basis. | ||
// | ||
|
||
if (box.h < box.w) { | ||
const offset = (box.w - box.h) / 2 | ||
return { | ||
a: box.a, | ||
b: box.b, | ||
x: box.x + offset * box.a, // offset along width | ||
y: box.y + offset * box.b, | ||
w: box.h, // square | ||
h: box.h | ||
} | ||
} | ||
// else box.h >= box.w | ||
|
||
const offset = (box.h - box.w) / 2 | ||
return { | ||
a: box.a, | ||
b: box.b, | ||
x: box.x - offset * box.b, // offset along height; orient. rotated 90 deg | ||
y: box.y + offset * box.a, | ||
w: box.w, | ||
h: box.w // square | ||
} | ||
} |
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,66 @@ | ||
module.exports = (circles) => { | ||
// @affineplane.circle3.boundingCircle(circles) | ||
// | ||
// Find a circle that encloses all the given circles | ||
// when projected onto the same xy-plane. | ||
// The resulting circle shares the largest z coordinate of the given circles. | ||
// The result is approximate but is quaranteed to contain the optimal | ||
// (projected) bounding circle. | ||
// | ||
// Parameters | ||
// circles | ||
// an array of circle3 | ||
// | ||
// Return | ||
// a circle3 | ||
// | ||
|
||
const n = circles.length | ||
if (n === 0) { | ||
throw new Error('Cannot compute bounding circle for empty set of circles.') | ||
} | ||
|
||
// Find bounding box | ||
const c0 = circles[0] | ||
let minx = c0.x - c0.r | ||
let maxx = c0.x + c0.r | ||
let miny = c0.y - c0.r | ||
let maxy = c0.y + c0.r | ||
let maxz = c0.z | ||
for (let i = 1; i < n; i += 1) { | ||
const c = circles[i] | ||
const mix = c.x - c.r | ||
const max = c.x + c.r | ||
const miy = c.y - c.r | ||
const may = c.y + c.r | ||
const maz = c.z | ||
if (mix < minx) { minx = mix } | ||
if (max > maxx) { maxx = max } | ||
if (miy < miny) { miny = miy } | ||
if (may > maxy) { maxy = may } | ||
if (maz > maxz) { maxz = maz } | ||
} | ||
|
||
// TODO Find better bounding box | ||
|
||
// Find the center of the bounding box. | ||
const ox = minx + (maxx - minx) / 2 | ||
const oy = miny + (maxy - miny) / 2 | ||
|
||
// Find max radius | ||
let maxr = 0 | ||
for (let i = 0; i < n; i += 1) { | ||
const c = circles[i] | ||
const dx = c.x - ox | ||
const dy = c.y - oy | ||
const d = Math.sqrt(dx * dx + dy * dy) + c.r | ||
if (maxr < d) { maxr = d } | ||
} | ||
|
||
return { | ||
x: ox, | ||
y: oy, | ||
z: maxz, | ||
r: maxr | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
module.exports = (tr, source) => { | ||
// @affineplane.helm3.transitFrom(tr, source) | ||
// | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
module.exports = (point, source) => { | ||
// @affineplane.point2.transitFrom(point, source) | ||
// | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
module.exports = (vec, plane) => { | ||
// @affineplane.vec2.transitFrom(vec, plane) | ||
// | ||
|
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
Oops, something went wrong.