Raytracing a Level Set geometry
A level set geoemtry is defined by a constraint equations
using Krang
import CairoMakie as GLMk
using GeometryBasics
using FileIO
Lets create a camera with a screen of 20Mx20M at a resolution of 200x200 pixels for a high spin black hole.
metric = Krang.Kerr(0.9) # Kerr metric with a spin of 0.99
θo = 89 / 180 * π # Inclination angle of the observer
ρmax = 20.0 # Horizontal and Vertical extent of the screen
sze = 200 # Resolution of the screen is sze x sze
camera = Krang.SlowLightIntensityCamera(metric, θo, -ρmax, ρmax, -ρmax, ρmax, sze)
SlowLightIntensityCamera{Float64, Matrix{Krang.SlowLightIntensityPixel{Float64}}}(Kerr{Float64}(1.0, 0.9), Krang.SlowLightIntensityScreen{Float64, Matrix{Krang.SlowLightIntensityPixel{Float64}}}((-20.0, 20.0), (-20.0, 20.0), Krang.SlowLightIntensityPixel{Float64}[Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (-20.0, -20.0), (-29.18861423266478 - 3.3537505426307734e-17im, 0.24263747362939725 + 1.5063696195576235e-15im, 1.6782502513720612 - 1.5168879528449595e-15im, 27.26772650766332 + 4.4055838713643797e-17im), 0.058204597315845714, 0.11640919463169143, 2.842209106471304, 16.713342732597273, -2.688591622641137, -22.121051943139634, -0.2387349764137514, -0.05085597634204857, (0.0008725762173162735, 0.11108611795829751), (0.0008726648323428316, 0.1571597798655397), (8.859883935894616e-8, 0.027792278379919516), 1.5533430342749532, 400.1215878811236, 19.996953903127825) Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (-20.0, -19.798994974874372), (-29.046130530864428 - 3.396586734596297e-17im, 0.23992633257421048 + 1.5139444112783999e-15im, 1.6801710889137595 - 1.5246539812970533e-15im, 27.126033109376458 + 4.4675437364616284e-17im), 0.058511821788351674, 0.11702364357670335, 2.829149170490956, 16.62807951011331, -2.6838951582860844, -22.009265777746894, -0.2380889068451399, -0.05102660372461329, (0.0008814330369263448, 0.11164630991360983), (0.0008815225514868533, 0.1571606342452944), (8.949825967173883e-8, 0.027650748247351434), 1.5533430342749532, 392.12178989622424, 19.996953903127825) … Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (-20.0, 19.79899497487437), (-29.046130530864424 - 5.660977890993818e-17im, 0.23992633257421225 + 2.5232406854640003e-15im, 1.6801710889137578 - 2.541089968828422e-15im, 27.126033109376458 + 7.445906227436015e-17im), 0.05851182178835167, 0.11702364357670333, 2.829149170490981, 16.628079510113224, -2.6838951582860844, -22.00926577774689, -0.23808890684514158, -0.051026603724613366, (0.0008814330369263448, 0.11164630991360983), (0.0008815225514868533, 0.1571606342452944), (8.94982596717388e-8, 0.02765074824735143), 1.5533430342749532, 392.12178989622413, 19.996953903127825) Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (-20.0, 20.0), (-29.18861423266478 - 3.3537505426307734e-17im, 0.24263747362939725 + 1.5063696195576235e-15im, 1.6782502513720612 - 1.5168879528449595e-15im, 27.26772650766332 + 4.4055838713643797e-17im), 0.058204597315845714, 0.11640919463169143, 2.842209106471304, 16.713342732597273, -2.688591622641137, -22.121051943139634, -0.2387349764137514, -0.05085597634204857, (0.0008725762173162735, 0.11108611795829751), (0.0008726648323428316, 0.1571597798655397), (8.859883935894616e-8, 0.027792278379919516), 1.5533430342749532, 400.1215878811236, 19.996953903127825); Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (-19.798994974874372, -20.0), (-29.04667442643992 - 5.620168701301023e-17im, 0.2455036370048358 + 2.523263671940176e-15im, 1.675479817403053 - 2.5409933970922264e-15im, 27.125690972032032 + 7.393141216506084e-17im), 0.0585127014633823, 0.1170254029267646, 2.862808515454489, 16.53112101059466, -2.6836041693004997, -22.009244028105655, -0.24278256678878965, -0.05124865853146545, (0.0008725779887162399, 0.11164544500936019), (0.0008726666038507306, 0.15875559314344628), (8.859893464598423e-8, 0.02821414139636405), 1.5533430342749532, 400.119151250731, 19.795979492041113) Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (-19.798994974874372, -19.798994974874372), (-28.903465533074666 - 4.554069334429162e-17im, 0.24278493795946865 + 2.028864804304035e-15im, 1.6774010304357851 - 2.043308917623845e-15im, 26.983279564679414 + 5.998480666410165e-17im), 0.05882477803349028, 0.11764955606698056, 2.8495247188392474, 16.44584142166779, -2.6788597952709816, -21.896887621703385, -0.24211632989261653, -0.05142307125008821, (0.0008814348628136387, 0.11221418496573957), (0.0008815243774853934, 0.15875646935648066), (8.949835052185238e-8, 0.02807475914547245), 1.5533430342749532, 392.11935326583165, 19.795979492041113) … Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (-19.798994974874372, 19.79899497487437), (-28.903465533074666 - 6.831104001643743e-17im, 0.24278493795946865 + 3.0432972064560527e-15im, 1.677401030435787 - 3.064963376435768e-15im, 26.983279564679407 + 8.997720999615297e-17im), 0.058824778033490295, 0.11764955606698059, 2.8495247188392216, 16.445841421667872, -2.6788597952709816, -21.896887621703385, -0.24211632989261478, -0.05142307125008814, (0.0008814348628136387, 0.11221418496573957), (0.0008815243774853934, 0.15875646935648066), (8.949835052185236e-8, 0.028074759145472448), 1.5533430342749532, 392.11935326583153, 19.795979492041113) Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (-19.798994974874372, 20.0), (-29.04667442643992 - 5.620168701301023e-17im, 0.2455036370048358 + 2.523263671940176e-15im, 1.675479817403053 - 2.5409933970922264e-15im, 27.125690972032032 + 7.393141216506084e-17im), 0.0585127014633823, 0.1170254029267646, 2.862808515454489, 16.53112101059466, -2.6836041693004997, -22.009244028105655, -0.24278256678878965, -0.05124865853146545, (0.0008725779887162399, 0.11164544500936019), (0.0008726666038507306, 0.15875559314344628), (8.859893464598423e-8, 0.02821414139636405), 1.5533430342749532, 400.119151250731, 19.795979492041113); … ; Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (19.79899497487437, -20.0), (-29.128240280734634 - 3.883554476108743e-17im, 0.21837642095379906 + 1.5135074544035291e-15im, 1.8853709532469747 - 1.5271231514258879e-15im, 27.024492906533858 + 5.2451241783446053e-17im), 0.05879884589130818, 0.11759769178261636, -1.9202145530008077, 35.13234099808301, -2.6902914744750386, -21.99200756721406, -0.12936412407862471, -0.043088853064723216, (0.0008725779887162401, 0.1116454450093602), (0.0008726666038507307, 0.1587555931434463), (8.859893464598426e-8, 0.028214141396364058), 1.5533430342749532, 400.119151250731, -19.79597949204111) Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (19.79899497487437, -19.798994974874372), (-28.98582637222651 - 6.558180941455047e-17im, 0.21578789375665863 + 2.535313423752978e-15im, 1.889058637744217 - 2.558457684510264e-15im, 26.880979840725633 + 8.872607017183627e-17im), 0.05911717902306508, 0.11823435804613017, -1.9101643225947527, 34.98214343390364, -2.685628082722018, -21.87937882669745, -0.128986050550292, -0.04318985552253318, (0.0008814348628136387, 0.11221418496573957), (0.0008815243774853934, 0.15875646935648066), (8.949835052185236e-8, 0.028074759145472448), 1.5533430342749532, 392.11935326583165, -19.79597949204111) … Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (19.79899497487437, 19.79899497487437), (-28.98582637222651 - 6.558180941455047e-17im, 0.21578789375665863 + 2.535313423752978e-15im, 1.889058637744217 - 2.558457684510264e-15im, 26.880979840725633 + 8.872607017183627e-17im), 0.05911717902306508, 0.11823435804613017, -1.9101643225947527, 34.98214343390364, -2.685628082722018, -21.87937882669745, -0.128986050550292, -0.04318985552253318, (0.0008814348628136387, 0.11221418496573957), (0.0008815243774853934, 0.15875646935648066), (8.949835052185236e-8, 0.028074759145472448), 1.5533430342749532, 392.11935326583153, -19.79597949204111) Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (19.79899497487437, 20.0), (-29.128240280734634 - 3.883554476108743e-17im, 0.21837642095379906 + 1.5135074544035291e-15im, 1.8853709532469747 - 1.5271231514258879e-15im, 27.024492906533858 + 5.2451241783446053e-17im), 0.05879884589130818, 0.11759769178261636, -1.9202145530008077, 35.13234099808301, -2.6902914744750386, -21.99200756721406, -0.12936412407862471, -0.043088853064723216, (0.0008725779887162401, 0.1116454450093602), (0.0008726666038507307, 0.1587555931434463), (8.859893464598426e-8, 0.028214141396364058), 1.5533430342749532, 400.119151250731, -19.79597949204111); Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (20.0, -20.0), (-29.270222058152335 - 6.430986063777065e-17im, 0.21591257735939706 + 2.5098773115862156e-15im, 1.8877216183686318 - 2.5322909829522873e-15im, 27.166587862424308 + 8.67235320038425e-17im), 0.05848754042092072, 0.11697508084184144, -1.9130627162826508, 35.235421819378814, -2.6952215152803585, -22.10390761986673, -0.12801015873373894, -0.042789610368982246, (0.0008725762173162735, 0.11108611795829751), (0.0008726648323428316, 0.1571597798655397), (8.859883935894616e-8, 0.027792278379919516), 1.5533430342749532, 400.1215878811236, -19.996953903127825) Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (20.0, -19.798994974874372), (-29.128525886907646 - 3.909143401421816e-17im, 0.21333429615515165 + 1.5134916299043445e-15im, 1.891386614223805 - 1.5272047153813409e-15im, 27.02380497652869 + 5.280451949121466e-17im), 0.05880088640203578, 0.11760177280407157, -1.903151806989317, 35.08629558338402, -2.6906044419738793, -21.99185337797064, -0.12764086166099958, -0.042888602408412045, (0.0008814330369263448, 0.11164630991360983), (0.0008815225514868533, 0.1571606342452944), (8.949825967173883e-8, 0.027650748247351434), 1.5533430342749532, 392.12178989622424, -19.996953903127825) … Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (20.0, 19.79899497487437), (-29.128525886907646 - 1.3030478004739338e-17im, 0.2133342961551552 + 5.04497209968115e-16im, 1.8913866142237996 - 5.09068238460447e-16im, 27.023804976528687 + 1.7601506497071388e-17im), 0.05880088640203577, 0.11760177280407154, -1.9031518069893458, 35.086295583384114, -2.6906044419738793, -21.991853377970628, -0.12764086166100105, -0.04288860240841221, (0.0008814330369263448, 0.11164630991360983), (0.0008815225514868533, 0.1571606342452944), (8.94982596717388e-8, 0.02765074824735143), 1.5533430342749532, 392.12178989622413, -19.996953903127825) Krang.SlowLightIntensityPixel{Float64}(Kerr{Float64}(1.0, 0.9), (20.0, 20.0), (-29.270222058152335 - 6.430986063777065e-17im, 0.21591257735939706 + 2.5098773115862156e-15im, 1.8877216183686318 - 2.5322909829522873e-15im, 27.166587862424308 + 8.67235320038425e-17im), 0.05848754042092072, 0.11697508084184144, -1.9130627162826508, 35.235421819378814, -2.6952215152803585, -22.10390761986673, -0.12801015873373894, -0.042789610368982246, (0.0008725762173162735, 0.11108611795829751), (0.0008726648323428316, 0.1571597798655397), (8.859883935894616e-8, 0.027792278379919516), 1.5533430342749532, 400.1215878811236, -19.996953903127825)]), (Inf, 1.5533430342749532))
We will define a parabaloid geometry to the set of all points satisfied by the equation
struct Parabaloid{T} <: Krang.AbstractLevelSetGeometry{T}
rh::T
index::T
end
function (geometry::Parabaloid)(x, y, z)
r = sqrt(x^2 + y^2 + z^2)
return 1 - (r / geometry.rh)^geometry.index * (1 - z / r)
end
The jet will be emit a constant intensity whose physics we define in the XMaterial
.
We are ignoring relativistic effects in this example.
struct XMaterial <: Krang.AbstractMaterial end
function (mat::XMaterial)(pix, intersection)
return 1.0
end
We will ray trace the geometry and plot the image.
parabaloid = Parabaloid(Krang.horizon(metric), 1.0)
fig = GLMk.Figure();
ax = GLMk.Axis(fig[1, 1], aspect = 1)
intersections = raytrace(camera, Krang.Mesh(parabaloid, XMaterial()), res = 1_00);
And plot the image with GLMakie,
GLMk.heatmap!(ax, intersections, colormap = :afmhot);
fig
GLMk.save("geometric_jet.png", fig)
CairoMakie.Screen{IMAGE}
This page was generated using Literate.jl.