Geometric
geometric
¶
Functions¶
angle_between(v1, v2)
¶
Returns the angle in radians between vectors 'v1' and 'v2'::
angle_between((1, 0, 0), (0, 1, 0)) 1.5707963267948966 angle_between((1, 0, 0), (1, 0, 0)) 0.0 angle_between((1, 0, 0), (-1, 0, 0)) 3.141592653589793
Source code in geograypher/utils/geometric.py
batched_unary_union(geometries, batch_size, grid_size=None, subsequent_batch_size=4, sort_by_loc=False, simplify_tol=0, verbose=False)
¶
Roughly replicate the functionality of shapely.unary_union using a batched implementation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometries
|
List[Geometry]
|
Geometries to aggregate |
required |
batch_size
|
int
|
The batch size for the first aggregation |
required |
grid_size
|
Union[None, float]
|
grid size passed to unary_union |
None
|
subsequent_batch_size
|
int
|
The batch size for subsequent (recursive) batches. Defaults to 4. |
4
|
sort_by_loc
|
bool
|
Should the polygons be sorted by location to have a higher likelihood of merging. Defaults to False. |
False
|
simplify_tol
|
float
|
How much to simplify in intermediate steps |
0
|
verbose
|
bool
|
Should additional print outs be provided |
False
|
Returns:
Type | Description |
---|---|
MultiPolygon
|
shapely.MultiPolygon: The merged multipolygon |
Source code in geograypher/utils/geometric.py
clip_line_segments(boundaries, origins, directions, image_indices, ray_limit=None)
¶
Clips line segments between two boundary surfaces using ray tracing, keeping only the segments that intersect both surfaces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
boundaries
|
Tuple[PolyData, PolyData]
|
A tuple containing two PyVista PolyData surfaces representing the boundaries. |
required |
origins
|
ndarray
|
Array of ray origin points (shape: [N, 3]). |
required |
directions
|
ndarray
|
Array of ray direction vectors (shape: [N, 3]). |
required |
image_indices
|
List[int]
|
List of indices associated with each ray, used for identification. Tracks which image each ray corresponded to. |
required |
ray_limit
|
Optional[float]
|
If provided, segments longer than this value are dropped as invalid. Note that the filtered distance is from the original ray start to the second boundary. This is to mimic measuring from a camera (hypothetical ray source) to the ground (assuming the boundaries are given as [ceiling, floor]). |
None
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, ndarray, ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: - (N, 3) array of start points of clipped segments. This will be the point that intersected boundaries[0] - (N, 3) array of end points of clipped segments. This will be the point that intersected boundaries[1] - (N, 3) array of direction vectors for the clipped segments. - (N,) array of image indices corresponding to the clipped segments. |
Source code in geograypher/utils/geometric.py
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 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 248 249 250 251 252 253 254 |
|