Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/draw/boolean.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions src/path-util.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}
}
Expand Down