topologicpy.Edge module
- class topologicpy.Edge.Edge
Bases:
objectMethods
Align2D(edgeA, edgeB)Compute the 4x4 transformation matrix to fully align edgeA to edgeB.
Angle(edgeA, edgeB[, mantissa, bracket])Returns the angle in degrees between the two input edges.
Bisect(edgeA, edgeB[, length, placement, ...])Creates a bisecting edge between edgeA and edgeB.
ByFaceNormal(face[, origin, length, tolerance])Creates a straight edge representing the normal to the input face.
ByOffset2D(edge[, offset, tolerance])Creates an edge offset from the input edge in the XY plane.
ByOriginDirectionLength([origin, direction, ...])Creates a straight edge from the input parameters.
ByStartVertexEndVertex(vertexA, vertexB[, ...])Creates a straight edge that connects the input vertices.
ByVertices(*vertices[, tolerance, silent])Creates a straight edge that connects the input list of vertices.
ByVerticesCluster(cluster[, tolerance])Creates a straight edge that connects the input cluster of vertices.
Connection(edgeA, edgeB[, tolerance, silent])Returns the edge representing the connection between the first input edge to the second input edge using the two closest vertices.
Direction(edge[, mantissa])Returns the direction of the input edge expressed as a list of three numbers.
EndVertex(edge[, silent])Returns the end vertex of the input edge.
Equation2D(edge[, mantissa])Returns the 2D equation of the input edge.
Extend(edge[, distance, bothSides, reverse, ...])Extends the input edge by the input distance.
ExtendToEdge(edgeA, edgeB[, mantissa, step, ...])Extends the first input edge to meet the second input edge.
ExternalBoundary(edge[, tolerance, silent])Returns the external boundary (cluster of end vertices) of the input edge.
Index(edge, edges[, strict, tolerance])Returns index of the input edge in the input list of edges
Intersect2D(edgeA, edgeB[, silent, ...])Returns the intersection vertex of the two input edges.
IsCollinear(edgeA, edgeB[, mantissa, tolerance])Return True if the two input edges are collinear.
IsCoplanar(edgeA, edgeB[, mantissa, tolerance])Return True if the two input edges are coplanar.
IsParallel(edgeA, edgeB[, mantissa, tolerance])Return True if the two input edges are parallel.
Length(edge[, mantissa])Returns the length of the input edge.
Line([origin, length, direction, placement, ...])Creates a straight edge (line) using the input parameters.
Normal(edge[, angle])Returns the normal (perpendicular) vector to the input edge.
NormalEdge(edge[, length, u, angle, ...])Returns the normal (perpendicular) vector to the input edge as an edge.
Normalize(edge[, useEndVertex, tolerance, ...])Creates a normalized edge that has the same direction as the input edge, but a length of 1.
ParameterAtVertex(edge, vertex[, mantissa, ...])Returns the u parameter along the input edge based on the location of the input vertex.
Quadrance(edge[, mantissa])Returns the quadrance of the input edge.
Reverse(edge[, tolerance, silent])Creates an edge that has the reverse direction of the input edge.
SetLength(edge[, length, bothSides, ...])Returns an edge with the new length in the same direction as the input edge.
Spread(edgeA, edgeB[, mantissa, bracket])Returns the spread between the two input edges.
StartVertex(edge[, silent])Returns the start vertex of the input edge.
Trim(edge[, distance, bothSides, reverse, ...])Trims the input edge by the input distance.
TrimByEdge(edgeA, edgeB[, reverse, ...])Trims the first input edge by the second input edge.
VertexByDistance(edge[, distance, origin, ...])Creates a vertex along the input edge offset by the input distance from the input origin.
VertexByParameter(edge[, u])Creates a vertex along the input edge offset by the input u parameter.
Vertices(edge[, silent])Returns the list of vertices of the input edge.
- static Align2D(edgeA, edgeB)
Compute the 4x4 transformation matrix to fully align edgeA to edgeB.
- Parameters:
edge1 (Edge): The source 2D edge to transform. edge2 (Edge): The target 2D edge.
- Returns:
list: A 4x4 transformation matrix.
- static Angle(edgeA, edgeB, mantissa: int = 6, bracket: bool = False) float
Returns the angle in degrees between the two input edges.
- Parameters
- edgeAtopologic_core.Edge
The first input edge.
- edgeBtopologic Edge
The second input edge.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- bracketbool
If set to True, the returned angle is bracketed between 0 and 180. Default is False.
- Returns
- float
The angle in degrees between the two input edges.
- static Bisect(edgeA, edgeB, length: float = 1.0, placement: int = 0, tolerance: float = 0.0001, silent: bool = False)
Creates a bisecting edge between edgeA and edgeB.
- Parameters
- edgeAtopologic_core.Edge
The first topologic Edge.
- edgeBtopologic Edge
The second topologic Edge.
- lengthfloat , optional
The desired length of the bisecting edge. Default is 1.0.
- placementint , optional
The desired placement of the bisecting edge. If set to 0, the bisecting edge centroid will be placed at the end vertex of the first edge. If set to 1, the bisecting edge start vertex will be placed at the end vertex of the first edge. If set to 2, the bisecting edge end vertex will be placed at the end vertex of the first edge. If set to any number other than 0, 1, or 2, the bisecting edge centroid will be placed at the end vertex of the first edge. Default is 0.
- tolerancefloat , optional
The desired tolerance to decide if an Edge can be created. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The created bisecting edge.
- static ByFaceNormal(face, origin=None, length: float = 1.0, tolerance: float = 0.0001)
Creates a straight edge representing the normal to the input face.
- Parameters
- facetopologic_core.Face
The input face
- origintopologic_core.Vertex , optional
The desired origin of the edge. If set to None, the centroid of the face is chosen as the origin of the edge. Default is None.
- lengthfloat , optional
The desired length of the edge. Default is 1.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- edgetopologic_core.Edge
The created edge.
- static ByOffset2D(edge, offset: float = 1.0, tolerance: float = 0.0001)
Creates an edge offset from the input edge in the XY plane.
- static ByOriginDirectionLength(origin=None, direction=[0, 0, 1], length: float = 1.0, tolerance: float = 0.0001, silent: bool = False)
Creates a straight edge from the input parameters.
- Parameters
- origintopologic_core.Vertex
The origin (start vertex) of the edge.
- directionlist , optional
The desired direction vector of the edge. Default is [0,0,1] (pointing up in the Z direction)
- length: float , optional
The desired length of edge. Default is 1.0.
- tolerancefloat , optional
The desired tolerance to decide if an edge can be created. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The created edge.
- static ByStartVertexEndVertex(vertexA, vertexB, tolerance: float = 0.0001, silent=False)
Creates a straight edge that connects the input vertices.
- Parameters
- vertexAtopologic_core.Vertex
The first input vertex. This is considered the start vertex.
- vertexBtopologic_core.Vertex
The second input vertex. This is considered the end vertex.
- tolerancefloat , optional
The desired tolerance to decide if an Edge can be created. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- edgetopologic_core.Edge
The created edge.
- static ByVertices(*vertices, tolerance: float = 0.0001, silent: bool = False)
Creates a straight edge that connects the input list of vertices.
- Parameters
- verticeslist
The input list of vertices. The first item is considered the start vertex and the last item is considered the end vertex.
- tolerancefloat , optional
The desired tolerance to decide if an edge can be created. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The created edge.
- static ByVerticesCluster(cluster, tolerance: float = 0.0001)
Creates a straight edge that connects the input cluster of vertices.
- Parameters
- clustertopologic_core.Cluster
The input cluster of vertices. The first item is considered the start vertex and the last item is considered the end vertex.
- tolerancefloat , optional
The desired tolerance to decide if an edge can be created. Default is 0.0001.
- Returns
- topologic_core.Edge
The created edge.
- static Connection(edgeA, edgeB, tolerance: float = 0.0001, silent: bool = False)
Returns the edge representing the connection between the first input edge to the second input edge using the two closest vertices.
- Parameters
- edgeAtopologic_core.Edge
The first input edge. This edge will be extended to meet edgeB.
- edgeBtopologic_core.Edge
The second input edge. This edge will be used to extend edgeA.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge or topologic_core.Wire
The connected edge. Since it is made of two edges, this method returns a Wire.
- static Direction(edge, mantissa: int = 6) list
Returns the direction of the input edge expressed as a list of three numbers.
- Parameters
- edgetopologic_core.Edge
The input edge.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- Returns
- list
The direction of the input edge.
- static EndVertex(edge, silent: bool = False)
Returns the end vertex of the input edge.
- Parameters
- edgetopologic_core.Edge
The input edge.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Vertex
The end vertex of the input edge.
- static Equation2D(edge, mantissa=6)
Returns the 2D equation of the input edge. This is assumed to be in the XY plane.
- Parameters
- edgetopologic_core.Edge
The input edge.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- Returns
- dict
The equation of the edge stored in a dictionary. The dictionary has the following keys: “slope”: The slope of the line. This can be float(‘inf’) “x_intercept”: The X axis intercept. This can be None. “y_intercept”: The Y axis intercept. This can be None.
- static Extend(edge, distance: float = 1.0, bothSides: bool = True, reverse: bool = False, tolerance: float = 0.0001, silent: bool = False)
Extends the input edge by the input distance.
- Parameters
- edgetopologic_core.Edge
The input edge.
- distancefloat , optional
The offset distance. Default is 1.
- bothSidesbool , optional
If set to True, the edge will be extended by half the distance at each end. Default is False.
- reversebool , optional
If set to True, the edge will be extended from its start vertex. Otherwise, it will be extended from its end vertex. Default is False.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The extended edge.
- static ExtendToEdge(edgeA, edgeB, mantissa: int = 6, step: bool = True, tolerance: float = 0.0001, silent: bool = False)
Extends the first input edge to meet the second input edge.
- Parameters
- edgeAtopologic_core.Edge
The first input edge. This edge will be extended to meet edgeB.
- edgeBtopologic_core.Edge
The second input edge. This edge will be used to extend edgeA.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The extended edge.
- static ExternalBoundary(edge, tolerance: float = 0.0001, silent: bool = False)
Returns the external boundary (cluster of end vertices) of the input edge.
- Parameters
- edgetopologic_core.Edge
The input edge.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Cluster
The external boundary of the input edge. This is a cluster of the edge’s end vertices.
- static Index(edge, edges: list, strict: bool = False, tolerance: float = 0.0001) int
Returns index of the input edge in the input list of edges
- Parameters
- edgetopologic_core.Edge
The input edge.
- edgeslist
The input list of edges.
- strictbool , optional
If set to True, the edge must be strictly identical to the one found in the list. Otherwise, a distance comparison is used. Default is False.
- tolerancefloat , optional
The tolerance for computing if the input edge is identical to an edge from the list. Default is 0.0001.
- Returns
- int
The index of the input edge in the input list of edges.
- static Intersect2D(edgeA, edgeB, silent: bool = False, mantissa: int = 6, tolerance: float = 0.0001)
Returns the intersection vertex of the two input edges. This is assumed to be in the XY plane. The intersection vertex does not necessarily fall within the extents of either edge.
- Parameters
- edgeAtopologic_core.Edge
The first input edge.
- edgeBtopologic_core.Edge
The second input edge.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- Returns
- topologic_core.Vertex
The intersection vertex or None if the edges are parallel or collinear.
- static IsCollinear(edgeA, edgeB, mantissa: int = 6, tolerance: float = 0.0001)
Return True if the two input edges are collinear. Returns False otherwise. This code is based on a contribution by https://github.com/gaoxipeng
- Parameters
- edgeAtopologic_core.Edge
The first input edge.
- edgeBtopologic_core.Edge
The second input edge.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- bool
True if the two edges are collinear. False otherwise.
- static IsCoplanar(edgeA, edgeB, mantissa: int = 6, tolerance: float = 0.0001)
Return True if the two input edges are coplanar. Returns False otherwise.
- Parameters
- edgeAtopologic_core.Edge
The first input edge.
- edgeBtopologic_core.Edge
The second input edge.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- bool
True if the two edges are coplanar. False otherwise.
- static IsParallel(edgeA, edgeB, mantissa: int = 6, tolerance: float = 0.0001)
Return True if the two input edges are parallel. Returns False otherwise.
- Parameters
- edgeAtopologic_core.Edge
The first input edge.
- edgeBtopologic_core.Edge
The second input edge.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- bool
True if the two edges are collinear. False otherwise.
- static Length(edge, mantissa: int = 6) float
Returns the length of the input edge.
- Parameters
- edgetopologic_core.Edge
The input edge.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- Returns
- float
The length of the input edge.
- static Line(origin=None, length: float = 1, direction: list = [1, 0, 0], placement: str = 'center', tolerance: float = 0.0001)
Creates a straight edge (line) using the input parameters.
- Parameters
- origintopologic_core.Vertex , optional
The origin location of the box. Default is None which results in the edge being placed at (0, 0, 0).
- lengthfloat , optional
The desired length of the edge. Default is 1.0.
- directionlist , optional
The desired direction (vector) of the edge. Default is [1,0,0] (along the X-axis).
- placementstr , optional
The desired placement of the edge. The options are: 1. “center” which places the center of the edge at the origin. 2. “start” which places the start of the edge at the origin. 3. “end” which places the end of the edge at the origin. The default is “center”. It is case insensitive.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- ——-
- topologic_core.Edge
The created edge
- static Normal(edge, angle: float = 0.0)
Returns the normal (perpendicular) vector to the input edge.
- Parameters
- edgetopologic_core.Edge
The input edge.
- anglefloat , optional
The desired rotational offset angle in degrees for the normal edge. This rotates the normal edge by the angle value around the axis defined by the input edge. Default is 0.0.
- Returns
- list
The normal (perpendicular ) vector to the input edge.
- static NormalEdge(edge, length: float = 1.0, u: float = 0.5, angle: float = 0.0, tolerance: float = 0.0001, silent: bool = False)
Returns the normal (perpendicular) vector to the input edge as an edge.
- Parameters
- edgetopologic_core.Edge
The input edge.
- lengthfloat , optional
The desired length of the normal edge. Default is 1.0.
- ufloat , optional
The desired u parameter placement of the normal edge. A value of 0.0 places the normal edge at the start vertex of the input edge, a value of 0.5 places the normal edge at the midpoint of the input edge, and a value of 1.0 places the normal edge at the end vertex of the input edge. Default is 0.5
- anglefloat , optional
The desired rotational offset angle in degrees for the normal edge. This rotates the normal edge by the angle value around the axis defined by the input edge. Default is 0.0.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The normal (perpendicular) vector to the input edge as an edge.
- static Normalize(edge, useEndVertex: bool = False, tolerance: float = 0.0001, silent: bool = False)
Creates a normalized edge that has the same direction as the input edge, but a length of 1.
- Parameters
- edgetopologic_core.Edge
The input edge.
- useEndVertexbool , optional
If True the normalized edge end vertex will be placed at the end vertex of the input edge. Otherwise, the normalized edge start vertex will be placed at the start vertex of the input edge. Default is False.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The normalized edge.
- static ParameterAtVertex(edge, vertex, mantissa: int = 6, silent: bool = False) float
Returns the u parameter along the input edge based on the location of the input vertex.
- Parameters
- edgetopologic_core.Edge
The input edge.
- vertextopologic_core.Vertex
The input vertex.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- float
The u parameter along the input edge based on the location of the input vertex.
- static Quadrance(edge, mantissa: int = 6) float
Returns the quadrance of the input edge. See: https://en.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
- Parameters
- edgetopologic_core.Edge
The input edge.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- Returns
- float
The quadrance of the input edge.
- static Reverse(edge, tolerance: float = 0.0001, silent: bool = False)
Creates an edge that has the reverse direction of the input edge.
- Parameters
- edgetopologic_core.Edge
The input edge.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The reversed edge.
- static SetLength(edge, length: float = 1.0, bothSides: bool = True, reverse: bool = False, tolerance: float = 0.0001)
Returns an edge with the new length in the same direction as the input edge.
- Parameters
- edgetopologic_core.Edge
The input edge.
- lengthfloat , optional
The desired length of the edge. Default is 1.
- bothSidesbool , optional
If set to True, the edge will be offset symmetrically from each end. Default is True.
- reversebool , optional
If set to True, the edge will be offset from its start vertex. Otherwise, it will be offset from its end vertex. Default is False.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- topologic_core.Edge
The extended edge.
- static Spread(edgeA, edgeB, mantissa: int = 6, bracket: bool = False) float
Returns the spread between the two input edges.
- Spread is the rational trigonometry equivalent of angle and is defined as:
spread = sin^2(theta)
spread = 0 : edges are parallel
spread = 1 : edges are perpendicular
0 <= spread <= 1
No trigonometric functions are used
- Parameters
- edgeAtopologic_core.Edge
The first input edge.
- edgeBtopologic_core.Edge
The second input edge.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- bracketbool
If set to True, the spread is bracketed to represent the acute case (i.e. invariant under edge reversal). Default is False.
- Returns
- float
The spread between the two input edges.
- static StartVertex(edge, silent: bool = False)
Returns the start vertex of the input edge.
- Parameters
- edgetopologic_core.Edge
The input edge.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Vertex
The start vertex of the input edge.
- static Trim(edge, distance: float = 0.0, bothSides: bool = True, reverse: bool = False, tolerance: float = 0.0001, silent: bool = False)
Trims the input edge by the input distance.
- Parameters
- edgetopologic_core.Edge
The input edge.
- distancefloat , optional
The offset distance. Default is 0.
- bothSidesbool , optional
If set to True, the edge will be trimmed by half the distance at each end. Default is False.
- reversebool , optional
If set to True, the edge will be trimmed from its start vertex. Otherwise, it will be trimmed from its end vertex. Default is False.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The trimmed edge.
- static TrimByEdge(edgeA, edgeB, reverse: bool = False, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)
Trims the first input edge by the second input edge.
- Parameters
- edgeAtopologic_core.Edge
The first input edge. This edge will be trimmed by edgeB.
- edgeBtopologic_core.Edge
The second input edge. This edge will be used to trim edgeA.
- reversebool , optional
If set to True, which segment is preserved is reversed. Otherwise, it is not. Default is False.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Edge
The trimmed edge.
- static VertexByDistance(edge, distance: float = 0.0, origin=None, mantissa: int = 6, tolerance: float = 0.0001)
Creates a vertex along the input edge offset by the input distance from the input origin.
- Parameters
- edgetopologic_core.Edge
The input edge.
- distancefloat , optional
The offset distance. Default is 0.
- origintopologic_core.Vertex , optional
The origin of the offset distance. If set to None, the origin will be set to the start vertex of the input edge. Default is None.
- mantissaint , optional
The desired length of the mantissa. Default is 6
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- topologic_core.Vertex
The created vertex.
- static VertexByParameter(edge, u: float = 0.0)
Creates a vertex along the input edge offset by the input u parameter.
- Parameters
- edgetopologic_core.Edge
The input edge.
- ufloat , optional
The u parameter along the input topologic Edge. A parameter of 0 returns the start vertex. A parameter of 1 returns the end vertex. Default is 0.
- Returns
- topologic_core.Vertex
The created vertex.
- static Vertices(edge, silent: bool = False) list
Returns the list of vertices of the input edge.
- Parameters
- edgetopologic_core.Edge
The input edge.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
The list of vertices.