Hey, this probably has some very obvious solution that for some reason I can‘t seem to find. Is there a way to draw an arc in CeTZ, that’s on the x-z-plane. When i try arc-through and feed it points in that plane, i get an error. Thank you for your help!
Hi!
Please provide a minimal code snippet of what you tried to do, so we can further investigate the error.
Thanks.
Sorry it took me so long to get back to you - here‘s the code I tried:
#cetz.canvas(
{import cetz.draw: *
// drawing reference axes
line((0, 0, 0), (0, 3, 0), name: "axisY", stroke: (paint: black, thickness: .7pt, dash: "dashed", cap: "round"))
line((0, 0, 0), (0, 0, 3), name: "axisZ", stroke: (paint: black, thickness: .7pt, dash: "dashed", cap: "round"))
line((0, 0, 0), (3, 0, 0), name: "axisX", stroke: (paint: black, thickness: .7pt, dash: "dashed", cap: "round"))
//labeling axes
content("axisZ.end", [$z$], anchor: "east", padding: .1)
content("axisY.end", [$y$], anchor: "east", padding: .1)
content("axisX.end", [$x$], anchor: "west", padding: .1)
//drawing arc between z and x axis
arc-through((0, 0, 2), (calc.sqrt(2), 0, calc. sqrt(2)), (2, 0, 0))
})
The function arc-through()
does not seem to directly support drawing with three-dimensional coordinates. The example here only uses xy-coordinates but the documentation does not directly state that the function can not have non-zero z-coordinates.
Since you want to draw the arc in the xz-plane, you can use the projection function on-xz
. This will “promote” your arc points from 2D to 3D according to (x, y) → (x, 0, y).
// drawing arc between z and x axis
on-xz(arc-through((0, 2), (calc.sqrt(2), calc.sqrt(2)), (2, 0)))
Thanks, that should work. On another note - would you happen to have such a handy solution for when I‘m trying to draw an arc outside any base plane?
Looking at the available projection functions, I think ortho()
is what you would be looking for. In the example they use on-xz()
to draw a rectangle in the xz-plane which is then “rotated” by the ortho()
function.