Selection utilities
distance_between_point_and_line_segment_2d(p, p1, p2)
Calculate the distance between a point p and a line segment p1, p2
Source code in src/napari_threedee/utils/selection_utils.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
select_sphere_from_click(click_point, view_direction, sphere_centroids, sphere_diameter)
Determine which, if any spheres are intersected by a click ray.
If multiple spheres are intersected, the closest sphere to the click point (ray start) will be returned.
Parameters
click_point : np.ndarray The point where the click ray originates. view_direction : np.ndarray The unit vector pointing in the direction the viewer is looking. sphere_centroids : np.ndarray The (n, 3) array of center points for the n points. sphere_diameter : float The diameter of all spheres. Must the same diameter for all spheres.
Returns
selection : Optional[int] The index for the sphere that was intersected. Returns None if no spheres are intersected.
Source code in src/napari_threedee/utils/selection_utils.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
select_triangle_from_click(click_point, view_direction, triangles)
Determine if a line goes through any of a set of triangles.
For example, this could be used to determine if a click was in a triangle of a mesh.
Parameters
click_point : np.ndarray (3,) array containing the location that was clicked. This should be in the same coordinate system as the vertices. view_direction : np.ndarray (3,) array describing the direction camera is pointing in the scene. This should be in the same coordinate system as the vertices. triangles : np.ndarray (n, 3, 3) array containing the coordinates for the 3 corners of n triangles.
Returns
in_triangles : np.ndarray (n,) boolean array that is True of the ray intersects the triangle
Source code in src/napari_threedee/utils/selection_utils.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|