Selection utilities
napari_threedee.utils.selection_utils
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_triangle_from_click(click_point: np.ndarray, view_direction: np.ndarray, triangles: np.ndarray)
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.
PARAMETER | DESCRIPTION |
---|---|
click_point
|
(3,) array containing the location that was clicked. This should be in the same coordinate system as the vertices.
TYPE:
|
view_direction
|
(3,) array describing the direction camera is pointing in the scene. This should be in the same coordinate system as the vertices.
TYPE:
|
triangles
|
(n, 3, 3) array containing the coordinates for the 3 corners of n triangles.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
in_triangles
|
(n,) boolean array that is True of the ray intersects the triangle
TYPE:
|
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 |
|
select_sphere_from_click(click_point: np.ndarray, view_direction: np.ndarray, sphere_centroids: np.ndarray, sphere_diameter: float) -> Optional[int]
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.
PARAMETER | DESCRIPTION |
---|---|
click_point
|
The point where the click ray originates.
TYPE:
|
view_direction
|
The unit vector pointing in the direction the viewer is looking.
TYPE:
|
sphere_centroids
|
The (n, 3) array of center points for the n points.
TYPE:
|
sphere_diameter
|
The diameter of all spheres. Must the same diameter for all spheres.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
selection
|
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 |
|