diff --git a/CHANGES.md b/CHANGES.md index 65d7c16a..3113ca36 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ - Fixed mark `inset:` style getting applied twice (#1099) - Fixes `matrix.diag` function typo - Added a new `make-ctx` function for creating a new canvas context without a canvas +- Fixed a bug with hobby and boolean rejecting two component vectors # 0.5.1 - Added the `boolean` draw function for path boolean operations. diff --git a/src/draw/boolean.typ b/src/draw/boolean.typ index 44f54b6d..d550720b 100644 --- a/src/draw/boolean.typ +++ b/src/draw/boolean.typ @@ -75,12 +75,12 @@ // Projects a CeTZ 3D path to a 2D wire path, asserting all vertices share the // same z-plane (within `tol`) and all subpaths are closed. -#let _path3d-to-wire2d(path3d, tol: 1e-6) = { +#let _path3d-to-wire2d(path3d, eps: 1e-6) = { if path3d.len() == 0 { return ((subpaths: ()), 0.0) } - let (z0, same-z) = path-util.same-z-plane(path3d, tol: tol) + let (z0, same-z) = path-util.same-z-plane(path3d, eps: eps) assert(same-z, message: "boolean: all input vertices must lie in a single z-plane.") let drop-z(v) = (v.at(0), v.at(1)) diff --git a/src/path-util.typ b/src/path-util.typ index d601a37c..4e3c2d27 100644 --- a/src/path-util.typ +++ b/src/path-util.typ @@ -93,19 +93,19 @@ /// `true` iff every other vertex is within `tol` of that z-coordinate. /// /// - path (path): Input path; must be non-empty -/// - tol (float): Absolute z tolerance +/// - eps (float): Absolute z tolerance /// -> array Tuple of the form (z, same-z) -#let same-z-plane(path, tol: 1e-6) = { +#let same-z-plane(path, eps: 1e-6) = { assert( path.len() > 0, message: "Cannot determine z-plane of an empty path", ) - let z0 = path.first().at(0).at(2) + let z0 = path.first().at(0).at(2, default: 0.0) for (origin, _, segments) in path { - if calc.abs(origin.at(2) - z0) > tol { return (z0, false) } + if calc.abs(origin.at(2, default: 0.0) - z0) > eps { return (z0, false) } for (kind, ..args) in segments { for v in args { - if calc.abs(v.at(2) - z0) > tol { return (z0, false) } + if calc.abs(v.at(2, default: 0.0) - z0) > eps { return (z0, false) } } } }