OpticSim.jl
OpticSim.jl copied to clipboard
traceMT transposes x and y coordinates/detector resolution
Describe the bug When simulating the same system with Vis.drawtraceimage(), trace() and traceMT, traceMT outputs a detector image with transposed x and y resolution.
To Reproduce
using OpticSim
using OpticSim.Vis
using OpticSim.Geometry
using OpticSim.Emitters
using OpticSim.GlassCat
raygenerator = Sources.Source(
origins=Origins.Point(0.0, 0.0, 0.0),
directions=Directions.RectGrid(pi/4, 0.01, 10, 1),
power=AngularPower.Lambertian()
)
detector_length = 10.0
detector_width = 5.0
x_resolution = 10
y_resolution = 5
working_distance = 10
detector = Rectangle(detector_length/2, detector_width/2, SVector(0.0, 0.0, -1.0), SVector(0.0, 0.0, working_distance), interface = opaqueinterface())
air_lens = OpticSim.transform(
Cuboid(detector_length/2, detector_width/2, 0.5, interface=FresnelInterface{Float64}(Air, Air)),
translation(0.0, 0.0, working_distance/2))
la = LensAssembly(air_lens())
sys = CSGOpticalSystem(la, detector, x_resolution, y_resolution)
Vis.drawtracerays(sys; raygenerator, trackallrays = true, test = false, verbose=true)
im_drawtraceimage = Vis.drawtraceimage(sys; raygenerator, test=false, verbose=true)
display(im_drawtraceimage)
resetdetector!(sys) # reset in case there was a previous run in an interactive session
im_trace = trace(sys, raygenerator; printprog = true, test = false)
display(im_trace)
resetdetector!(sys) # reset in case there was a previous run in an interactive session
im_traceMT = traceMT(sys, raygenerator; printprog = true, test = false)
display(im_traceMT)
outputs:
Drawing System...
Tracing...
Drawing Rays...
Completed in 0.0s
5×10 HierarchicalImage{Float32}:
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 2.0 1.0 1.0 2.0 1.0 1.0 2.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Finished tracing 10 rays in 0.0s
5×10 HierarchicalImage{Float32}:
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 2.0 1.0 1.0 2.0 1.0 1.0 2.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Initialising...
Tracing...
Accumulating images...
Finished tracing 10 rays in 0.0s,
10×5 HierarchicalImage{Float32}:
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
2.0 3.0 2.0 2.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
Expected behavior All three methods should output the same detector image of shape 5 x 10, where the rays hit along the longer axis. Instead, traceMT outputs a 10x5 image, where the rays hit along the short axis.
Desktop (please complete the following information): OpticSim v0.6.0