How do draw an angle that is not in the x-y plane? #838
-
I need to draw an angle essentially from a->D->R in the figure, but I'm getting the issue that all the z-coordinates of the vertices defining the angle need to be the same. I have commented the angle at the end. Is there any way to draw this?
|
Beta Was this translation helpful? Give feedback.
Answered by
johannes-wolf
Mar 19, 2025
Replies: 1 comment 1 reply
-
Hack Alert! It is possible, but very ugly.
Allowing a z component in #import "@preview/cetz:0.3.4": *
#let matrice_landing_angles = canvas(length: 3cm, {
import draw: *
let radius_origin_negative = 0.5
let radius_origin_positive = 1.5
let origin = (0, 0, 0)
let drone = (0, 0, 1.25)
let ymax = (0, 2, 0)
let landing_pad = (0.6, 0.75, 0)
let landing_pad_y = (0, 0.75, 0)
let landing_pad_angle = -19deg
let landing_pad_radius = 0.75
ortho(y: 0deg, x: -60deg, z: -55deg, name: "v", {
on-xy({
grid((-radius_origin_negative, -radius_origin_negative), (radius_origin_positive, radius_origin_positive), step: 0.25, stroke: 0.125pt)
})
set-style(
mark: (fill: black, scale: 2),
stroke: (thickness: 0.4pt, cap: "round"),
content: (padding: 1pt)
)
line((-0.75, 0, 0), (1.75, 0, 0), mark: (start: "stealth", end: "stealth"))
content((1.75, 0, 0), anchor: "south-west", padding: 1mm, $x$)
line((0, -0.75, 0), (0, 1.75, 0), mark: (start: "stealth", end: "stealth"))
content((0, 1.75, 0), anchor: "west", padding: 1mm, $y$)
line((0, 0, -0.75), (0, 0, 1.75), mark: (start: "stealth", end: "stealth"))
content((0, 0, 1.75), anchor: "north", padding: 1mm, $z$)
content(drone, $D$, anchor: "east", padding: 1mm)
line(drone, landing_pad, stroke: (dash: "dashed"))
line(origin, landing_pad, stroke: (dash: "dashed"))
content((origin, 50%, drone), text(fill: red, $a$), anchor: "east", padding: 1mm)
content((landing_pad, 60%, drone), text(fill: red, $R$), anchor: "north-west", padding: 2mm)
angle.angle(origin, landing_pad, ymax, fill: aqua.lighten(50%), label-radius: 0.6, label: $phi$)
angle.angle(landing_pad_y, landing_pad, ymax, fill: aqua.lighten(50%),
label: $psi$, label-radius: 0.6, radius: 0.5)
circle((0.6,0.75), radius: 1mm, fill: black)
line(landing_pad, (landing_pad_radius * calc.cos(landing_pad_angle) + 0.75, landing_pad_radius * calc.sin(landing_pad_angle) + 1, 0), mark: (fill: blue, end: "stealth"), stroke: blue)
line(landing_pad_y, landing_pad, stroke: (dash: "dashed", paint: blue))
content(landing_pad, anchor: "south-east", padding: 1mm, "LP")
anchor("landing_pad", landing_pad)
anchor("drone", drone)
anchor("origin", origin)
})
scope(ctx => {
let (drone, landing_pad, origin) = coordinate.resolve(
ctx, "v.drone", "v.landing_pad", "v.origin")
.slice(1)
.map(v => {
// We do not want transformed coordinates
v = util.revert-transform(ctx.transform, v)
// Remove the z component
(v.at(0), v.at(1), 0)
})
angle.angle(drone, origin, landing_pad, fill: aqua.lighten(50%),
label: $theta$, label-radius: 0.6, radius: 0.5, inner: true)
})
})
#figure(
matrice_landing_angles,
caption: [Relevant angles.]
) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
uzgit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hack Alert! It is possible, but very ugly.
My solution:
Allowing a z component in
angle
coordinats would be useful.I should also add some function to get non-transformed anchor coordinates.
Ortho returning anchors with a
z!=0
seems to be not correct.