Closed KronosTheLate closed 3 months ago
3D support is very limited right now. To set up your coordinate system, call set-transform(<matrix>)
to overwrite the transformation matrix. We should definitely add some functions to set up 3D coordinate systems more easily.
The system is left-handed because TikZ' also is, tbh.
A scale(z: -1)
should flip the coordinates.
Some elements, like marks, have z-up
and xy-up
style-keys to set up their orientation, but this does not change the coordinate system.
Thanks, scale(z: -1)
works as expected.
I am super impressed by the limited 3D support, awesome work ^_^
As this is a young package, it is not too late to improve upon it's ancestors. Would it not make a lot of sense to make the default coordinate system right-handed, and basically all coordinate systems anyone works with are? If not, the burden of inverting the z-axis will be inherited by every user wanting to visualize a normal coordinate system, forever. Unless there is a clear benefit (other than consistency with TikZ), I would vote hard in the direction of changing the default.
@KronosTheLate what do you think about https://github.com/johannes-wolf/cetz/pull/504
It looks good to me! There are some details I feel unable to evaluate (due to lack of knowledge and experience), but that PR certainly closes this issue. I will hop on over to continue the discussion there.
Thanks for fixing this <3
Relevant issue: https://github.com/johannes-wolf/cetz/issues/274
The following screenshot shows how a simple 3D coordinate system I made appears to be left-handed:
Code:
``` #import "@preview/cetz:0.2.0" // Drawing diagrams directly in Document #[ #cetz.canvas(length: 2cm, { import cetz.draw: * rotate(y: 30deg) let grid_sidelength = 3 grid( (-grid_sidelength/2, -grid_sidelength/2, -grid_sidelength/2), (grid_sidelength/2, grid_sidelength/2, -grid_sidelength/2), step: 0.5, stroke: gray + 0.2pt ) line((-grid_sidelength/2, 0, 0), (grid_sidelength/2, 0, 0), name: "xaxis", mark: (end: "stealth")) content((name: "xaxis", anchor: 98%), [#v(1.5em)$ x $]) line((0, -grid_sidelength/2, 0), (0, grid_sidelength/2, 0), name: "yaxis", mark: (end: "stealth")) content((name: "yaxis", anchor: 98%), [#h(-0.9em)$y$]) line((0, 0, -grid_sidelength/2), (0, 0, grid_sidelength/2), name: "zaxis", mark: (end: "stealth")) content((name: "zaxis", anchor: 98%), [#h(-1em)$z$], anchor: "south-east") let ccol = red.darken(30%) line((0, 0, 0), (1, 0, 0), name: "ihat", mark:(end: "stealth", fill: ccol), stroke: ccol) content((name: "ihat", anchor: 65%, ), text(ccol)[#v(1.5em)$hat(i)$]) let ccol = green.darken(30%) line((0, 0, 0), (0, 1, 0), name: "jhat", mark:(end: "stealth", fill: ccol), stroke: ccol) content((name: "jhat", anchor: 65%), text(ccol)[#h(-0.75em)$hat(j)$]) let ccol = blue.darken(30%) line((0, 0, 0), (0, 0, 1), name: "khat", mark:(end: "stealth", fill: ccol), stroke: ccol) content((name: "khat", anchor: 65%), text(ccol)[#v(-1em)$hat(k)$]) })] ```This seems like an odd choice to me. I tried changing
z-up
andxy-up
inset-style
, but I could not see any difference. Am I doing it wrong, or is the default coordinate system left-handed?P.S: Awesome package. Easy to use, reaults look great.