GeometryOperators#
Overview#
Convert a C# list object to a Python list. |
|
Convert a number and unit to a float. |
|
Retrieve a string for a coordinate system plane. |
|
Retrieve a string for a coordinate system plane. |
|
Retrieve a string for a coordinate system axis. |
|
Retrieve the draft type. |
|
Evaluate the midpoint between two points. |
|
Evaluate the area of a triangle defined by its three vertices. |
|
Evaluate the cross product of two geometry vectors. |
|
Evaluate the dot product between two geometry vectors. |
|
Evaluate the product between a scalar value and a vector. |
|
Evaluate rotation of a vector around an axis. |
|
Evaluate two geometry vectors by subtracting them (a-b). |
|
Evaluate two geometry vectors by adding them (a+b). |
|
Evaluate the Euclidean norm of a geometry vector. |
|
Normalize a geometry vector. |
|
Vector from one point to another point. |
|
Evaluate the distance between two points expressed as their Cartesian coordinates. |
|
Find a point on a plane. |
|
Evaluate the vector distance between point |
|
Check if a point lies on the segment defined by two points. |
|
Check if a segment defined by two points is parallel to a segment defined by two other points. |
|
ADD DESCRIPTION. |
|
Check if two vectors are collinear (parallel or anti-parallel). |
|
Project a segment onto another segment and check if the projected segment is inside it. |
|
Return the sum of two vertices lists. |
|
Evaluate the angle between two geometry vectors. |
|
Retrieve the axes from the HFSS X axis and Y pointing axis as per |
|
Retrieve Euler angles of a frame following the rotation sequence ZXZ. |
|
Retrieve Euler angles of a frame following the rotation sequence ZYZ. |
|
Convert a quaternion to a rotated frame defined by X, Y, and Z axes. |
|
Convert a quaternion to the axis angle rotation formulation. |
|
Convert the axis angle rotation formulation to a quaternion. |
|
Convert a quaternion to Euler angles following rotation sequence ZXZ. |
|
Convert the Euler angles following rotation sequence ZXZ to a quaternion. |
|
Convert a quaternion to Euler angles following rotation sequence ZYZ. |
|
Convert the Euler angles following rotation sequence ZYZ to a quaternion. |
|
Convert the angle from degrees to radians. |
|
Convert the angle from radians to degrees. |
|
Implementation of atan2 that does not suffer from the following issues: |
|
Evaluate the product of two quaternions, |
|
Evaluate the rotation of a vector, defined by a quaternion. |
|
Evaluate the inverse rotation of a vector that is defined by a quaternion. |
|
Evaluate the centroid of a polygon defined by its points. |
|
Return x_pointing and y_pointing vectors as expressions from |
|
Convert a string to a numeric value. Discard the suffix. |
|
Return |
|
Return a list of [x,y,z] numeric values given a coordinate system as input. |
|
Orient a polygon clockwise or counterclockwise. The vertices should be already ordered either way. |
|
Evaluate the signed angle between two geometry vectors. |
|
Evaluate the signed angle between two 2D geometry vectors. |
|
Determine if a point is inside, outside the polygon or at exactly at the border. |
|
Determine if a point is inside or outside a polygon, both located on the same plane. |
|
Determine if the two segments a and b are intersecting. |
|
Determine if a segment defined by two points |
|
Check if two vectors are perpendicular. |
|
Check if a point projection lies on the segment defined by two points. |
|
Calculate the distance between a point |
|
Find the largest area rectangles of arbitrary orientation in a polygon. |
|
Ceil of angle. |
|
Radian angle ceiling. |
|
Convert angle to degree with given digits rounding. |
|
Convert to radians with given round. |
|
Given a list of points, finds the closest points to a reference point. |
|
Mirror point about a plane defining by a point on the plane and a normal point. |
|
Detect all points that are placed along lines. |
|
Find the smallest distance between two polygons using KDTree for efficient nearest neighbor search. |
Import detail#
from pyedb.modeler.geometry_operators import GeometryOperators
Method detail#
- static GeometryOperators.List2list(input_list)#
Convert a C# list object to a Python list.
This function performs a deep conversion.
- Parameters:
- input_list
List C# list to convert to a Python list.
- input_list
- Returns:
ListConverted Python list.
- static GeometryOperators.parse_dim_arg(string, scale_to_unit=None, variable_manager=None)#
Convert a number and unit to a float. Angles are converted in radians.
- Parameters:
- string
str,optional String to convert. For example,
"2mm". The default isNone.- scale_to_unit
str,optional Units for the value to convert. For example,
"mm".- variable_manager
pyedb.dotnet.database.Variables.VariableManager,optional Try to parse formula and returns numeric value. The default is
None.
- string
- Returns:
floatValue for the converted value and units. For example,
0.002.
Examples
Parse ‘“2mm”’.
>>> from pyedb.modeler.geometry_operators import GeometryOperators as go >>> go.parse_dim_arg("2mm") >>> 0.002
Use the optional argument
scale_to_unitto specify the destination unit.>>> go.parse_dim_arg("2mm", scale_to_unit="mm") >>> 2.0
- static GeometryOperators.cs_plane_to_axis_str(val)#
Retrieve a string for a coordinate system plane.
- static GeometryOperators.cs_plane_to_plane_str(val)#
Retrieve a string for a coordinate system plane.
- Parameters:
- val
- Returns:
strString for the coordinate system plane.
- static GeometryOperators.cs_axis_str(val)#
Retrieve a string for a coordinate system axis.
- static GeometryOperators.draft_type_str(val)#
Retrieve the draft type.
- static GeometryOperators.get_mid_point(v1, v2)#
Evaluate the midpoint between two points.
- Parameters:
- v1
List List of
[x, y, z]coordinates for the first point.- v2
List List of
[x, y, z]coordinates for the second point.
- v1
- Returns:
ListList of
[x, y, z]coordinates for the midpoint.
- static GeometryOperators.get_triangle_area(v1, v2, v3)#
Evaluate the area of a triangle defined by its three vertices.
- Parameters:
- v1
List List of
[x, y, z]coordinates for the first vertex.- v2
List List of
[x, y, z]coordinates for the second vertex.- v3
List List of
[x, y, z]coordinates for the third vertex.
- v1
- Returns:
floatArea of the triangle.
- static GeometryOperators.v_cross(a, b)#
Evaluate the cross product of two geometry vectors.
- Parameters:
- a
List List of
[x, y, z]coordinates for the first vector.- b
List List of
[x, y, z]coordinates for the second vector.
- a
- Returns:
ListList of
[x, y, z]coordinates for the result vector.
- static GeometryOperators.v_dot(a, b)#
Evaluate the dot product between two geometry vectors.
- Parameters:
- a
List List of
[x, y, z]coordinates for the first vector.- b
List List of
[x, y, z]coordinates for the second vector.
- a
- Returns:
floatResult of the dot product.
- static GeometryOperators.v_prod(s, v)#
Evaluate the product between a scalar value and a vector.
- Parameters:
- s
float Scalar value.
- v
List List of values for the vector in the format
[v1, v2,..., vn]. The vector can be any length.
- s
- Returns:
ListList of values for the result vector. This list is the same length as the list for the input vector.
- static GeometryOperators.v_rotate_about_axis(vector, angle, radians=False, axis='z')#
Evaluate rotation of a vector around an axis.
- Parameters:
- Returns:
listList of values for the result vector.
- static GeometryOperators.v_sub(a, b)#
Evaluate two geometry vectors by subtracting them (a-b).
- Parameters:
- a
List List of
[x, y, z]coordinates for the first vector.- b
List List of
[x, y, z]coordinates for the second vector.
- a
- Returns:
ListList of
[x, y, z]coordinates for the result vector.
- static GeometryOperators.v_sum(a, b)#
Evaluate two geometry vectors by adding them (a+b).
- Parameters:
- a
List List of
[x, y, z]coordinates for the first vector.- b
List List of
[x, y, z]coordinates for the second vector.
- a
- Returns:
ListList of
[x, y, z]coordinates for the result vector.
- static GeometryOperators.v_norm(a)#
Evaluate the Euclidean norm of a geometry vector.
- Parameters:
- a
List - List of ``[x, y, z]`` coordinates for the vector.
- a
- Returns:
floatEvaluated norm in the same unit as the coordinates for the input vector.
- static GeometryOperators.normalize_vector(v)#
Normalize a geometry vector.
- Parameters:
- v
List List of
[x, y, z]coordinates for vector.
- v
- Returns:
ListList of
[x, y, z]coordinates for the normalized vector.
- static GeometryOperators.v_points(p1, p2)#
Vector from one point to another point.
- Parameters:
- p1
List Coordinates
[x1,y1,z1]for the first point.- p2
List Coordinates
[x2,y2,z2]for second point.
- p1
- Returns:
ListCoordinates
[vx, vy, vz]for the vector from the first point to the second point.
- static GeometryOperators.points_distance(p1, p2)#
Evaluate the distance between two points expressed as their Cartesian coordinates.
- Parameters:
- p1
List List of
[x1,y1,z1]coordinates for the first point.- p2
List List of
[x2,y2,z2]coordinates for the second ppint.
- p1
- Returns:
floatDistance between the two points in the same unit as the coordinates for the points.
- static GeometryOperators.find_point_on_plane(pointlists, direction=0)#
Find a point on a plane.
- Parameters:
- pointlists
List List of points.
- direction
int,optional The default is
0.
- pointlists
- Returns:
List
- static GeometryOperators.distance_vector(p, a, b)#
Evaluate the vector distance between point
pand a line defined by two points,aandb.Note
he formula is
d = (a-p)-((a-p)dot p)n, whereais a point of the line (eitheraorb) andnis the unit vector in the direction of the line.- Parameters:
- p
List List of
[x, y, z]coordinates for the reference point.- a
List List of
[x, y, z]coordinates for the first point of the segment.- b
List List of
[x, y, z]coordinates for the second point of the segment.
- p
- Returns:
ListList of
[x, y, z]coordinates for the distance vector.
- static GeometryOperators.is_between_points(p, a, b, tol=1e-06)#
Check if a point lies on the segment defined by two points.
- Parameters:
- p
List List of
[x, y, z]coordinates for the reference pointp.- a
List List of
[x, y, z]coordinates for the first point of the segment.- b
List List of
[x, y, z]coordinates for the second point of the segment.- tol
float Linear tolerance. The default value is
1e-6.
- p
- Returns:
- bool
Truewhen the point lies on the segment defined by the two points,Falseotherwise.
- static GeometryOperators.is_parallel(a1, a2, b1, b2, tol=1e-06)#
Check if a segment defined by two points is parallel to a segment defined by two other points.
- Parameters:
- a1
List List of
[x, y, z]coordinates for the first point of the fiirst segment.- a2
List List of
[x, y, z]coordinates for the second point of the first segment.- b1
List List of
[x, y, z]coordinates for the first point of the second segment.- b2
List List of
[x, y, z]coordinates for the second point of the second segment.- tol
float Linear tolerance. The default value is
1e-6.
- a1
- Returns:
- bool
Truewhen successful,Falsewhen failed.
- static GeometryOperators.parallel_coeff(a1, a2, b1, b2)#
ADD DESCRIPTION.
- Parameters:
- a1
List List of
[x, y, z]coordinates for the first point of the first segment.- a2
List List of
[x, y, z]coordinates for the second point of the first segment.- b1
List List of
[x, y, z]coordinates for the first point of the second segment.- b2
List List of
[x, y, z]coordinates for the second point of the second segment.
- a1
- Returns:
float_vdot of 4 vertices of 2 segments.
- static GeometryOperators.is_collinear(a, b, tol=1e-06)#
Check if two vectors are collinear (parallel or anti-parallel).
- static GeometryOperators.is_projection_inside(a1, a2, b1, b2)#
Project a segment onto another segment and check if the projected segment is inside it.
- Parameters:
- a1
List List of
[x, y, z]coordinates for the first point of the projected segment.- a2
List List of
[x, y, z]coordinates for the second point of the projected segment.- b1
List List of
[x, y, z]coordinates for the first point of the other segment.- b2
List List of
[x, y, z]coordinates for the second point of the other segment.
- a1
- Returns:
- bool
Truewhen the projected segment is inside the other segmennt,Falseotherwise.
- static GeometryOperators.arrays_positions_sum(vertlist1, vertlist2)#
Return the sum of two vertices lists.
- Parameters:
- vertlist1
List - vertlist2
List
- vertlist1
- Returns:
- static GeometryOperators.v_angle(a, b)#
Evaluate the angle between two geometry vectors.
- Parameters:
- a
List List of
[x, y, z]coordinates for the first vector.- b
List List of
[x, y, z]coordinates for the second vector.
- a
- Returns:
floatAngle in radians.
- static GeometryOperators.pointing_to_axis(x_pointing, y_pointing)#
Retrieve the axes from the HFSS X axis and Y pointing axis as per the definition of the AEDT interface coordinate system.
- Parameters:
- x_pointing
List List of
[x, y, z]coordinates for the X axis.- y_pointing
List List of
[x, y, z]coordinates for the Y pointing axis.
- x_pointing
- Returns:
tuple[Xx, Xy, Xz], [Yx, Yy, Yz], [Zx, Zy, Zz]of the three axes (normalized).
- static GeometryOperators.axis_to_euler_zxz(x, y, z)#
Retrieve Euler angles of a frame following the rotation sequence ZXZ.
Provides assumption for the gimbal lock problem.
- Parameters:
- x
List List of
[Xx, Xy, Xz]coordinates for the X axis.- y
List List of
[Yx, Yy, Yz]coordinates for the Y axis.- z
List List of
[Zx, Zy, Zz]coordinates for the Z axis.
- x
- Returns:
tuple(phi, theta, psi) containing the Euler angles in radians.
- static GeometryOperators.axis_to_euler_zyz(x, y, z)#
Retrieve Euler angles of a frame following the rotation sequence ZYZ.
Provides assumption for the gimbal lock problem.
- Parameters:
- x
List List of
[Xx, Xy, Xz]coordinates for the X axis.- y
List List of
[Yx, Yy, Yz]coordinates for the Y axis.- z
List List of
[Zx, Zy, Zz]coordinates for the Z axis.
- x
- Returns:
tuple(phi, theta, psi) containing the Euler angles in radians.
- static GeometryOperators.quaternion_to_axis(q)#
Convert a quaternion to a rotated frame defined by X, Y, and Z axes.
- Parameters:
- q
List List of
[q1, q2, q3, q4]coordinates for the quaternion.
- q
- Returns:
tuple[Xx, Xy, Xz], [Yx, Yy, Yz], [Zx, Zy, Zz] of the three axes (normalized).
- static GeometryOperators.quaternion_to_axis_angle(q)#
Convert a quaternion to the axis angle rotation formulation.
- Parameters:
- q
List List of
[q1, q2, q3, q4]coordinates for the quaternion.
- q
- Returns:
tuple([ux, uy, uz], theta) containing the rotation axes expressed as X, Y, Z components of the unit vector
uand the rotation angle theta expressed in radians.
- static GeometryOperators.axis_angle_to_quaternion(u, theta)#
Convert the axis angle rotation formulation to a quaternion.
- Parameters:
- u
List List of
[ux, uy, uz]coordinates for the rotation axis.- theta
float Angle of rotation in radians.
- u
- Returns:
ListList of
[q1, q2, q3, q4]coordinates for the quaternion.
- static GeometryOperators.quaternion_to_euler_zxz(q)#
Convert a quaternion to Euler angles following rotation sequence ZXZ.
- Parameters:
- q
List List of
[q1, q2, q3, q4]coordinates for the quaternion.
- q
- Returns:
tuple(phi, theta, psi) containing the Euler angles in radians.
- static GeometryOperators.euler_zxz_to_quaternion(phi, theta, psi)#
Convert the Euler angles following rotation sequence ZXZ to a quaternion.
- static GeometryOperators.quaternion_to_euler_zyz(q)#
Convert a quaternion to Euler angles following rotation sequence ZYZ.
- Parameters:
- q
List List of
[q1, q2, q3, q4]coordinates for the quaternion.
- q
- Returns:
tuple(phi, theta, psi) containing the Euler angles in radians.
- static GeometryOperators.euler_zyz_to_quaternion(phi, theta, psi)#
Convert the Euler angles following rotation sequence ZYZ to a quaternion.
- static GeometryOperators.deg2rad(angle)#
Convert the angle from degrees to radians.
- static GeometryOperators.rad2deg(angle)#
Convert the angle from radians to degrees.
- static GeometryOperators.atan2(y, x)#
Implementation of atan2 that does not suffer from the following issues: math.atan2(0.0, 0.0) = 0.0 math.atan2(-0.0, 0.0) = -0.0 math.atan2(0.0, -0.0) = 3.141592653589793 math.atan2(-0.0, -0.0) = -3.141592653589793 and returns always 0.0.
- static GeometryOperators.q_prod(p, q)#
Evaluate the product of two quaternions,
pandq, defined as: p = p0 + p’ = p0 + ip1 + jp2 + kp3. q = q0 + q’ = q0 + iq1 + jq2 + kq3. r = pq = p0q0 - p’ • q’ + p0q’ + q0p’ + p’ x q’.- Parameters:
- p
List List of
[p1, p2, p3, p4]coordinates for quaternionp.- q
List List of
[p1, p2, p3, p4]coordinates for quaternionq.
- p
- Returns:
ListList of [r1, r2, r3, r4] coordinates for the result quaternion.
- static GeometryOperators.q_rotation(v, q)#
Evaluate the rotation of a vector, defined by a quaternion. Evaluated as:
"q = q0 + q' = q0 + iq1 + jq2 + kq3","w = qvq* = (q0^2 - |q'|^2)v + 2(q' • v)q' + 2q0(q' x v)".- Parameters:
- v
List List of
[v1, v2, v3]coordinates for the vector.- q
List List of
[q1, q2, q3, q4]coordinates for the quaternion.
- v
- Returns:
ListList of
[w1, w2, w3]coordinates for the result vectorw.
- static GeometryOperators.q_rotation_inv(v, q)#
Evaluate the inverse rotation of a vector that is defined by a quaternion.
It can also be the rotation of the coordinate frame with respect to the vector.
q = q0 + q’ = q0 + iq1 + jq2 + kq3 q* = q0 - q’ = q0 - iq1 - jq2 - kq3 w = q*vq
- Parameters:
- v
List List of
[v1, v2, v3]coordinates for the vector.- q
List List of
[q1, q2, q3, q4]coordinates for the quaternion.
- v
- Returns:
ListList of
[w1, w2, w3]coordinates for the vector.
- static GeometryOperators.get_polygon_centroid(pts)#
Evaluate the centroid of a polygon defined by its points.
- Parameters:
- pts
List List of points, with each point defined by its
[x,y,z]coordinates.
- pts
- Returns:
ListList of [x,y,z] coordinates for the centroid of the polygon.
- static GeometryOperators.cs_xy_pointing_expression(yaw, pitch, roll)#
Return x_pointing and y_pointing vectors as expressions from the yaw, ptich, and roll input (as strings).
- static GeometryOperators.get_numeric(s)#
Convert a string to a numeric value. Discard the suffix.
- static GeometryOperators.is_small(s)#
Return
Trueif the number represented by s is zero (i.e very small).
- static GeometryOperators.numeric_cs(cs_in)#
Return a list of [x,y,z] numeric values given a coordinate system as input.
- static GeometryOperators.orient_polygon(x, y, clockwise=True)#
Orient a polygon clockwise or counterclockwise. The vertices should be already ordered either way. Use this function to change the orientation. The polygon is represented by its vertices coordinates.
- Parameters:
- x
List List of x coordinates of the vertices. Length must be >= 1. Degenerate polygon with only 2 points is also accepted, in this case the points are returned unchanged.
- y
List List of y coordinates of the vertices. Must be of the same length as x.
- clockwisebool
If
Truethe polygon is oriented clockwise, ifFalseit is oriented counterclockwise. Default isTrue.
- x
- Returns:
ListofListLists of oriented vertices.
- static GeometryOperators.v_angle_sign(va, vb, vn, right_handed=True)#
Evaluate the signed angle between two geometry vectors. The sign is evaluated respect to the normal to the plane containing the two vectors as per the following rule. In case of opposite vectors, it returns an angle equal to 180deg (always positive). Assuming that the plane normal is normalized (vb == 1), the signed angle is simplified. For the right-handed rotation from Va to Vb: - atan2((va x Vb) . vn, va . vb). For the left-handed rotation from Va to Vb: - atan2((Vb x va) . vn, va . vb).
- Parameters:
- va
List List of
[x, y, z]coordinates for the first vector.- vb
List List of
[x, y, z]coordinates for the second vector.- vn
List List of
[x, y, z]coordinates for the plane normal.- right_handedbool
Whether to consider the right-handed rotation from va to vb. The default is
True. WhenFalse, left-hand rotation from va to vb is considered.
- va
- Returns:
floatAngle in radians.
- static GeometryOperators.v_angle_sign_2D(va, vb, right_handed=True)#
Evaluate the signed angle between two 2D geometry vectors. Iit the 2D version of the
GeometryOperators.v_angle_signconsidering vn = [0,0,1]. In case of opposite vectors, it returns an angle equal to 180deg (always positive).- Parameters:
- va
List List of
[x, y]coordinates for the first vector.- vb
List List of
[x, y]coordinates for the second vector.- right_handedbool
Whether to consider the right-handed rotation from Va to Vb. The default is
True. WhenFalse, left-hand rotation from Va to Vb is considered.
- va
- Returns:
floatAngle in radians.
- static GeometryOperators.point_in_polygon(point, polygon, tolerance=1e-08)#
Determine if a point is inside, outside the polygon or at exactly at the border.
The method implements the radial algorithm (https://es.wikipedia.org/wiki/Algoritmo_radial)
- pointList
List of
[x, y]coordinates.- polygonList
[[x1, x2, …, xn],[y1, y2, …, yn]]
- tolerancefloat
tolerance used for the algorithm. Default value is 1e-8.
- Returns:
int-1When the point is outside the polygon.0When the point is exactly on one of the sides of the polygon.1When the point is inside the polygon.
- static GeometryOperators.is_point_in_polygon(point, polygon)#
Determine if a point is inside or outside a polygon, both located on the same plane.
The method implements the radial algorithm (https://es.wikipedia.org/wiki/Algoritmo_radial)
- pointList
List of
[x, y]coordinates.- polygonList
[[x1, x2, …, xn],[y1, y2, …, yn]]
- Returns:
- bool
Trueif the point is inside the polygon or exactly on one of its sides.Falseotherwise.
- static GeometryOperators.are_segments_intersecting(a1, a2, b1, b2, include_collinear=True)#
Determine if the two segments a and b are intersecting.
- a1List
First point of segment a. List of
[x, y]coordinates.- a2List
Second point of segment a. List of
[x, y]coordinates.- b1List
First point of segment b. List of
[x, y]coordinates.- b2List
Second point of segment b. List of
[x, y]coordinates.- include_collinearbool
If
Truetwo segments are considered intersecting also if just one end lies on the other segment. Default isTrue.
- Returns:
- bool
Trueif the segments are intersecting.Falseotherwise.
- static GeometryOperators.is_segment_intersecting_polygon(a, b, polygon)#
Determine if a segment defined by two points
aandbintersects a polygon. Points on the vertices and on the polygon boundaries are not considered intersecting.- aList
First point of the segment. List of
[x, y]coordinates.- bList
Second point of the segment. List of
[x, y]coordinates.- polygonList
[[x1, x2, …, xn],[y1, y2, …, yn]]
- Returns:
floatTrueif the segment intersect the polygon.Falseotherwise.
- static GeometryOperators.is_perpendicular(a, b, tol=1e-06)#
Check if two vectors are perpendicular.
- static GeometryOperators.is_point_projection_in_segment(p, a, b)#
Check if a point projection lies on the segment defined by two points.
- Parameters:
- p
List List of
[x, y, z]coordinates for the reference pointp.- a
List List of
[x, y, z]coordinates for the first point of the segment.- b
List List of
[x, y, z]coordinates for the second point of the segment.
- p
- Returns:
- bool
Truewhen the projection point lies on the segment defined by the two points,Falseotherwise.
- static GeometryOperators.point_segment_distance(p, a, b)#
Calculate the distance between a point
pand a segment defined by two pointsaandb.- Parameters:
- p
List List of
[x, y, z]coordinates for the reference pointp.- a
List List of
[x, y, z]coordinates for the first point of the segment.- b
List List of
[x, y, z]coordinates for the second point of the segment.
- p
- Returns:
floatDistance between the point and the segment.
- static GeometryOperators.find_largest_rectangle_inside_polygon(polygon, partition_max_order=16)#
Find the largest area rectangles of arbitrary orientation in a polygon.
Implements the algorithm described by Rubén Molano, et al. “Finding the largest area rectangle of arbitrary orientation in a closed contour”, published in Applied Mathematics and Computation. https://doi.org/10.1016/j.amc.2012.03.063. (https://www.sciencedirect.com/science/article/pii/S0096300312003207)
- Parameters:
- polygon
List [[x1, x2, …, xn],[y1, y2, …, yn]]
- partition_max_order
float,optional Order of the lattice partition used to find the quasi-lattice polygon that approximates
polygon. Default is16.
- polygon
- Returns:
ListofListList containing the rectangles points. Return all rectangles found. List is in the form: [[[x1, y1],[x2, y2],…],[[x1, y1],[x2, y2],…],…].
- static GeometryOperators.degrees_over_rounded(angle, digits)#
Ceil of angle.
- static GeometryOperators.radians_over_rounded(angle, digits)#
Radian angle ceiling.
- static GeometryOperators.degrees_default_rounded(angle, digits)#
Convert angle to degree with given digits rounding.
- static GeometryOperators.radians_default_rounded(angle, digits)#
Convert to radians with given round.
- static GeometryOperators.find_closest_points(points_list, reference_point, tol=1e-06)#
Given a list of points, finds the closest points to a reference point. It returns a list of points because more than one can be found. It works with 2D or 3D points. The tolerance used to evaluate the distance to the reference point can be specified.
- Parameters:
- points_list
ListofList List of points. The points can be defined in 2D or 3D space.
- reference_point
List The reference point. The point can be defined in 2D or 3D space (same as points_list).
- tol
float,optional The tolerance used to evaluate the distance. Default is
1e-6.
- points_list
- Returns:
ListofList
- static GeometryOperators.mirror_point(start, reference, vector)#
Mirror point about a plane defining by a point on the plane and a normal point.
- static GeometryOperators.find_points_along_lines(points, minimum_number_of_points=3, distance_threshold=None, selected_angles=None, return_additional_info=False)#
Detect all points that are placed along lines.
The method takes as input a list of 2D points and detects all lines that contain at least 3 points. Optionally, the minimum number of points contained in a line can be specified by setting the argument
minimum_number_of_points. As default, all points along the lines are returned, regardless of their relative distance. Optionally, a distance_threshold can be set. If two points in a line are separated by a distance larger thandistance_threshold, the line is divided in two parts. If one of those parts does not satisfy theminimum_number_of_pointsrequirement, it is discarded. If distance_threshold is set (notNone), the computational time increases.- pointsList, numpy.ndarray
The points to process. Can be a list of lists where each sublist represents a 2D point
[x, y]coordinates, or a numpy array of shape (n, 2).- minimum_number_of_pointsint, optional
The minimum number of points that a line must contain. Default is
3.- distance_thresholdfloat, None, optional
If two points in a line are separated by a distance larger than distance_threshold, the line is divided in two parts. Default is
None, in which case the control is not performed.- selected_angleslist, None, optional
Specify a list of angles in degrees. If specified, the method returns only the lines which have one of the specified angles. The angle is defined as the positive angle of the infinite line with respect to the x-axis It is positive, and between 0 and 180 degrees. For example,
[90]indicated vertical lines parallel to the y-axis,[0]or[180]identifies horizontal lines parallel to the x-axis,45identifies lines parallel to the first quadrant bisector. Default isNone, in which case all lines are returned.- return_additional_infobool, optional
Whether to return additional information about the number of elements processed. The default is
True.
- Returns:
tupleThe tuple contains: - lines: a list of lists where each sublist represents a 2D point
[x, y]coordinates in each line. - lines indexes: a list of lists where each sublist represents the index of the point in each line.The index is referring to the point position in the input point list.
number of processed points: optional, returned if
return_additional_infoisTruenumber of processed lines: optional, returned if
return_additional_infoisTrue- number of detected lines after
minimum_number_of_pointsis applied: optional, returned if
return_additional_infoisTrue
- number of detected lines after
- number of detected lines after
distance_thresholdis applied: optional, returned if
return_additional_infoisTrue
- number of detected lines after
- static GeometryOperators.smallest_distance_between_polygons(polygon1, polygon2)#
Find the smallest distance between two polygons using KDTree for efficient nearest neighbor search.
Parameters: polygon1 (list of tuples): List of (x, y) coordinates representing the points of the first polygon. polygon2 (list of tuples): List of (x, y) coordinates representing the points of the second polygon.
Returns: float: The smallest distance between any two points from the two polygons.
Example: >>> polygon1 = [(1, 1), (4, 1), (4, 4), (1, 4)] >>> polygon2 = [(5, 5), (8, 5), (8, 8), (5, 8)] >>> smallest_distance_between_polygons(polygon1, polygon2) 1.4142135623730951