Raytracing a polygon mesh
julia
using Krang
import CairoMakie as CMk
using GeometryBasics
using FileIO
spin = 0.99
metric = Krang.Kerr(spin)
θo = 90/180*π
ρmax = 22.0
sze = 200
200
Import external mesh
julia
bunny_mesh = translate(
rotate(
scale(
load(download("https://graphics.stanford.edu/~mdfisher/Data/Meshes/bunny.obj", "bunny.obj")), 150
), 3π / 2, 0.0, 0.0, 1.0
), -10, -4, 0
)
fig = CMk.Figure()
ax = CMk.Axis3(fig[1,1], aspect=(1,1,1), elevation = π/2, azimuth = π)
CMk.mesh!(ax, bunny_mesh, color=[parse(CMk.Colorant, "rgba(0%, 50%, 70%,1.0)") for tri in bunny_mesh.position], colormap = :blues, transparency=true, shading=true)
fig
save("stanford_bunny.png", fig)
┌ Warning: `shading = true` is not valid. Use `Makie.automatic`, `NoShading`, `FastShading` or `MultiLightShading`. Defaulting to `MakieCore.Automatic()`.
└ @ Makie ~/.julia/packages/Makie/gG38B/src/lighting.jl:243
Raytrace the mesh embedded in the Kerr space time with additive blending The mesh is embedded in the space-time by assuming the world coordinates of the mesh is the same as the Cartesian coordinates that would be generated from Boyer-Lindquist coordinates.
julia
camera = Krang.IntensityCamera(metric, θo, -ρmax, ρmax, -ρmax, ρmax, sze)
intersections = raytrace(camera, bunny_mesh)'
fig = CMk.Figure()
ax = CMk.Axis(fig[1,1], aspect=1, xreversed=true)
CMk.heatmap!(ax, intersections)
fig
save("mesh_geometry_example.png", fig)
This page was generated using Literate.jl.