Jollywatt / typst-fletcher

Typst package for drawing diagrams with arrows, built on top of CeTZ.
MIT License
270 stars 6 forks source link

Default 3D coordinate system is left-handed? #9

Closed KronosTheLate closed 4 months ago

KronosTheLate commented 4 months ago

The following screenshot shows how a simple 3D coordinate system I made appears to be left-handed:

image
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 and xy-up in set-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.

KronosTheLate commented 4 months ago

Sorry, ment to raise this issue over at cetz itself. This is now done, so I will close this.

Jollywatt commented 4 months ago

(Here's the cetz issue: https://github.com/johannes-wolf/cetz/issues/501 for anyone reading)