I want to create the rotated cube with Makie.jl
and GeometryBasics.jl
. I made the following code, but it did not work well.
using GLMakie, GeometryBasics
# rotation matrix
theta = pi/4
C = [
1 0 0
0 cos(theta) -sin(theta)
0 sin(theta) cos(theta)
]
# rotated points of a cube
points = [
Point3{Float64}(C * [ 0.5, 0.5, 0.5]),
Point3{Float64}(C * [-0.5, 0.5, 0.5]),
Point3{Float64}(C * [-0.5, -0.5, 0.5]),
Point3{Float64}(C * [ 0.5, -0.5, 0.5]),
Point3{Float64}(C * [ 0.5, 0.5, -0.5]),
Point3{Float64}(C * [-0.5, 0.5, -0.5]),
Point3{Float64}(C * [-0.5, -0.5, -0.5]),
Point3{Float64}(C * [ 0.5, -0.5, -0.5])
]
cube = GeometryBasics.mesh(points)
fig = Figure()
ax = Axis3(
fig[1, 1],
aspect = :data,
viewmode = :fit
)
mesh!(ax, cube, color=:yellow, shading = true)
display(fig)
The Makie displays the following, which does not contain any mesh.
I investigated the variable cube
, and it gives the empty mesh. I believe it should have Triangle
s.
julia> cube
Mesh{3, Float64, Triangle}
How can I resolve this? Or are there any other solutions?