Plot circle in 3d space #749
-
I want to draw a circle representing a coordinate point in a 3D space within an #cetz.canvas({
import cetz.draw: *
ortho(x: 20deg, y: 30deg, {
on-xz({
grid((0, 0), (5.5, 5.5), step: 1.0, stroke: gray + 0.2pt)
line((0, 0), (0, 5.5), mark: (end: ">"))
line((0, 0), (5.5, 0), mark: (end: ">"))
})
on-xy({
grid((0, 0), (5.5, 5.5), step: 1.0, stroke: gray + 0.2pt)
line((0, 0), (0, 5.5), mark: (end: ">"))
})
on-yz({
grid((0, 0), (5.5, 5.5), step: 1.0, stroke: gray + 0.2pt)
})
circle((3,3,4), radius: 0.2, fill:red)
})
}) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
In the meantime, I have found a workaround to this problem, by giving up on #cetz.canvas({
import cetz.draw: *
let persp(a, c: calc.sqrt(2)/2) = {
set-transform(
((1, 0, calc.cos(a) * c,0),
(0,-1,-calc.sin(a) * c,0),
(0, 0, 0, 0),
(0, 0, 0, 1)))
}
persp(45deg, c: -0.5)
on-xz({
grid((0, 0), (5.5, 5.5), step: 1.0, stroke: gray + 0.2pt)
line((0, 0), (0, 5.5), mark: (end: ">"))
content((0, 5.8), $z$)
line((0, 0), (5.5, 0), mark: (end: ">"))
content((5.7, 0), $x$)
})
on-xy({
grid((0, 0), (5.5, 5.5), step: 1.0, stroke: gray + 0.2pt)
line((0, 0), (0, 5.5), mark: (end: ">"))
content((0, 5.8), $y$)
})
on-yz({
grid((0, 0), (5.5, 5.5), step: 1.0, stroke: gray + 0.2pt)
})
circle((3,3,4), radius: 0.2, fill:red)
}) However, I still do not know how to plot unslanted circles in the |
Beta Was this translation helpful? Give feedback.
-
Upon further research (and trial-and-error), the easiest way I could find to plot an unslanted circle in the So instead of I will mark this question as answered, but any further insights / better implementation suggestions are welcome! #cetz.canvas({
import cetz.draw: *
ortho(x: 20deg, y: 30deg, {
on-xz({
grid((0, 0), (5.5, 5.5), step: 1.0, stroke: gray + 0.2pt)
line((0, 0), (0, 5.5), mark: (end: ">"), name:"line")
line((0, 0), (5.5, 0), mark: (end: ">"), name:"line")
})
on-xy({
grid((0, 0), (5.5, 5.5), step: 1.0, stroke: gray + 0.2pt)
line((0, 0), (0, 5.5), mark: (end: ">"))
})
on-yz({
grid((0, 0), (5.5, 5.5), step: 1.0, stroke: gray + 0.2pt)
})
content((3,3,4), [#cetz.canvas({circle((), radius: 0.2, fill:red)})])
})
}) |
Beta Was this translation helpful? Give feedback.
Upon further research (and trial-and-error), the easiest way I could find to plot an unslanted circle in the
ortho
environment was to put the circle in anothercetz.canvas
, and encapsulate it withcontent
.So instead of
circle(coordinate, ...)
, I will docontent(coordinate, [#cetz.canvas({circle((), ...)})])
.This will work with any shape (or combination of shapes that can be contained in a canvas).
I will mark this question as answered, but any further insights / better implementation suggestions are welcome!