33"""
44abstract type AbstractLevelSetGeometry{T} <: AbstractGeometry end
55
6- function _raytrace (
6+ @inline function _raytrace (
77 observation:: A ,
88 pixel:: AbstractPixel{T} ,
99 mesh:: Mesh{<:AbstractLevelSetGeometry,<:AbstractMaterial} ;
1010 res = 100 ,
1111) where {A,T}
1212 geometry = mesh. geometry
1313 material = mesh. material
14- ray = Vector {Intersection{T}} (undef, res)
15- generate_ray! (ray, pixel, res)
16- (; rs, θs, ϕs, νr, νθ) = ray[1 ]
17- origin =
18- boyer_lindquist_to_quasi_cartesian_kerr_schild_fast_light (pixel. metric, rs, θs, ϕs)
19- z = zero (A)
20- for i = 1 : res
21- (; ts, rs, θs, ϕs, νr, νθ) = ray[i]
22- if rs <= Krang. horizon (pixel. metric) || iszero (rs)
23- continue
24- end
25- line_point_2 = boyer_lindquist_to_quasi_cartesian_kerr_schild_fast_light (
26- pixel. metric,
27- rs,
28- θs,
29- ϕs,
30- )
31- if isinf (line_point_2[1 ]) || isinf (line_point_2[2 ]) || isinf (line_point_2[3 ])
32- continue
33- end
34- didintersect, point = line_intersection (origin, line_point_2, geometry)
35- rs = sqrt (sum (point .^ 2 ))
36- θs = acos (point[3 ] / rs)
37- ϕs = ϕ_BL (pixel. metric, rs, atan (point[2 ], point[1 ]))
14+ τf = Krang. total_mino_time (pixel)
15+ Δτ = τf / res - eps ()
16+ origin_bl = 1e100 ,pixel. θo, 0.0 , true , true
17+ for i in 1 : res
18+ τref = Δτ* i
19+ τ = Krang. line_intersection (pixel, origin_bl, Δτ* (i- 1 ), τref, geometry)
20+ rs, θs, ϕs, νr, νθ = Krang. emission_coordinates_fast_light (pixel, τ)
3821
3922 if rs < Krang. horizon (pixel. metric)
4023 continue
4124 end
4225
43- intersection = Intersection (ts, rs, θs, ϕs, νr, νθ)
44- observation += ! didintersect ? z : material (pixel, intersection)# didintersect ? 1 : 0
45- origin = line_point_2
26+ intersection = Krang. Intersection (0.0 , rs, θs, ϕs, νr, νθ)
27+ observation += τ == 0 ? T (0 ) : material (pixel, intersection)# didintersect ? 1 : 0
28+ origin_bl = Krang. emission_coordinates_fast_light (pixel, τref)
29+
4630 end
4731 return observation
4832end
4933
5034@inline function line_intersection (
51- origin:: NTuple{3,T} ,
52- line_point_2,
53- geometry:: AbstractLevelSetGeometry{T} ,
35+ pixel:: Krang.AbstractPixel ,
36+ origin_bl,
37+ τi:: T ,
38+ τf:: T ,
39+ geometry:: Krang.AbstractLevelSetGeometry{T} ,
5440) where {T}
55- didintersect = geometry (origin... ) * geometry (line_point_2... ) <= zero (T)
41+ origin = Krang. boyer_lindquist_to_quasi_cartesian_kerr_schild_fast_light (pixel. metric, origin_bl[1 : 3 ]. .. )
42+ line_point_2_bl = Krang. emission_coordinates_fast_light (pixel, τf)
43+ line_point_2 = Krang. boyer_lindquist_to_quasi_cartesian_kerr_schild_fast_light (pixel. metric, line_point_2_bl[1 : 3 ]. .. )
44+ geo_origin = geometry (origin... )
45+ didintersect = geo_origin * geometry (line_point_2... ) <= zero (T)
5646 if didintersect
57- direction = (
58- line_point_2[1 ] - origin[1 ],
59- line_point_2[2 ] - origin[2 ],
60- line_point_2[3 ] - origin[3 ],
61- )
62-
63- t = find_zero ((x) -> geometry ((origin .+ (direction .* x)). .. ), (zero (T), one (T)))
64-
65- return true , origin .+ (direction .* t)
47+ t = Krang. Roots. find_zero ((x) -> x == zero (T) ? geo_origin : geometry (Krang. boyer_lindquist_to_quasi_cartesian_kerr_schild_fast_light (pixel. metric, Krang. emission_coordinates_fast_light (pixel, x)[1 : 3 ]. .. )... ), (τi, τf))
48+ return t
6649 end
67- return false , (zero (T), zero (T), zero (T))
68-
69- end
50+ return zero (T)
51+ end
0 commit comments