upxo.geoEntities.pops module
Pure point operations and point-to-entity comparison utilities for UPXO.
Usage
from upxo.geoEntities import pops
Functions
- Profiling
PROFILE_up2d_INST
- Point operations (single-point arithmetic / transforms)
xadd, yadd, xmul, ymul, xdiv, ydiv, xabs, yabs, intize, floatize, roundround, roundceil, roundfloor, negxy, negx, negy, mirrorx, mirrory, translate, rotate
- Point-point comparisons
CMPEQ_points, CMPEQ_pnt_fast_exact, CMPEQ_pnt_fast_EPS, CMPEQ_pnt_fast_tdist
- Point-edge operations
CMPEQ_up2d_edge, CMPEQ_up2d_edges, DIST_point_edges
- Point-point relative-position queries
RELPOS_point_points_above, RELPOS_point_points_below, RELPOS_point_points_left, RELPOS_point_points_right
- upxo.geoEntities.pops.CMPEQ_points(p1, p2)[source]
Return
p1 == p2using the point equality operator.
- upxo.geoEntities.pops.CMPEQ_pnt_fast_exact(p1, p2)[source]
Return
Trueifp1andp2have exactly equal x and y.
- upxo.geoEntities.pops.CMPEQ_pnt_fast_EPS(p1, p2)[source]
Return
Trueif the Euclidean distance betweenp1andp2is ≤ EPS.
- upxo.geoEntities.pops.CMPEQ_pnt_fast_tdist(p1, p2, tdist=1e-12)[source]
Return
Trueif the Euclidean distance betweenp1andp2is ≤tdist.
- upxo.geoEntities.pops.CMPEQ_up2d_edge(point, edge)[source]
Check equality with points of the input UPXO edge
- Parameters:
edge (UPXO edge object) – User input UPXO edge object
- Returns:
List of two truth values. First for pnta of input edge and second for pntb of input edge. If distance <= point EPS, value is True, else False
- Return type:
Examples
>>> from upxo.geoEntities.point2d import point2d >>> from upxo.geoEntities.edge2d import edge2d >>> from upxo.geoEntities import pops >>> p = point2d(0, 0, lean='ignore') >>> e = edge2d(method='up2d', pnta=point2d(0, 0), pntb=point2d(1, 0)) >>> pops.CMPEQ_up2d_edge(p, e)
- upxo.geoEntities.pops.CMPEQ_up2d_edges(point, edges, data_set)[source]
Check equality with points of the input UPXO edges
- Parameters:
edges (dth.dt.ITERABLES) – Iterable having user input UPXO edge objects
- Returns:
equalities – (N, 2) shaped numpy array of truth values, N: number of edges
- Return type:
np.array
Examples
>>> from upxo.geoEntities.point2d import point2d >>> from upxo.geoEntities.edge2d import edge2d >>> from upxo.geoEntities import pops >>> p = point2d(0, 0, lean='ignore') >>> edges = [edge2d(method='up2d', pnta=point2d(0, 0), pntb=point2d(1, 0))] >>> pops.CMPEQ_up2d_edges(p, edges, 'large_data_set')
- upxo.geoEntities.pops.DIST_point_edges(point, edges, data_set)[source]
- Parameters:
edges (dth.dt.ITERABLES) – Iterable having user input UPXO edge objects
- Returns:
dist – (N, 2) shaped numpy array of distances, N: number of edges dist[n, 0]: distance from point to pnta of nth edge dist[n, 1]: distance from point to pntb of nth edge
- Return type:
np.array
Examples
>>> from upxo.geoEntities.point2d import point2d >>> from upxo.geoEntities.edge2d import edge2d >>> from upxo.geoEntities import pops >>> p = point2d(0, 0, lean='ignore') >>> edges = [edge2d(method='up2d', pnta=point2d(0, 0), pntb=point2d(1, 0))] >>> pops.DIST_point_edges(p, edges, 'large_data_set')
- upxo.geoEntities.pops.RELPOS_point_points_above(point, point_objects)[source]
Returns Truth array as per elements in point_objects. True if other object is above, else False in any other case
- Parameters:
point_objects (point2d / shapely point / coord_xy list) – / coord_xy tuple Input set of points to compare against.
- Return type:
list of Boolean (truth values)
- upxo.geoEntities.pops.RELPOS_point_points_below(point, point_objects)[source]
Returns Truth array as per elements in point_objects. True if other object is below, else False in any other case
- Parameters:
point_objects (point2d / shapely point / coord_xy list) – / coord_xy tuple Input set of points to compare against.
- Return type:
list of Boolean (truth values)
- upxo.geoEntities.pops.RELPOS_point_points_left(point, point_objects)[source]
Returns Truth array as per elements in point_objects. True if other object is to the left, else False in any other case
- Parameters:
point_objects (point2d / shapely point / coord_xy list) – / coord_xy tuple Input set of points to compare against.
- Return type:
list of Boolean (truth values)
- upxo.geoEntities.pops.RELPOS_point_points_right(point, point_objects)[source]
Returns Truth array as per elements in point_objects. True if other object is to the right, else False in any other case
- Parameters:
point_objects (point2d / shapely point / coord_xy list) – / coord_xy tuple Input set of points to compare against.
- Return type:
list of Boolean (truth values)
- upxo.geoEntities.pops.xadd(point, k, saa=False, make_new=True, lean='ignore', throw=True)[source]
Add
kto the x-coordinate ofpoint, with saa/throw control.
- upxo.geoEntities.pops.yadd(point, k, saa=False, make_new=True, lean='ignore', throw=True)[source]
Add
kto the y-coordinate ofpoint, with saa/throw control.
- upxo.geoEntities.pops.xmul(point, k, saa=False, make_new=True, lean='ignore', throw=True)[source]
Multiply the x-coordinate of
pointbyk, with saa/throw control.
- upxo.geoEntities.pops.ymul(point, k, saa=False, make_new=True, lean='ignore', throw=True)[source]
Multiply the y-coordinate of
pointbyk, with saa/throw control.
- upxo.geoEntities.pops.xdiv(point, k, saa=False, make_new=True, lean='ignore', throw=True)[source]
Divide the x-coordinate of
pointbyk, with saa/throw control.
- upxo.geoEntities.pops.ydiv(point, k, saa=False, make_new=True, lean='ignore', throw=True)[source]
Divide the y-coordinate of
pointbyk, with saa/throw control.
- upxo.geoEntities.pops.xabs(point, saa=False, make_new=True, lean='ignore', throw=True)[source]
Apply absolute value to the x-coordinate of
point, with saa/throw control.
- upxo.geoEntities.pops.yabs(point, saa=False, make_new=True, lean='ignore', throw=True)[source]
Apply absolute value to the y-coordinate of
point, with saa/throw control.
- upxo.geoEntities.pops.intize(point, saa=False, make_new=True, lean='ignore', throw=True)[source]
Convert both coordinates of
pointtoint, with saa/throw control.
- upxo.geoEntities.pops.floatize(point, saa=False, make_new=True, lean='ignore', throw=True)[source]
Convert both coordinates of
pointtofloat, with saa/throw control.
- upxo.geoEntities.pops.roundround(point, nd=4, saa=False, make_new=True, lean='ignore', throw=True)[source]
Round both coordinates of
pointtondigits, with saa/throw control.
- upxo.geoEntities.pops.xroundround(point, nd=4, saa=False, make_new=True, lean='ignore', throw=True)[source]
Round the x-coordinate of
pointtondigits, with saa/throw control.
- upxo.geoEntities.pops.yroundround(point, nd=4, saa=False, make_new=True, lean='ignore', throw=True)[source]
Round the y-coordinate of
pointtondigits, with saa/throw control.
- upxo.geoEntities.pops.roundceil(point, nd=4, saa=False, make_new=True, lean='ignore', throw=True)[source]
Apply
math.ceilto both coordinates ofpoint, with saa/throw control.
- upxo.geoEntities.pops.xroundceil(point, nd=4, saa=False, make_new=True, lean='ignore', throw=True)[source]
Apply
math.ceilto the x-coordinate ofpoint, with saa/throw control.
- upxo.geoEntities.pops.yroundceil(point, nd=4, saa=False, make_new=True, lean='ignore', throw=True)[source]
Apply
math.ceilto the y-coordinate ofpoint, with saa/throw control.
- upxo.geoEntities.pops.roundfloor(point, nd=4, saa=False, make_new=True, lean='ignore', throw=True)[source]
Apply
math.floorto both coordinates ofpoint, with saa/throw control.
- upxo.geoEntities.pops.xroundfloor(point, nd=4, saa=False, make_new=True, lean='ignore', throw=True)[source]
Apply
math.floorto the x-coordinate ofpoint, with saa/throw control.
- upxo.geoEntities.pops.yroundfloor(point, nd=4, saa=False, make_new=True, lean='ignore', throw=True)[source]
Apply
math.floorto the y-coordinate ofpoint, with saa/throw control.
- upxo.geoEntities.pops.negxy(point, saa=False, make_new=True, lean='ignore', throw=True)[source]
Negate both coordinates of
point, with saa/throw control.
- upxo.geoEntities.pops.negx(point, saa=False, make_new=True, lean='ignore', throw=True)[source]
Negate the x-coordinate of
point, with saa/throw control.
- upxo.geoEntities.pops.negy(point, saa=False, make_new=True, lean='ignore', throw=True)[source]
Negate the y-coordinate of
point, with saa/throw control.
- upxo.geoEntities.pops.mirrorx(point, saa: bool = False, make_new: bool = True, lean: bool = 'ignore', throw: bool = True)[source]
Mirror point about the x-axis.
- upxo.geoEntities.pops.mirrory(point, saa: bool = False, make_new: bool = True, lean: bool = 'ignore', throw: bool = True)[source]
Mirror point about the y-axis.
- upxo.geoEntities.pops.translate(point, xyincr: list = [0.0, 0.0], method: str = 'xyincr', xincr: float = 0.0, yincr: float = 0.0, xnew: float = 0.0, ynew: float = 0.0, xynew: list = [0.0, 0.0], saa: bool = False, make_new: bool = True, lean: bool = 'ignore', throw: bool = True)[source]
Translate
pointby a displacement vector, with saa/throw control.
- upxo.geoEntities.pops.rotate(point, t=0.0, o=(0.0, 0.0), nd=12, saa=False, make_new=True, lean='ignore', throw=True)[source]
Rotate counterclockwise. nd: number of decimal places to round off to
- upxo.geoEntities.pops.distance(self, otype='point2d', obj=None, cor=0.1, nworkers=1)[source]
Single UPXO point2d object - DONE
List of upxo point2d objects - DONE
A single coordinate pair of point2d - DONE
List of x coordinates and y coordinates - DONE
- upxo.geoEntities.pops.pixelize(point, dim=2, k1=0.5, k2=0.5, k3=0.5, z0=0.0, t=0.0, aunit='deg', avoidEPS=False, nd=12, saa=False, throw=False, throw_edges=False, throw_faces=False, make_midnode=False, makextal_upxo=False, makextal_shapely=False, makextal_vtk=False, makeelement_gmsh=False, make_abaqus_element=False, break_into_2tria=False, break_into_2trib=False, break_into_4tri=False)[source]
Build a pixel (rectangular voxel) around a point and optionally subdivide it.
Constructs a 2-D rectangular pixel centred on
pointwith half-widthsk1(x) andk2(y), optionally rotated by anglet. In 3-D mode (dim=3) the pixel is extruded to a hexahedral cell using half-depthk3. The cell can be returned as a whole or split into triangles / tetrahedra, and optionally converted to UPXO, Shapely, VTK, Gmsh, or Abaqus element representations.- Parameters:
point (Point2d) – Centre point of the pixel.
dim ({2, 3}, optional) – Spatial dimension of the output cell. Default is
2.k1 (float, optional) – Half-width along x. Default is
0.5.k2 (float, optional) – Half-width along y. Default is
0.5.k3 (float, optional) – Half-depth along z (3-D only). Default is
0.5.z0 (float, optional) – z-coordinate of the bottom face (3-D only). Default is
0.0.t (float, optional) – Rotation angle of the pixel about its centre. Default is
0.0.aunit ({'deg', 'rad'}, optional) – Unit of
t. Default is'deg'.avoidEPS (bool, optional) – If
True, suppress epsilon-based adjustments. Default isFalse.nd (int, optional) – Number of decimal places for coordinate rounding. Default is
12.saa (bool, optional) – If
True, store the result back onpoint(save-and-apply). Default isFalse.throw (bool, optional) – If
True, return the pixel vertices. Default isFalse.throw_edges (bool, optional) – If
True, return edge objects. Default isFalse.throw_faces (bool, optional) – If
True, return face objects (3-D only). Default isFalse.make_midnode (bool, optional) – If
True, compute and include the mid-node. Default isFalse.makextal_upxo (bool, optional) – If
True, build a UPXO crystal from the pixel. Default isFalse.makextal_shapely (bool, optional) – If
True, build a Shapely polygon. Default isFalse.makextal_vtk (bool, optional) – If
True, build a VTK cell. Default isFalse.makeelement_gmsh (bool, optional) – If
True, build a Gmsh element. Default isFalse.make_abaqus_element (bool, optional) – If
True, build an Abaqus element. Default isFalse.break_into_2tria (bool, optional) – If
True, split the quad into two triangles (variant A). Default isFalse.break_into_2trib (bool, optional) – If
True, split the quad into two triangles (variant B). Default isFalse.break_into_4tri (bool, optional) – If
True, split the quad into four triangles about the centre. Default isFalse.
- Returns:
Returns pixel data when
throwor related flags areTrue; otherwise modifiespointin-place (whensaa=True) and returnsNone.- Return type:
None or tuple
Notes
Corner-point naming convention (2-D, unrotated):
p2 ----------- p1 p1 = (x + k1, y + k2) | | p2 = (x - k1, y + k2) | O(x, y) | p3 = (x - k1, y - k2) | | p4 = (x + k1, y - k2) p3 ----------- p4
For 3-D hexahedral cells the bottom face duplicates the 2-D layout at
z = z0and the top face atz = z0 + 2*k3.
- upxo.geoEntities.pops.make_polygon(point, r, nv, t, make_mpv=True, make_edges=True, mp_lean='ignore', e_lean='ignore', ep_lean='ignore', fill_random=False, fill_r_threshold=0.8, make_mpfill=False, n_random=20)[source]
Makes a Polygon with self ~UPXO point 2d~ as the centre
- Parameters:
r (float/int) – radius.
nv (int) – Number of vertices on the cirle. Code uses n+1. User to input n.
t (float) – Rotation angle. Degrees. ACW for positive t values.
make_mpv (bool, optional) – bool to make UPXO mul-point object of the polygon’s vertices. The default is True.
make_edges (bool, optional) – bool to make UPXO edge objects. The default is True.
mp_lean (str) – Leanness specification of the mul-point object
e_lean (str) – Leanness specification of the edge objects
ep_lean (str) – Leanness specification of the points in the mul-point object
fill_random (bool) – Specifies whether to fill with points. The default is False
fill_r_threshold (float) – Domain:[0, 1] Threshold radius factor for filling with points . For high nv, fill_r_threshold could be near 1 For low nv, fill_r_threshold must be smaller
make_mpv – bool to make UPXO mul-point object of filler points. The default is False.
n_random (int)
- Returns:
polygon. Description of polygon is below – polygon[‘v’]: vertices polygon[‘fill’]: filler points polygon[‘e’]: edges
Example-1
———
p = point2d(x=0.0, y=0.0)
polygon = p.make_polygon(0.5, 5, 0, – make_mpv=True, mp_lean=’ignore’, e_lean=’ignore’, ep_lean=’ignore’, fill_random=True, fill_r_threshold=0.8, n_random=1000, make_edges=True, make_mpfill=False, )