How to use `angle()` with z-coordinate and projection?

Hi all,

I want to draw the right angle AFE but I could not figure out how to do so.

#import "@preview/cetz:0.4.2" as cetz: *

#cetz.canvas({
  import cetz.angle: *
  import cetz.draw: *

  rotate(x: 270deg)
  rotate(z: 270deg - 5deg)

  let l = 10
  set-style(stroke: 0.4pt)
  grid(
    (-l / 2, -l / 2, -l / 2),
    (l / 2, l / 2, -l / 2),
    help-lines: true,
  )

  line((4, 0), (0, 0), (0, 4), stroke: (paint: blue, dash: "dashed"))
  line((4, 0), (4, 4), (0, 4), stroke: (paint: blue), name: "r")
  content("r.25%", $r$, anchor: "north")
  line((0, 0, 0), (2, 2, 6), stroke: (paint: blue, dash: "dashed"))
  line((0, 4, 0), (2, 2, 6), stroke: blue, name: "p")
  content("p.mid", $p$, anchor: "south-west")
  line((4, 0, 0), (2, 2, 6), stroke: blue)
  line((4, 4, 0), (2, 2, 6), stroke: blue)

  line((2, 4, 0), (2, 2, 6), stroke: (paint: blue, dash: "dashed"), name: "ell")
  content("ell.mid", $ell$, anchor: "west")

  line((2, 2, 0), (2, 2, 6), stroke: (paint: blue, dash: "dashed"), name: "h")
  content("h.mid", $h$)

  line((2, 2), (2, 4), stroke: (paint: blue, dash: "dashed"))

  right-angle((4, 0), (0, 0), (4, 4), label: none, stroke: orange, fill: orange.lighten(80%))

  on-yz(x: 2, {
    angle((0, 4), (0, 2), (6, 2), label: none, stroke: orange, fill: orange.lighten(80%), name: "a")
  })
  content("a.north-west", $a$)

  on-yz(x: 2, {
    right-angle((0, 2), (0, 4), (6, 2), label: none, stroke: orange, fill: orange.lighten(80%))
  })

  // how to project this on a specific plane
  on-xz(y: 4, {
    right-angle((2, 0), (0, 0), (2, 6), label: none, stroke: orange, fill: orange.lighten(80%))
  })

  content((2, 2, 6), $A$, anchor: "south")
  content((0, 0, 0), $B$, anchor: "south-east")
  content((4, 0, 0), $C$, anchor: "east")
  content((4, 4, 0), $D$, anchor: "north-west")
  content((0, 4, 0), $E$, anchor: "west")
  content((2, 2, 0), $O$, anchor: "north-east")
  content((2, 4, 0), $F$, anchor: "north-west")
})

I also tried using right-angle() with 3d coordinates without on-xz() which returns an undesired output, and angle() with 3d coordinates without on-xz() which returns an error.

How should I properly draw the angle AFE?

1 Like