@@ -329,17 +329,19 @@ def progress_callback(progress_percent : int, step_description : str): # noqa: A
329329 points_asl = np .zeros ((num_search_points ,3 ), dtype = float ) # search grid points in ASL coordinates
330330 normals_asl = np .zeros ((num_search_points ,3 ), dtype = float ) # normal vector of the plane that is fitted at each point, in ASL coordinates
331331
332+ # Pre-build plane fitting grid that will be used repeatedly in the search loop below.
333+ # This grid lives in the spherical coordinate basis theta-phi plane at each point.
334+ # Below we will project it onto the skin surface for each search point.
335+ dtheta_sequence = np .arange (- planefit_dyaw_extent , planefit_dyaw_extent + planefit_dyaw_step , planefit_dyaw_step )
336+ dphi_sequence = np .arange (- planefit_dpitch_extent , planefit_dpitch_extent + planefit_dpitch_step , planefit_dpitch_step )
337+ dtheta_grid , dphi_grid = np .meshgrid (dtheta_sequence , dphi_sequence , indexing = 'ij' )
338+
332339 for i in range (num_search_points ):
333340 theta_rad , phi_rad = thetas [i ]* np .pi / 180 , phis [i ]* np .pi / 180
334341
335342 # Cartesian coordinate location of the point at which we are fitting a plane
336343 point = np .array (spherical_to_cartesian (skin_interpolator (theta_rad , phi_rad ), theta_rad , phi_rad ))
337344
338- # Build plane fitting grid in the spherical coordinate basis theta-phi plane, which we will later project back onto the skin surface
339- dtheta_sequence = np .arange (- planefit_dyaw_extent , planefit_dyaw_extent + planefit_dyaw_step , planefit_dyaw_step )
340- dphi_sequence = np .arange (- planefit_dpitch_extent , planefit_dpitch_extent + planefit_dpitch_step , planefit_dpitch_step )
341- dtheta_grid , dphi_grid = np .meshgrid (dtheta_sequence , dphi_sequence , indexing = 'ij' )
342-
343345 r_hat , theta_hat , phi_hat = spherical_coordinate_basis (theta_rad ,phi_rad )
344346 planefit_points_unprojected_cartesian = (
345347 point .reshape ((1 ,1 ,3 ))
0 commit comments