Skip to content

Commit

Permalink
Merge axelpale/release-2.18.0
Browse files Browse the repository at this point in the history
Release 2.18.0
  • Loading branch information
axelpale committed Dec 12, 2023
2 parents 99f4d7c + eb6da83 commit e88a602
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 65 deletions.
152 changes: 97 additions & 55 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<a name="top"></a>
# Affineplane API Documentation v2.17.1
# Affineplane API Documentation v2.18.0

Welcome to affineplane API reference documentation. These docs are generated with [yamdog](https://axelpale.github.io/yamdog/).

Expand Down Expand Up @@ -166,6 +166,7 @@ and thus can be represented in any basis without loss of information.
- [affineplane.box2.getBasisInverse](#affineplanebox2getbasisinverse)
- [affineplane.box2.getBounds](#affineplanebox2getbounds)
- [affineplane.box2.getCircle](#affineplanebox2getcircle)
- [affineplane.box2.getInnerSquare](#affineplanebox2getinnersquare)
- [affineplane.box2.getMinimumBounds](#affineplanebox2getminimumbounds)
- [affineplane.box2.getPath](#affineplanebox2getpath)
- [affineplane.box2.getPoints](#affineplanebox2getpoints)
Expand Down Expand Up @@ -489,6 +490,24 @@ Aliases: [affineplane.box2.getSphere](#affineplanebox2getsphere)

Source: [getCircle.js](https://github.com/axelpale/affineplane/blob/main/lib/box2/getCircle.js)

<a name="affineplanebox2getinnersquare"></a>
## [affineplane](#affineplane).[box2](#affineplanebox2).[getInnerSquare](#affineplanebox2getinnersquare)(box)

Get the largest square that fits inside the box and has the same center.

<p style="margin-bottom: 0"><strong>Parameters:</strong></p>

- *box*
- a [box2](#affineplanebox2), in the reference basis.


<p style="margin-bottom: 0"><strong>Returns:</strong></p>

- a [box2](#affineplanebox2), in the reference basis.


Source: [getInnerSquare.js](https://github.com/axelpale/affineplane/blob/main/lib/box2/getInnerSquare.js)

<a name="affineplanebox2getminimumbounds"></a>
## [affineplane](#affineplane).[box2](#affineplanebox2).[getMinimumBounds](#affineplanebox2getminimumbounds)(boxes)

Expand Down Expand Up @@ -1506,6 +1525,7 @@ Represented with an object `{ x, y, z, r }` for the origin and the radius.
- [affineplane.circle3.area](#affineplanecircle3area)
- [affineplane.circle3.atCenter](#affineplanecircle3atcenter)
- [affineplane.circle3.boundingBox](#affineplanecircle3boundingbox)
- [affineplane.circle3.boundingCircle](#affineplanecircle3boundingcircle)
- [affineplane.circle3.collide](#affineplanecircle3collide)
- [affineplane.circle3.collideCircle](#affineplanecircle3collidecircle)
- [affineplane.circle3.collideSegment](#affineplanecircle3collidesegment)
Expand Down Expand Up @@ -1618,6 +1638,28 @@ Get outer cuboid boundary of the given circle.

Source: [boundingBox.js](https://github.com/axelpale/affineplane/blob/main/lib/circle3/boundingBox.js)

<a name="affineplanecircle3boundingcircle"></a>
## [affineplane](#affineplane).[circle3](#affineplanecircle3).[boundingCircle](#affineplanecircle3boundingcircle)(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.

<p style="margin-bottom: 0"><strong>Parameters:</strong></p>

- *circles*
- an array of [circle3](#affineplanecircle3)


<p style="margin-bottom: 0"><strong>Returns:</strong></p>

- a [circle3](#affineplanecircle3)


Source: [boundingCircle.js](https://github.com/axelpale/affineplane/blob/main/lib/circle3/boundingCircle.js)

<a name="affineplanecircle3collide"></a>
## [affineplane](#affineplane).[circle3](#affineplanecircle3).[collide](#affineplanecircle3collide)(c, cc)

Expand Down Expand Up @@ -10963,20 +11005,6 @@ The zero vector in 2D

Source: [vec2/index.js](https://github.com/axelpale/affineplane/blob/main/lib/vec2/index.js)

<a name="affineplanevec3zero"></a>
## [affineplane](#affineplane).[vec3](#affineplanevec3).[ZERO](#affineplanevec3zero)

The zero vector in 3D

Source: [vec3/index.js](https://github.com/axelpale/affineplane/blob/main/lib/vec3/index.js)

<a name="affineplanevec4zero"></a>
## [affineplane](#affineplane).[vec4](#affineplanevec4).[ZERO](#affineplanevec4zero)

The zero vector in 4D

Source: [vec4/index.js](https://github.com/axelpale/affineplane/blob/main/lib/vec4/index.js)

<a name="affineplanevec2add"></a>
## [affineplane](#affineplane).[vec2](#affineplanevec2).[add](#affineplanevec2add)(v, w)

Expand Down Expand Up @@ -11612,46 +11640,6 @@ Translation of the plane does not affect the vector.

Source: [transitTo.js](https://github.com/axelpale/affineplane/blob/main/lib/vec2/transitTo.js)

<a name="affineplanevec2unit"></a>
## [affineplane](#affineplane).[vec2](#affineplanevec2).[unit](#affineplanevec2unit)(v)

Get unit vector parallel to the given vector.
The magnitude of unit vector is equal to one.
If zero vector is given, assume direction towards positive x.

<p style="margin-bottom: 0"><strong>Parameters:</strong></p>

- *v*
- a [vec2](#affineplanevec2)


<p style="margin-bottom: 0"><strong>Returns:</strong></p>

- a [vec2](#affineplanevec2), magnitude of one.


Aliases: [affineplane.vec2.normalize](#affineplanevec2normalize)

Source: [unit.js](https://github.com/axelpale/affineplane/blob/main/lib/vec2/unit.js)

<a name="affineplanevec2validate"></a>
## [affineplane](#affineplane).[vec2](#affineplanevec2).[validate](#affineplanevec2validate)(v)

Check if object is a valid [vec2](#affineplanevec2).

<p style="margin-bottom: 0"><strong>Parameters:</strong></p>

- *v*
- an object


<p style="margin-bottom: 0"><strong>Returns:</strong></p>

- a boolean


Source: [validate.js](https://github.com/axelpale/affineplane/blob/main/lib/vec2/validate.js)

<a name="affineplanevec3"></a>
## [affineplane](#affineplane).[vec3](#affineplanevec3)

Expand Down Expand Up @@ -11707,6 +11695,60 @@ and rotation when represented on different plane.

Source: [vec3/index.js](https://github.com/axelpale/affineplane/blob/main/lib/vec3/index.js)

<a name="affineplanevec3zero"></a>
## [affineplane](#affineplane).[vec3](#affineplanevec3).[ZERO](#affineplanevec3zero)

The zero vector in 3D

Source: [vec3/index.js](https://github.com/axelpale/affineplane/blob/main/lib/vec3/index.js)

<a name="affineplanevec4zero"></a>
## [affineplane](#affineplane).[vec4](#affineplanevec4).[ZERO](#affineplanevec4zero)

The zero vector in 4D

Source: [vec4/index.js](https://github.com/axelpale/affineplane/blob/main/lib/vec4/index.js)

<a name="affineplanevec2unit"></a>
## [affineplane](#affineplane).[vec2](#affineplanevec2).[unit](#affineplanevec2unit)(v)

Get unit vector parallel to the given vector.
The magnitude of unit vector is equal to one.
If zero vector is given, assume direction towards positive x.

<p style="margin-bottom: 0"><strong>Parameters:</strong></p>

- *v*
- a [vec2](#affineplanevec2)


<p style="margin-bottom: 0"><strong>Returns:</strong></p>

- a [vec2](#affineplanevec2), magnitude of one.


Aliases: [affineplane.vec2.normalize](#affineplanevec2normalize)

Source: [unit.js](https://github.com/axelpale/affineplane/blob/main/lib/vec2/unit.js)

<a name="affineplanevec2validate"></a>
## [affineplane](#affineplane).[vec2](#affineplanevec2).[validate](#affineplanevec2validate)(v)

Check if object is a valid [vec2](#affineplanevec2).

<p style="margin-bottom: 0"><strong>Parameters:</strong></p>

- *v*
- an object


<p style="margin-bottom: 0"><strong>Returns:</strong></p>

- a boolean


Source: [validate.js](https://github.com/axelpale/affineplane/blob/main/lib/vec2/validate.js)

<a name="affineplanevec3add"></a>
## [affineplane](#affineplane).[vec3](#affineplanevec3).[add](#affineplanevec3add)(v, w)

Expand Down
36 changes: 36 additions & 0 deletions lib/box2/getInnerSquare.js
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
}
}
1 change: 1 addition & 0 deletions lib/box2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ exports.getBasisInverse = require('./getBasisInverse')
exports.getBounds = require('./getBounds')
exports.getCircle = require('./getCircle')
exports.getSphere = exports.getCircle
exports.getInnerSquare = require('./getInnerSquare')
exports.getMinimumBounds = require('./getMinimumBounds')
exports.getPath = require('./getPath')
exports.getPoints = exports.getPath
Expand Down
66 changes: 66 additions & 0 deletions lib/circle3/boundingCircle.js
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
}
}
1 change: 1 addition & 0 deletions lib/circle3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ exports.almostEqual = require('./almostEqual')
exports.area = require('./area')
exports.atCenter = require('./atCenter')
exports.boundingBox = require('./boundingBox')
exports.boundingCircle = require('./boundingCircle')
exports.collide = require('./collide')
exports.collideCircle = exports.collide
exports.collideSegment = require('./collideSegment')
Expand Down
1 change: 0 additions & 1 deletion lib/helm3/transitFrom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module.exports = (tr, source) => {
// @affineplane.helm3.transitFrom(tr, source)
//
Expand Down
1 change: 0 additions & 1 deletion lib/point2/transitFrom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module.exports = (point, source) => {
// @affineplane.point2.transitFrom(point, source)
//
Expand Down
1 change: 0 additions & 1 deletion lib/vec2/transitFrom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module.exports = (vec, plane) => {
// @affineplane.vec2.transitFrom(vec, plane)
//
Expand Down
2 changes: 1 addition & 1 deletion lib/version.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "affineplane",
"version": "2.17.1",
"version": "2.18.0",
"description": "Affine geometry library for 2D and 3D spaces",
"keywords": [
"affine",
Expand Down Expand Up @@ -38,12 +38,12 @@
},
"license": "MIT",
"devDependencies": {
"async": "^3.2.4",
"async": "^3.2.5",
"genversion": "^3.1.1",
"nodemon": "^2.0.21",
"standard": "^17.0.0",
"tap-arc": "^0.3.5",
"tape": "^5.6.3",
"nodemon": "^3.0.2",
"standard": "^17.1.0",
"tap-arc": "^1.2.2",
"tape": "^5.7.2",
"yamdog": "^2.1.0"
},
"scripts": {
Expand Down
Loading

0 comments on commit e88a602

Please sign in to comment.