-
-
Notifications
You must be signed in to change notification settings - Fork 75
arc-through fails due to floating point residual error on non-zero Z coordinates #1055
Copy link
Copy link
Open
Milestone
Description
I wanted to build an arc that goes thru a circle with a non zero z coordinate. And for certain z coordinates there is a floating point residual error that blocks the arc from forming.
The solution would be to round the z coordinate before construction the arc.
#cetz.canvas({
import cetz.draw: *
let pos = (4, 2)
circle((rel: (0, 0, -1), to : pos), radius: 1, name: "back", stroke: none)
arc-through_rounded("back.south-east", "back.north" ,"back.north-west")
})And I get
assertion failed: The z coordinate of all points must be equal, but is: (-1.0000000000000002, -1.0, -1.0)
I made a temporary fix with this function, but I don't believe it is a fullproof solution and would like to know what you think.
#let arc-through_rounded(a, b, c, digits: 4) = {
get-ctx(ctx => {
let (ctx, a, b, c) = cetz.coordinate.resolve(ctx, a, b, c)
(a,b,c) = (a,b,c).map(v => (v.at(0), v.at(1), calc.round(v.at(2), digits: digits)))
cetz.draw.arc-through(a,b,c)
})
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels