@@ -194,12 +194,19 @@ def back_trans_point(
194194 -------
195195 A numpy array representing the position of the point in the camera coordinate system.
196196 """
197+ glass_direction = np .array ([glass .vec_x , glass .vec_y , glass .vec_z ], dtype = np .float64 )
198+
199+ return fast_back_trans_point (glass_direction , mm .d [0 ], cross_c , cross_p , pos_t )
200+
201+ @njit
202+ def fast_back_trans_point (glass_direction : np .ndarray , d : float , cross_c , cross_p , pos_t ) -> np .ndarray :
203+ """Run numba faster version of back projection."""
197204 # Calculate the glass direction vector
198- glass_direction = np . array ([ glass . vec_x , glass . vec_y , glass . vec_z ])
199- norm_glass_direction = np .linalg .norm (glass_direction )
205+
206+ norm_glass_direction = float ( np .linalg .norm (glass_direction ) )
200207
201208 # Normalize the glass direction vector
202- renorm_glass = glass_direction * (mm . d [ 0 ] / norm_glass_direction )
209+ renorm_glass = glass_direction * (d / norm_glass_direction )
203210
204211 # Calculate the position of the point after passing through the glass
205212 after_glass = cross_c - renorm_glass
@@ -222,9 +229,7 @@ def back_trans_point(
222229
223230 return pos
224231
225- # @njit
226-
227-
232+ @njit
228233def move_along_ray (glob_z : float , vertex : np .ndarray , direct : np .ndarray ) -> np .ndarray :
229234 """Move along the ray to the global z plane.
230235
@@ -369,7 +374,7 @@ def fast_get_mmf_from_mmlut(
369374 iz = int (sz )
370375 sz -= iz
371376
372- R = np .linalg .norm (np .array ([temp [0 ], temp [1 ], 0 ]))
377+ R = float ( np .linalg .norm (np .array ([temp [0 ], temp [1 ], 0 ]) ))
373378 sr = R / rw
374379 ir = int (sr )
375380 sr -= ir
0 commit comments