napari utilities
data_to_world_normal(vector, layer)
Convert a normal vector defining an orientation from data coordinates to world coordinates. For example, this would be used to a plane normal.
https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/geometry/transforming-normals.html
Parameters
vector : tuple, list, 1D array A vector in data coordinates. layer : napari.layers.BaseLayer The napari layer to get the transform from.
Returns
np.ndarray Transformed vector in data coordinates. This returns a unit vector.
Source code in src/napari_threedee/utils/napari_utils.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
data_to_world_ray(vector, layer)
Convert a vector defining an orientation from data coordinates to world coordinates. For example, this would be used to convert the view ray.
Parameters
vector : tuple, list, 1D array A vector in data coordinates. layer : napari.layers.BaseLayer The napari layer to get the transform from.
Returns
np.ndarray Transformed vector in data coordinates.
Source code in src/napari_threedee/utils/napari_utils.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
get_mouse_position_in_displayed_dimensions(event)
Get the position under the mouse in scene (displayed world) coordinates.
Parameters
event The mouse event.
Returns
click_dir_data_3d : np.ndarray The click direction in displayed data coordiantes
Source code in src/napari_threedee/utils/napari_utils.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
get_mouse_position_in_displayed_layer_data_coordinates(layer, event)
Get the mouse click position and direction in layer data displayed coordinates.
Parameters
layer : napari.layers.Layer The layer to convert the coordinates to. event The mouse event.
Returns
click_position_data_3d : np.ndarray The click position in displayed data coordinates. click_dir_data_3d : np.ndarray The click direction in displayed data coordiantes
Source code in src/napari_threedee/utils/napari_utils.py
131 132 133 134 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 |
|
get_napari_visual(viewer, layer)
Get the visual class for a given layer
Parameters
viewer The napari viewer object layer The napari layer object for which to find the visual.
Returns
visual The napari visual class for the layer.
Source code in src/napari_threedee/utils/napari_utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
get_view_direction_in_displayed_dimensions(event)
Get the view direction under the mouse in scene (displayed world) coordinates.
Parameters
event: Event napari mouse event.
Source code in src/napari_threedee/utils/napari_utils.py
119 120 121 122 123 124 125 126 127 128 |
|
get_vispy_layer_node(viewer, layer)
Get the vispy node associated with a layer
Source code in src/napari_threedee/utils/napari_utils.py
43 44 45 46 47 48 49 50 |
|
get_vispy_root_node(viewer, layer)
Get the vispy node at the root of the scene graph.
This is the node that layers are added to.
Source code in src/napari_threedee/utils/napari_utils.py
53 54 55 56 57 58 59 60 61 |
|
world_to_data_normal(vector, layer)
Convert a normal vector defining an orientation from world coordinates to data coordinates. For example, this would be used to a plane normal.
https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/geometry/transforming-normals.html
Parameters
vector : tuple, list, 1D array A vector in world coordinates. layer : napari.layers.BaseLayer The napari layer to get the transform from.
Returns
np.ndarray Transformed vector in data coordinates. This returns a unit vector.
Source code in src/napari_threedee/utils/napari_utils.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|