pchandler.geometry.coordinates
Cartesian coordinate classes with numerical-precision shift management.
Defines AbstractCoordinates and Abstract3dCoordinates base
classes, CartesianCoordinates (the main user-facing 3D coordinate
container), plus the rhv2xyz / xyz2rhv spherical/Cartesian conversion
helpers.
Functions
|
Convert spherical coordinates (RHV) to Cartesian coordinates (XYZ). |
|
Convert Cartesian coordinates (XYZ) to spherical coordinates (RHV). |
Classes
Abstract base for 2D coordinate classes exposing |
|
Abstract coordinates with support for a transformation to custom coordinate system and a scan center parameter. |
|
|
Optional keyword arguments accepted by |
Abstract base for all coordinate classes; carries a UUID4 identity. |
|
Cartesian Coordinate class with support for numerical optimizations and helper access methods. |
|
|
Optional keyword arguments accepted by |
|
Full keyword surface for |
- class pchandler.geometry.coordinates.CartesianCoordinates
Bases:
Abstract3dCoordinatesCartesian Coordinate class with support for numerical optimizations and helper access methods.
- Parameters:
arr (Array_Nx3_T) – Raw coordinate data
unshifted_bbox (MinMaxPoints | None) – Bounding box of the original input coordinates (before optimization shift)
numerical_optimization_shift (OptimizedShift | None) – Optimization shift applied to the point cloud.
socs_origin (Vector_3_T | None) – Scan center coordinate in the current coordinate system.
- arr: Array_Nx3_T
Contains the raw numpy ndarray data
- unshifted_bbox: MinMaxPoints | None
- numerical_optimization_shift: OptimizedShift | None
- __init__(xyz: TypeAliasForwardRef('GSEGUtils.base_types.Array_Nx3_T') | Self, **kwargs: Unpack[CartesianKw])
- __init__(**kwargs: Unpack[CartesianKwFull])
Build a
CartesianCoordinates, auto-computing a numerical-precision shift.On construction the object attempts to apply a numerical-precision shift so the coordinates fit in
float32without loss. The user can passnumerical_optimization_shift=Noneto force the coordinates to keep the input precision and original coordinate system.- Parameters:
xyz (Array_Nx3_T | Self, optional) – XYZ coordinates as an
(N, 3)array, or anotherCartesianCoordinatesinstance to copy from. May also be supplied via thearr=keyword.**kwargs – Optional fields:
socs_origin,project_transformation,numerical_optimization_shift,unshifted_bbox,_shift_applied_by.
- compute_unshifted_bbox(overwrite=False)
Compute the bounding box of the point cloud’s original (unshifted) coordinates.
- Parameters:
overwrite (bool, default=False) – Recompute the bounding box even if one is already cached.
- reduce(index)
Reduce the coordinates to the point set selected by
index(in place).Supports both numpy basic and advanced indexing.
- Parameters:
index (IndexLike) – Index or boolean mask selecting the rows to keep.
- sample(index)
Sample a copy of the coordinates using
index.- Parameters:
index (IndexLike) – Index or boolean mask selecting the rows to keep.
- Returns:
New
CartesianCoordinatescarrying the sampled rows.- Return type:
- update_shift(delta_shift)
Apply
delta_shiftto the coordinates and adjust the dtype accordingly.The dtype of the updated vectors is
float32when a numerical-optimization shift is registered, andfloat64otherwise.- Parameters:
delta_shift (Vector_3_T) – The shift vector to be added.
- model_dump(**kwargs)
Dump the model to a dict, preserving the private
_shift_applied_byattribute.- Parameters:
**kwargs (Any) – Passed through to
pydantic.BaseModel.model_dump().- Returns:
Model state including
_shift_applied_by.- Return type:
- copy(array=None, *, deep=True, update=None, link_to_same_NOS=True, **kwargs)
Produce a deep or shallow copy of the model.
Updates the model also if this parameter is parsed.
- Parameters:
array (Array_Nx3_Float_T | Self) – A new object will be created with all other parameters and have it’s coordinates update with this array.
deep (bool) – Flag to indicate if a deep copy should be made.
update (dict[str, Any] | None) – Dictionary of parameters to update.
link_to_same_NOS (bool) – Flag if the object should be tied to the same optimal shift object. Thus attached to the same coordinate system.
- Return type:
- classmethod merge(*cart_coords, **kwargs)
Merge multiple cartesian coordinate sets into one.
Attempts will be made to automatically resolve the numerical shift applied to each point cloud, if applied.
- Parameters:
cart_coords (CartesianCoordinates)
- Return type:
Notes
Behaviour when input PCDs have mixed numerical_optimization_shift:
If the first PCD’s NOS passes
check_addibility(combined_bbox), link the merged PCD to that NOS. (Most common; INFO log “Linking…”.)Else if a fresh
OptimizedShift()would be feasible for the combined bbox under the manager’s precision floor, mint one and link. INFO log “Creating new numerical optimization shift instance.”Else, set
numerical_optimization_shift = Noneon the merged PCD (degrade to float64 frame). INFO log “Unable to create new…”.
Phase 3 mint-new-UUID on cross-process unpickle (D-18) means downstream merge across pickle boundaries may surface different OptimizedShift instances on the destination than were pickled on the source; world-frame is preserved either way (see DESIGN-DECISIONS.md §”Pickle & state”).
- property x: GSEGUtils.base_types.Vector_Float_T
Return the X component of the coordinates.
- property y: GSEGUtils.base_types.Vector_Float_T
Return the Y component of the coordinates.
- property z: GSEGUtils.base_types.Vector_Float_T
Return the Z component of the coordinates.
- property xyz: GSEGUtils.base_types.Array_Nx3_Float_T
Return the XYZ coordinates as a numpy array.
- property yxz: GSEGUtils.base_types.Array_Nx3_Float_T
Return the coordinates in YXZ column order.
- property spher: GSEGUtils.base_types.Array_Nx3_Float_T
Return the coordinates in spherical RHV form relative to
socs_origin.When
socs_originis undefined,(0, 0, 0)is treated as the origin.- Returns:
Spherical coordinates as
(N, 3)[range, horizontal, vertical].- Return type:
Array_Nx3_Float_T
- property r: GSEGUtils.base_types.Vector_Float_T
Returns radial component of the spherical coordinates.
- Return type:
Vector_Float_T
- property hz: GSEGUtils.base_types.Vector_Float_T
Return the horizontal angles of the spherical coordinates.
- Return type:
Vector_Float_T
- property v: GSEGUtils.base_types.Vector_Float_T
Return the vertical angles of the spherical coordinates.
- Return type:
Vector_Float_T
- property rhv: GSEGUtils.base_types.Array_Nx3_Float_T
Returns the coordinates as spherical coordinates.
- Return type:
Array_Nx3_Float_T
- rotate(rotation)
Rotate the current coordinates in place by a 3x3 rotation matrix.
- Parameters:
rotation (Array_3x3_T) – 3x3 rotation matrix.
- translate(translation)
Translate the current coordinates in place.
- Parameters:
translation (Vector_3_T) – Translation vector added to each coordinate.
- scale(scale)
Scale the current coordinates in place (component-wise).
- Parameters:
scale (Vector_3_T) – Per-axis scale vector multiplied onto the coordinates.
- transform(affine)
Transform the current coordinates in place using a 4x4 affine matrix.
- Parameters:
affine (Array_4x4_T) – 4x4 affine transformation matrix.
- classmethod from_spherical(spher)
Build an instance from spherical coordinates in RHV format.
- Parameters:
spher (Array_Nx3_T) – Spherical coordinates as
(N, 3)[range, horizontal, vertical].- Returns:
New
CartesianCoordinatesbuilt from the converted XYZ.- Return type:
Self
- class pchandler.geometry.coordinates.AbstractCoordinates
Bases:
FixedLengthArray,ABCAbstract base for all coordinate classes; carries a UUID4 identity.
- id: UUID4
- class pchandler.geometry.coordinates.Abstract2dCoordinates
Bases:
ArrayNx2,AbstractCoordinates,ABCAbstract base for 2D coordinate classes exposing
rowandcol.
- class pchandler.geometry.coordinates.Abstract3dCoordinates
Bases:
ArrayNx3,AbstractCoordinates,ABCAbstract coordinates with support for a transformation to custom coordinate system and a scan center parameter.
- Parameters:
project_transformation (Array_4x4_T | None) – Affine transformation array representing transform from scan coordinates to project coordinates.
socs_origin (Vector_3_T | None) – Scan center coordinate in the current coordinate system.