routing.core.functions#
Base file for storing all useful functions.
- routing.core.functions.build_frame(node: tuple[float, float, float], next_node: tuple[float, float, float]) ndarray[source]#
Build a standard default frame from two points.
- routing.core.functions.build_frame_from_vector(node: ndarray, vector: ndarray) ndarray[source]#
Build a standard default frame from origin node and main axis vector.
- routing.core.functions.build_frame_vectorized(node: ndarray, next_node: ndarray) ndarray[source]#
Build a standard default frame from two points (vectorized).
- routing.core.functions.build_local_block(local_points: ndarray, frame: Frame3D, size: float) Block[source]#
Build a local block from points and a frame with given size.
- routing.core.functions.build_voxel_primitive(voxels: MatrixBasedVoxelization, frame: Frame3D | None = None, name: str = '') Primitive3D[source]#
Build a 3D primitive from voxelization with optional frame transformation.
- routing.core.functions.compress_array(array: ndarray | Array | None) Array | None[source]#
Compress a numpy array using zarr with Blosc compression.
- routing.core.functions.coord_to_voxel_index(point: tuple[float, float, float], voxel_origin: tuple[float, float, float], voxel_size: float) tuple[int, int, int][source]#
Gives the voxel containing a point.
- routing.core.functions.coord_to_voxel_index_continuous(point: tuple[float, float, float], voxel_origin: tuple[float, float, float], voxel_size: float) tuple[float, float, float][source]#
Gives the voxel containing a point.
- routing.core.functions.dot(a: tuple, b: tuple) float[source]#
Compute the dot product of two 3D vectors.
- routing.core.functions.extract_point_carrier_voxels(voxels: MatrixBasedVoxelization, point: ndarray) MatrixBasedVoxelization[source]#
Get the connex MatrixBasedVoxelization that carry a point from a non-connex MatrixBasedVoxelization.
- routing.core.functions.filter_voxels_by_axis_range(voxels: ndarray, axis: int, min_val: float, max_val: float) ndarray[source]#
Filter voxels by coordinate range on a specified axis (0=x, 1=y, 2=z).
- routing.core.functions.filter_voxels_by_x_range(voxels: ndarray, x_min: float, x_max: float) ndarray[source]#
Filter voxels by x-coordinate range.
- routing.core.functions.filter_voxels_by_y_range(voxels: ndarray, y_min: float, y_max: float) ndarray[source]#
Filter voxels by y-coordinate range.
- routing.core.functions.filter_voxels_by_z_range(voxels: ndarray, z_min: float, z_max: float) ndarray[source]#
Filter voxels by z-coordinate range.
- routing.core.functions.from_bounding_rectangles(bounding_rectangles: list[BoundingRectangle], name: str = '') BoundingRectangle[source]#
Create a bounding rectangle that contains multiple bounding rectangles.
- Parameters:
bounding_rectangles – A list of bounding rectangles that need to be contained.
name – A name for the bounding rectangles, optional.
- Returns:
A new bounding rectanglesthat contains all the input bounding rectangles.
- routing.core.functions.get_all_neighbors(index: tuple[int, int, int], diagonal: bool = False) list[tuple[int, int, int]][source]#
Gives all neighbors of a node.
- routing.core.functions.get_bounding_rectangle(center: tuple[float, float], radius: float) BoundingRectangle[source]#
Compute the bounding rectangle for a circle.
- Args:
center (tuple): The (x, y) center of the circle. radius (float): Radius of the circle.
- Returns:
BoundingRectangle: The bounding box around the circle.
- routing.core.functions.get_crossed_voxels(weights: ndarray, node1: tuple[int, int, int], node2: tuple[int, int, int]) ndarray[source]#
Get all crossed voxels by a line segment from node1 to node2 (Cython-optimized).
Uses the compiled version internally for consistency and performance. Returns [node1] + intermediate voxels.
- routing.core.functions.get_direction(start: ndarray, end: ndarray) tuple[ndarray, float, ndarray][source]#
Get vector, length and unit_vector of a vector defined with start and end points.
- routing.core.functions.get_nearest_active_voxel(coord: tuple[float, float, float], voxels: MatrixBasedVoxelization) tuple[int, int, int][source]#
Get the nearest voxel with nonnull weight from coordinates.
- routing.core.functions.get_node_neighbors_coords(coords: tuple[float, float, float], weights: ndarray, prospect_distance: float = 3) list[tuple[int, int, int]][source]#
Get all voxels neighboring a point at max prospect_distance with distance computation.
- routing.core.functions.get_node_neighbors_index(index: tuple[int, int, int], weights: ndarray | None = None, prospect_distance: int = 3) list[tuple[int, int, int]][source]#
Get all voxels neighboring a voxel at max prospect_distance (in voxels) without computing distances.
- routing.core.functions.get_voxels_in_bounding_box(voxels: list[tuple[int, int, int]]) list[tuple[int, int, int]][source]#
Compute all voxel coordinates inside the axis-aligned bounding box that contains all crossed voxels.
- routing.core.functions.h_coord(coords: ndarray) ndarray[source]#
Convert coordinates to homogeneous coordinates by adding a row of ones.
- routing.core.functions.invert_frame(frame: ndarray) ndarray[source]#
Invert a HTM frame with inverse movement instead of inverse matrix.
- routing.core.functions.merge_intersection_faces(faces: list[dict[Any, list]]) list[source]#
Merge intersection faces from a list of face dictionaries.
- routing.core.functions.point_to_local_frame(point: ndarray, frame: ndarray) ndarray[source]#
Project a point into a new frame.
- routing.core.functions.points_to_homogeneous_matrix(points: list) ndarray[source]#
Convert a list of points to a homogeneous transformation matrix.
- routing.core.functions.points_to_local_frames(points: ndarray, frames: list[ndarray]) list[ndarray][source]#
Project a list of points into a list of frames.
- routing.core.functions.reduce_cylinder_radius_3d_fast(voxel_indices: ndarray, radius_reduction: int = 2) ndarray[source]#
Fast version using 6-connectivity (direct neighbors only). Faster but erosion is less round.
- routing.core.functions.set_primitives_name(primitives: list[Primitive3D], name: str) None[source]#
Add an indexed name to primitives when a name is defined as argument.
- routing.core.functions.tensor_to_non_zero_indices(ndarray: ndarray) ndarray[source]#
Get matrix of all non-seros elements in ndarray.
- routing.core.functions.unflat_coords(flatten_coords: ndarray) ndarray[source]#
Get a matrix of shape (n_points, 3) from a vector of flatten coords (shape (3.n_points, )).