static int process_ray_1 (AcisSim_Ray_Type *ray, AcisSim_Pixel_Event_Type *event, double abs_coeff) { double depth; double energy = ray->energy; depth = compute_depth (abs_coeff); if (depth >= Total_Thickness) return -1; /* Routines that this call assumes that this structure has been zeroed. */ memset ((char *) event, 0, sizeof (AcisSim_Pixel_Event_Type)); /* Does this photon give rise to a fluorescent photon? */ if (0 != (event->did_fluoresc = ((energy > Fluor_Absorbtion_Energy) && (Fluor_Emission_Prob >= JDMrandom ())))) { /* If it fluoresced, then we also need to consider what happened to * the leftover energy. */ energy -= Fluor_Absorbtion_Energy; if (0 == handle_fluorescent_photon (ray, Fluor_Emission_Energy, depth, &event->fluoresc_island)) event->flags |= FLUOR_EVENT_OK; } if (0 == handle_regular_event (ray, energy, depth, &event->regular_island)) event->flags |= REGULAR_EVENT_OK; if (event->flags & (REGULAR_EVENT_OK | FLUOR_EVENT_OK)) return 0; return -1; }
/************************************************************************* * Compute the maximum depth of a tree. *************************************************************************/ int compute_depth (TREE_T * const a_tree) { /* Base case: leaf. */ if (is_leaf(a_tree)) { return(1); } /* Recursive case: internal node. */ else { int max_depth = 0; int num_children = get_num_children(a_tree); int i_child; for (i_child = 0; i_child < num_children; i_child++) { int this_depth = compute_depth(get_nth_child(i_child, a_tree)); if (this_depth > max_depth) { max_depth = this_depth; } } return(max_depth + 1); } /* Unreachable. */ abort(); return(0); }
Point3f Reprojector::reproject_to_3d(float pt0_x, float pt0_y, float pt1_x, float pt1_y) { float disparity_val = abs(pt1_x - pt0_x); float depth = compute_depth(disparity_val); Point2f plane_size = compute_plane_size(depth); float half_plane_width = plane_size.x / 2; float halfPlaneHeight = plane_size.y / 2; float real_x = map_val(pt0_x, 0, WIDTH_LARGE, -half_plane_width, half_plane_width); float real_y = map_val(pt0_y, 0, HEIGHT_LARGE, -halfPlaneHeight, halfPlaneHeight); return Point3f(real_x * 10, real_y * 10, depth * 10); }
void Tree::refresh() { compute_size(); compute_depth(); compute_height(); compute_hash(); }