upxo.geoEntities.featmake module
Factory functions for creating and converting UPXO geometric entities.
Usage
from upxo.geoEntities.featmake import make_p2d, make_p3d from upxo.geoEntities.featmake import intersect_slines2d
Functions
make_p2d : Convert any point representation to a 2D UPXO point. make_p3d : Convert any point representation to a 3D UPXO point. intersect_slines2d : Find intersection points between two Sline2d objects. intersect_slines2d_collinear_one_way : One-directional collinear intersection helper.
Notes
make_p2d and make_p3d dispatch on the type string returned by
find_spec_of_points and support many input formats: scalar coordinates,
coordinate lists, NumPy arrays, UPXO lean and full point objects.
- upxo.geoEntities.featmake.make_p2d(points, return_type=None, plane='xy')[source]
Convert any point representation into a list of UPXO 2D point objects.
Handles single points, lists of points, and NumPy arrays. The input may be 2D or 3D; the
planeargument selects which two axes to project onto when the source is 3D.- Parameters:
points (object) – Input point(s) in any supported format:
Point2d,Point3d,p2d_leanest,p3d_leanest, coordinate list[x, y]or[x, y, z], list of the above, or NumPy array with shape(n, 2)or(n, 3).return_type (str, optional) – Target output type.
'leanest'/'p2dlean'→p2d_leanest;'Point2d'/'p2d'or None →Point2d. Default is None.plane (str, optional) – Which plane to project 3D coordinates onto. One of
'xy','yz','xz','yx','zy','zx'. Default is'xy'.
- Returns:
One element per input point in the requested type.
- Return type:
list of Point2d or p2d_leanest
- Raises:
ValueError – When the input point specification is not recognised.
Examples
>>> from upxo.geoEntities.point2d import Point2d as p2d >>> from upxo.geoEntities.featmake import make_p2d >>> make_p2d(p2d(1, 2), return_type='Point2d') >>> make_p2d([p2d(1, 2), p2d(3, 3)], return_type='leanest') >>> import numpy as np >>> make_p2d(np.random.random((10, 3)), return_type='p2d')
- upxo.geoEntities.featmake.make_p3d(points, return_type=None, zloc=0.0)[source]
Convert any point representation into a list of UPXO 3D point objects.
- Parameters:
points (object) – Input point(s) in any supported format:
Point2d,Point3d,p2d_leanest,p3d_leanest, coordinate list[x, y, z], list of the above, or NumPy array with shape(n, 3).return_type (str, optional) – Target output type.
'p3dlean'/'leanest'→p3d_leanest;'Point3d'/'p3d'or None →Point3d. Default is None.zloc (float, optional) – Z-coordinate to assign when promoting 2D points to 3D. Default is 0.0.
- Returns:
One element per input point in the requested type.
- Return type:
list of Point3d or p3d_leanest
- Raises:
ValueError – When the input point specification is not recognised.
Examples
>>> from upxo.geoEntities.point2d import Point2d as p2d >>> from upxo.geoEntities.featmake import make_p3d >>> make_p3d(p2d(1, 2), return_type='Point3d', zloc=1.0) >>> make_p3d([p2d(1, 2), p2d(3, 3)], return_type='leanest') >>> import numpy as np >>> make_p3d(np.random.random((10, 3)), return_type='p3d')
- upxo.geoEntities.featmake.intersect_slines2d(la, lb, p2d, return_type='upxo')[source]
Find all intersection points between two UPXO 2D straight lines.
Checks both directions (
lawithlbandlbwithla) to handle collinear overlaps, deduplicates the result, then falls back to the standard algebraic line–line intersection formula for non-parallel lines.- Parameters:
- Returns:
List of intersection points in the format requested by
return_type. Empty list when lines do not intersect.- Return type:
Examples
>>> from upxo.geoEntities.sline2d import Sline2d as sl2d >>> from upxo.geoEntities.point2d import Point2d as p2d >>> import upxo.geoEntities.featmake as fmake >>> la = sl2d.by_coord([0, 0], [1, 1]) >>> lb = sl2d.by_coord([0, 1], [1, 0]) >>> fmake.intersect_slines2d(la, lb, p2d) >>> fmake.intersect_slines2d(la, lb, p2d, return_type='coord')
- upxo.geoEntities.featmake.intersect_slines2d_collinear_one_way(la, lb, p2d)[source]
Find endpoints of
lbthat lie onla(one-directional collinear check).Tests whether each endpoint of
lbis within the perpendicular distance tolerance oflaand also within the chord length ofla. Intended to be called fromintersect_slines2d()for each direction.- Parameters:
- Returns:
Endpoints of
lbthat lie onla. Empty list if none qualify.- Return type:
Examples
>>> from upxo.geoEntities.sline2d import Sline2d as sl2d >>> from upxo.geoEntities.point2d import Point2d as p2d >>> import upxo.geoEntities.featmake as fmake >>> la = sl2d.by_coord([0, 0], [1, 1]) >>> lb = sl2d.by_coord([0.1, 0.1], [1.8, 1.8]) >>> fmake.intersect_slines2d_collinear_one_way(la, lb, p2d)