Edges¶
Edges related classes.
- class design3d.edges.Arc2D(circle: Circle2D, start: Point2D, end: Point2D, reference_path: str = '#', name: str = '')[source]¶
-
Class to draw Arc2D.
angle: the angle measure always >= 0
- property angle¶
Arc angle property.
- Returns:
arc angle.
- arcellipse_intersections(arcellipse, abs_tol: float = 1e-06)[source]¶
Intersections between an arc 2d and arc-ellipse 2d.
- Parameters:
arcellipse – arc-ellipse 2d.
abs_tol – tolerance
- Returns:
list of intersection points.
- property bounding_rectangle¶
Gets the bounding rectangle for an Arc 2D.
- bsplinecurve_intersections(bspline, abs_tol: float = 1e-06)[source]¶
Intersections between an arc 2d and bspline curve 2d.
- Parameters:
bspline – bspline curve 2d.
abs_tol – tolerance.
- Returns:
list of intersection points.
- center_of_mass()[source]¶
Calculates the center of mass of the Arc2D.
- Returns:
center of mass point.
- copy(*args, **kwargs)[source]¶
Creates and returns a deep copy of the Arc2D object.
- Parameters:
*args –
Variable-length argument list.
**kwargs –
Arbitrary keyword arguments.
- Returns:
A new Arc2D object that is a deep copy of the original.
- frame_mapping(frame: Frame2D, side: str)[source]¶
Changes vector frame_mapping and return a new Arc2D.
side = ‘old’ or ‘new’
- classmethod from_3_points(point1, point2, point3, reference_path: str = '#', name: str = '')[source]¶
Creates a circle 2d from 3 points.
- Returns:
circle 2d.
- property is_trigo¶
Return True if circle is counterclockwise.
- line_intersections(line2d: Line2D)[source]¶
Calculates the intersection between a line and an Arc2D.
- Parameters:
line2d – Line2D to verify intersections.
- Returns:
a list with intersections points.
- linesegment_intersections(linesegment2d: LineSegment2D, abs_tol=1e-06)[source]¶
Calculates the intersection between a LineSegment2D and an Arc2D.
- Parameters:
linesegment2d – LineSegment2D to verify intersections.
abs_tol – tolerance.
- Returns:
a list with intersections points.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Plot arc 2d with Matplotlib.
- property points¶
- rotation(center: Point2D, angle: float)[source]¶
Arc2D rotation.
- Parameters:
center – rotation center
angle – angle rotation.
- Returns:
a new rotated Arc2D.
- straight_line_area()[source]¶
Calculates the area of the arc 2D, with line drawn from start to end.
- Returns:
straight_line_area.
- straight_line_point_belongs(point)[source]¶
Verifies if a point belongs to the surface created by closing the edge.
- Parameters:
point – Point to be verified.
- Returns:
Return True if the point belongs to this surface, or False otherwise.
- straight_line_second_moment_area(point: Point2D)[source]¶
Straight line second moment area for an Arc 2D.
- to_3d(plane_origin, x, y)[source]¶
Transforms the arc 2D into a 3D arc.
- Parameters:
plane_origin (design3d.Point3D) – The origin of plane to draw the arc 3D.
x (design3d.Vector3D) – First direction of the plane
y (design3d.Vector3D) – Second direction of the plane.
- Returns:
A 3D arc.
- Type:
Arc3D.
- class design3d.edges.Arc3D(circle, start, end, name='')[source]¶
-
An arc is defined by a starting point, an end point and an interior point.
- abscissa(point: Point3D, tol: float = 1e-06)[source]¶
Calculates the abscissa given a point in the Arc3D.
- Parameters:
point – point to calculate the abscissa.
tol – (Optional) Confusion distance to consider points equal. Default 1e-6.
- Returns:
corresponding abscissa.
- arc_intersections(other_arc, abs_tol: 1e-06)[source]¶
Calculates intersections between two Arc3D.
- Parameters:
other_arc – Arc 3D to verify intersections.
abs_tol – tolerance.
- Returns:
list with intersections points between the two Arc3D.
- arcellipse_intersections(arcellipse3d, abs_tol: float = 1e-06)[source]¶
Calculates intersections between two Arc3D.
- Parameters:
arcellipse3d – ArcEllipse 3D to verify intersections.
abs_tol – Tolerance.
- Returns:
List with intersections points between ArcEllipse3D and Arc3D.
- property bounding_box¶
Bounding box for Arc 3D.
- direction_vector(abscissa)[source]¶
Calculates a direction vector at a given abscissa of the Arc3D.
- Parameters:
abscissa – abscissa where in the curve the direction vector should be calculated.
- Returns:
Corresponding direction vector.
- distance_arc(arc3d, return_points=False)[source]¶
Gets the minimum distance between two Arcs 3D.
- Parameters:
arc3d – other arc 3d.
return_points – boolean to decide weather to return the corresponding minimal distance points or not.
- Returns:
minimum distance / minimal distance with corresponding points.
- distance_linesegment(linesegment3d, return_points=False)[source]¶
Gets the minimum distance between an Arc 3D and Line Segment 3D.
- Parameters:
linesegment3d – other line segment 3d.
return_points – boolean to decide weather to return the corresponding minimal distance points or not.
- Returns:
minimum distance / minimal distance with corresponding points.
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes vector frame_mapping and return a new Arc3D.
side = ‘old’ or ‘new’
- classmethod from_3_points(point1, point2, point3, name: str = '')[source]¶
Creates an Arc 3d using three points.
- Parameters:
point1 – start point.
point2 – interior point.
point3 – end point.
name – object’s name.
- Returns:
Arc 3D.
- classmethod from_angle(start: Point3D, angle: float, axis_point: Point3D, axis: Vector3D, name: str = '')[source]¶
Gives the arc3D from a start, an angle and an axis.
- property is_trigo¶
Return True if circle is counterclockwise.
- line_intersections(line3d: Line3D, tol: float = 1e-06)[source]¶
Calculates intersections between an Arc3D and a Line3D.
- Parameters:
line3d – line to verify intersections.
tol – maximum tolerance.
- Returns:
list with intersections points between line and Arc3D.
- linesegment_intersections(linesegment3d: LineSegment3D, abs_tol: float = 1e-06)[source]¶
Calculates intersections between an Arc3D and a LineSegment3D.
- Parameters:
linesegment3d – linesegment to verify intersections.
abs_tol – tolerance to be considered while validating an intersection.
- Returns:
list with intersections points between linesegment and Arc3D.
- minimum_distance_points_arc(other_arc)[source]¶
Calculates the minimum distance points between two arcs.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Plot method for Arc 3D using Matplotlib.
- plot2d(center: Point3D = Point3D(0.0, 0.0, 0.0), x3d: Vector3D = Vector3D(1.0, 0.0, 0.0), y3d: Vector3D = Vector3D(0.0, 1.0, 0.0), ax=None, color='k')[source]¶
Plot data.
- point_at_abscissa(abscissa)[source]¶
Calculates a point in the Arc3D at a given abscissa.
- Parameters:
abscissa – abscissa where in the curve the point should be calculated.
- Returns:
Corresponding point.
- point_belongs(point, abs_tol: float = 1e-06)[source]¶
Check if a point 3d belongs to the arc_3d or not.
- Parameters:
point – point to be verified is on arc.
abs_tol – tolerance allowed.
- Returns:
True if point is on Arc, False otherwise.
- property points¶
Gets arc points.
- Returns:
list with arc points.
- revolution(axis_point: Point3D, axis: Vector3D, angle: float)[source]¶
Revolution of Arc 3D around an axis.
- Parameters:
axis_point – revolution axis point.
axis – revolution axis.
angle – revolution angle.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
Arc3D rotation.
- Parameters:
center – rotation center
axis – rotation axis
angle – angle rotation
- Returns:
a new rotated Arc3D
- sweep(*args, **kwargs)[source]¶
Arc 3D is used as path for sweeping given section through it.
- Returns:
- to_2d(plane_origin, x, y)[source]¶
Transforms a Arc3D into an Arc2D, given a plane origin and an u and v plane vector.
- Parameters:
plane_origin – plane origin.
x – plane u vector.
y – plane v vector.
- Returns:
Arc2D.
- to_dict(use_pointers: bool = False, memo=None, path: str = '#', id_method=True, id_memo=None)[source]¶
Saves the object parameters into a dictionary.
- class design3d.edges.ArcEllipse2D(ellipse: Ellipse2D, start: Point2D, end: Point2D, name: str = '')[source]¶
Bases:
ArcEllipseMixin
,Edge
An 2-dimensional elliptical arc.
- Parameters:
ellipse (design3d.curves.Ellipse2D.) – An ellipse curve, as base for the arc ellipse.
start (
design3d.Point2D
) – The starting point of the elliptical arcend (
design3d.Point2D
) – The end point of the elliptical arcname (str, optional) – The name of the elliptical arc. Default value is ‘’
- abscissa(point: Point2D, tol: float = 1e-06)[source]¶
Calculates the abscissa of a given point.
- Parameters:
point – point for calculating abscissa
tol – tolerance.
- Returns:
a float, between 0 and the arc ellipse 2d’s length
- property angle¶
Gets arc of ellipse angle.
- property angle_end¶
Gets arc of ellipse ending angle.
- property angle_start¶
Gets arc of ellipse starting angle.
- property bounding_rectangle¶
Calculates the bounding rectangle for the arc ellipse 2d.
- Returns:
Bounding Rectangle object.
- bsplinecurve_intersections(bspline, abs_tol: float = 1e-06)[source]¶
Intersections between an Arc Ellipse 2D and a bSpline 2D.
- Parameters:
bspline – bspline 2D to verify intersections.
abs_tol – tolerance.
- Returns:
List with all intersections.
- property center¶
Gets ellipse’s center point.
- direction_vector(abscissa)[source]¶
Calculates the tangent vector to an ellipse at a given abscissa.
- Parameters:
abscissa (float.) – The abscissa value at which the tangent vector is to be calculated.
- Returns:
The tangent vector to the ellipse at the given abscissa.
- Return type:
design3d.Vector2D.
- Raises:
ValueError If the abscissa is out of range.
- discretization_points(*, number_points: int = None, angle_resolution: int = None)[source]¶
Discretization of an Edge to have “n” points.
- Parameters:
number_points – the number of points (including start and end points) if unset, only start and end will be returned.
angle_resolution – if set, the sampling will be adapted to have a controlled angular distance. Useful to mesh an arc.
- Returns:
a list of sampled points.
- frame_mapping(frame: Frame2D, side: str)[source]¶
Changes frame_mapping and return a new Arc Ellipse 2D.
side = ‘old’ or ‘new’
- classmethod from_3_points_and_center(start, interior, end, center, name: str = '')[source]¶
Creates an arc ellipse using 3 points and a center.
- Parameters:
start – start point.
interior – interior point.
end – end point.
center – ellipse’s point.
name – object’s name.
- Returns:
An arc-ellipse2D object.
- is_close(other_edge, tol: float = 1e-06)[source]¶
Checks if two arc-ellipse are the same considering the Euclidean distance.
- Parameters:
other_edge – other arc-ellipse.
tol (float, optional) – The tolerance under which the Euclidean distance is considered equal to 0, defaults to 1e-6.
- line_intersections(line2d: Line2D, tol: float = 1e-06)[source]¶
Intersections between an Arc Ellipse 2D and a Line 2D.
- Parameters:
line2d – Line 2D to verify intersections
tol – maximum tolerance.
- Returns:
List with all intersections
- linesegment_intersections(linesegment2d: LineSegment2D, abs_tol=1e-06)[source]¶
Intersections between an Arc Ellipse 2D and a Line Segment 2D.
- Parameters:
linesegment2d – LineSegment 2D to verify intersections.
abs_tol – tolerance.
- Returns:
List with all intersections.
- normal_vector(abscissa)[source]¶
Calculates the normal vector to an ellipse at a given abscissa.
- Parameters:
abscissa (float.) – The abscissa value at which the normal vector is to be calculated.
- Returns:
The normal vector to the ellipse at the given abscissa.
- Return type:
design3d.Vector2D.
- Raises:
ValueError If the abscissa is out of range.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Plot arc-ellipse 2d using Matplotlib.
- Parameters:
ax – Matplotlib plot if there exists any.
edge_style – edge styles.
- Returns:
Matplotlib plot
- point_belongs(point, abs_tol: float = 1e-06)[source]¶
Verifies if a point belongs to the arc ellipse 2d.
- Parameters:
point – point to be verified
abs_tol – tolerance applied during calculations
- Returns:
True if the point belongs, False otherwise
- property points¶
- rotation(center, angle: float)[source]¶
Rotation of ellipse around a center and an angle.
- Parameters:
center – center of the rotation.
angle – angle to rotated of.
- Returns:
a rotated new ellipse.
- split(split_point, tol: float = 1e-06)[source]¶
Splits arc-ellipse at a given point.
- Parameters:
split_point – splitting point.
tol – tolerance.
- Returns:
list of two Arc-Ellipse.
- straight_line_area()[source]¶
Calculates the area of the elliptic arc, with line drawn from start to end.
- Returns:
straight_line_area.
- straight_line_center_of_mass()[source]¶
Straight line center of mass.
PS.: This is an approximation.
- straight_line_point_belongs(point)[source]¶
Verifies if a point belongs to the surface created by closing the edge.
- Parameters:
point – Point to be verified
- Returns:
Return True if the point belongs to this surface, or False otherwise
- to_3d(plane_origin, x, y)[source]¶
Transforms the arc of ellipse 2D into a 3D arc of ellipse.
- Parameters:
plane_origin (design3d.Point3D) – The origin of plane to draw the arc of ellipse 3D.
x (design3d.Vector3D) – First direction of the plane
y (design3d.Vector3D) – Second direction of the plane.
- Returns:
A 3D arc of ellipse.
- Type:
ArcEllipse3D.
- class design3d.edges.ArcEllipse3D(ellipse: Ellipse3D, start: Point3D, end: Point3D, name='')[source]¶
Bases:
ArcEllipseMixin
,Edge
An arc is defined by a starting point, an end point and an interior point.
- abscissa(point: Point3D, tol: float = 1e-06)[source]¶
Calculates the abscissa a given point.
- Parameters:
point – point to calculate abscissa.
tol – tolerance allowed.
- Returns:
abscissa
- arcellipse_intersections(arcellipse3d, abs_tol: float = 1e-06)[source]¶
Gets the intersections between an Ellipse 3D and a Line Segment 3D.
- Parameters:
arcellipse3d – The other linesegment.
abs_tol – The absolute tolerance.
- Returns:
A list with the intersections points between the two edges.
- property bounding_box¶
Getter Bounding Box for an arc ellipse 3d.
- Returns:
bounding box.
- property center¶
Gets ellipse’s center point.
- direction_vector(abscissa)[source]¶
Returns the tangent vector at a given abscissa along the ArcEllipse3D.
This method calculates and returns the tangent vector at a specific abscissa along the ArcEllipse3D, which represents the direction of the curve at that point.
- Parameters:
abscissa (float) – The parameter value (abscissa) along the curve.
- Returns:
Vector3D A Vector3D object representing the tangent vector at the given abscissa.
- Raises:
ValueError: If the abscissa is out of the valid range of the curve.
- discretization_points(*, number_points: int = None, angle_resolution: int = 20)[source]¶
Discretization of a Contour to have “n” points.
- Parameters:
number_points – the number of points (including start and end points) if unset, only start and end will be returned
angle_resolution – if set, the sampling will be adapted to have a controlled angular distance. Useful to mesh an arc
- Returns:
a list of sampled points
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes frame_mapping and return a new ArcEllipse3D.
- Parameters:
frame (design3d.Frame3D) – Local coordinate system.
side (str) – ‘old’ will perform a transformation from local to global coordinates. ‘new’ will perform a transformation from global to local coordinates.
- Returns:
A new transformed ArcEllipse3D.
- Return type:
- get_start_end_angles()[source]¶
Calculate the start and end angles of the ArcEllipse3D in radians.
This method computes the start and end angles of the ArcEllipse3D, which represent the angles, in radians, between the major axis of the ellipse and the start and end points on the ellipse’s boundary.
- Returns:
tuple of floats A tuple containing the start and end angles in radians.
- is_close(other_arcellipse, abs_tol: float = 1e-06)[source]¶
Verifies if two arc ellipses are the same, considereing given tolerance.
- Parameters:
other_arcellipse – other arc ellipse.
abs_tol – tolerance.
- Returns:
True or False.
- line_intersections(line, abs_tol: float = 1e-06)[source]¶
Gets the intersections between an Ellipse 3D and a Line 3D.
- Parameters:
line – The intersecting lines.
abs_tol – The absolute tolerance.
- Returns:
A list with the intersections points between the two edges.
- linesegment_intersections(linesegment, abs_tol: float = 1e-06)[source]¶
Gets the intersections between an Ellipse 3D and a Line Segment 3D.
- Parameters:
linesegment – The other linesegment.
abs_tol – The absolute tolerance.
- Returns:
A list with the intersections points between the two edges.
- property normal¶
Gets ellipse’s normal direction.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Plot the arc ellipse.
- plot2d(x3d: Vector3D = Vector3D(1.0, 0.0, 0.0), y3d: Vector3D = Vector3D(0.0, 1.0, 0.0), ax=None, color='k')[source]¶
Plot 2d for an arc ellipse 3d.
- point_at_abscissa(abscissa)[source]¶
Calculates the point at a given abscissa.
- Parameters:
abscissa – abscissa to calculate point.
- Returns:
design3d.Point3D
- point_belongs(point, abs_tol: float = 1e-06)[source]¶
Verifies if a given point lies on the arc of ellipse 3D.
- Parameters:
point – point to be verified.
abs_tol – Absolute tolerance to consider the point on the curve.
- Returns:
True is point lies on the arc of ellipse, False otherwise
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
Arc-Ellipse3D rotation.
- Parameters:
center – rotation center.
axis – rotation axis.
angle – angle rotation.
- Returns:
a new rotated Arc-Ellipse3D.
- property self_2d¶
Arc ellipse 2d version of self.
- split(split_point, tol: float = 1e-06)[source]¶
Splits arc-ellipse at a given point.
- Parameters:
split_point – splitting point.
tol – tolerance.
- Returns:
list of two Arc-Ellipse.
- to_2d(plane_origin, x, y)[source]¶
Transforms an Arc Ellipse 3D into an Arc Ellipse 2D, given a plane origin and an u and v plane vector.
- Parameters:
plane_origin – plane origin.
x – plane u vector.
y – plane v vector.
- Returns:
ArcEllipse2D.
- class design3d.edges.ArcEllipseMixin[source]¶
Bases:
object
Abstract class for ArcEllipses.
Gets the shared section between two arcs of ellipse.
- Parameters:
other_arcelipse – other arc ellipse to verify for shared section.
abs_tol – tolerance.
- Returns:
shared arc section.
- class design3d.edges.ArcMixin(circle, start, end, name: str = '')[source]¶
Bases:
object
Abstract class representing an arc.
- Parameters:
circle (Union['design3d.curves.Circle2D', 'design3d.curves.Circle2D'].) – arc related circle curve.
# :param start: The starting point # :type start: Union[
design3d.Point2D
,design3d.Point3D
] # :param end: The finish point # :type end: Union[design3d.Point2D
,design3d.Point3D
] # :param name: The name of the arc. Default value is an empty string # :type name: str, optional- property angle¶
Arc angle property.
- Returns:
arc angle.
- property center¶
Gets arc center.
- direction_vector(abscissa: float)[source]¶
Get direction vector of the Arc2D.
- Parameters:
abscissa – defines where in the Arc2D the
direction vector is to be calculated :return: The direction vector of the Arc2D
- discretization_points(*, number_points: int = None, angle_resolution: int = 20)[source]¶
Discretize an Edge to have “n” points.
- Parameters:
number_points – the number of points (including start and end points) if unset, only start and end will be returned
angle_resolution – if set, the sampling will be adapted to have a controlled angular distance. Useful to mesh an arc
- Returns:
a list of sampled points
- property frame¶
Gets the arc frame.
- get_geo_lines(tag: int, start_point_tag: int, center_point_tag: int, end_point_tag: int)[source]¶
Gets the lines that define an Arc in a .geo file.
- Parameters:
tag (int) – The linesegment index
start_point_tag (int) – The linesegment’ start point index
center_point_tag (int) – The linesegment’ center point index
end_point_tag (int) – The line segment’s end point index
- Returns:
A line
- Return type:
str
- get_geo_points()[source]¶
Gets the points that define an Arc to use them in a .geo file.
- Returns:
A list of characteristic arc points
- Return type:
List
Gets the shared section between two arcs.
- Parameters:
other_arc – other arc to verify for shared section.
abs_tol – tolerance.
- Returns:
shared arc section.
- is_close(other_edge, tol: float = 1e-06)[source]¶
Checks if two arc are the same considering the Euclidean distance.
- Parameters:
other_edge – other arc.
tol (float, optional) – The tolerance under which the Euclidean distance is considered equal to 0, defaults to 1e-6
- length()[source]¶
Calculates the length of the Arc, with its radius, and its arc angle.
- Returns:
the length of the Arc.
- normal_vector(abscissa: float)[source]¶
Get the normal vector of the Arc2D.
- Parameters:
abscissa – defines where in the Arc2D the
normal vector is to be calculated :return: The normal vector of the Arc2D
- point_at_abscissa(abscissa)[source]¶
Calculates a point in the Arc at a given abscissa.
- Parameters:
abscissa – abscissa where in the curve the point should be calculated.
- Returns:
Corresponding point.
- property radius¶
Gets arc radius.
- class design3d.edges.BSplineCurve(degree: int, control_points: List[Point2D] | List[Point3D] | ndarray[tuple[int, ...], dtype[_ScalarType_co]], knot_multiplicities: List[int] | ndarray[tuple[int, ...], dtype[_ScalarType_co]], knots: List[float] | ndarray[tuple[int, ...], dtype[_ScalarType_co]], weights: List[float] | ndarray[tuple[int, ...], dtype[_ScalarType_co]] = None, name: str = '')[source]¶
Bases:
Edge
An abstract class for B-spline curves.
The following rule must be respected : number of knots = number of control points + degree + 1.
- Parameters:
degree (int) – The degree of the B-spline curve.
control_points (Union[List[
design3d.Point2D
], List[design3d.Point3D
]]) – A list of 2 or 3-dimensional pointsknot_multiplicities (List[int]) – The vector of multiplicities for each knot
knots (List[float]) – The knot vector composed of values between 0 and 1
weights (List[float], optional) – The weight vector applied to the knot vector. Default value is None
periodic (bool, optional) – If True the B-spline curve is periodic. Default value is False
name (str, optional) – The name of the B-spline curve. Default value is ‘’
- abscissa(point: Point2D | Point3D, tol: float = 1e-07)[source]¶
Computes the abscissa of a 2D or 3D point using the least square method.
- Parameters:
point (Union[
design3d.Point2D
,design3d.Point3D
].) – The point located on the B-spline curve.tol (float, optional.) – The precision in terms of distance. Default value is 1e-6.
- Returns:
The abscissa of the point.
- Return type:
float
- abscissa_to_parameter(abscissa: float)[source]¶
Search for the value of the normalized evaluation parameter u.
- Returns:
the given point when the BSplineCurve3D is evaluated at the u value.
- property control_points¶
Return the control points of the bspline curve.
- copy(deep: bool = True, **kwargs)[source]¶
Returns a copy of the instance.
- Parameters:
deep – If False, perform a shallow copy. If True, perform a deep copy.
- cut_after(parameter: float)[source]¶
Returns the left side of the split curve at a given parameter.
- Parameters:
parameter (float) – parameter value that specifies where to split the curve.
- cut_before(parameter: float)[source]¶
Returns the right side of the split curve at a given parameter.
- Parameters:
parameter (float) – parameter value that specifies where to split the curve.
- property data¶
Returns a dictionary of the BSpline data.
- decompose(return_params: bool = False)[source]¶
Decomposes the curve into Bézier curve segments of the same degree.
- Returns:
a list of Bezier segments
- Return type:
list
- property delta¶
Evaluation delta.
Evaluation delta corresponds to the step size while
evaluate
function iterates on the knot vector to generate curve points. Decreasing step size results in generation of more curve points. Therefore, smaller the delta value, smoother the curve.- Getter:
Gets the delta value
- Setter:
Sets the delta value
- Type:
float
- derivatives(u, order)[source]¶
Evaluates n-th order curve derivatives at the given parameter value.
The output of this method is list of n-th order derivatives. If
order
is0
, then it will only output the evaluated point. Similarly, iforder
is2
, then it will output the evaluated point, 1st derivative and the 2nd derivative.- Example:
Assuming a curve self is defined on a parametric domain [0.0, 1.0]. Let’s take the curve derivative at the parametric position u = 0.35.
>>> derivatives = self.derivatives(u=0.35, order=2) >>> derivatives[0] # evaluated point, equal to crv.evaluate_single(0.35) >>> derivatives[1] # 1st derivative at u = 0.35 >>> derivatives[2] # 2nd derivative at u = 0.35
- Parameters:
u (float) – parameter value
order (int) – derivative order
- Returns:
a list containing up to {order}-th derivative of the curve
- Return type:
Union[List[design3d.Vector2D], List[design3d.Vector3D]]
- direction_vector(abscissa)[source]¶
Calculates the direction vector on the BSpline curve at given abscissa.
- Parameters:
abscissa – edge abscissa
- Returns:
direction vector
- discretization_points(*, number_points: int = None, angle_resolution: int = None)[source]¶
Linear spaced discretization of the curve.
- Parameters:
number_points (int) – The number of points to include in the discretization.
angle_resolution (int) – The resolution of the angle to use when calculating the number of points.
- Returns:
A list of discretized points on the B-spline curve.
- Return type:
- property domain¶
Domain.
Domain is determined using the knot vector(s).
- Getter:
Gets the domain
- evaluate(**kwargs)[source]¶
Evaluates the curve.
The evaluated points are stored in
evalpts
property.Keyword Arguments:
start
: start parameterstop
: stop parameter
The
start
andstop
parameters allow evaluation of a curve segment in the range [start, stop], i.e. the curve will also be evaluated at thestop
parameter value.The following examples illustrate the usage of the keyword arguments.
- evaluate_single(u)[source]¶
Calculates a point in the BSplineCurve at a given parameter u.
- Parameters:
u (float) – Curve parameter. Must be a value between 0 and 1.
- Returns:
Corresponding point.
- Return type:
Union[design3d.Point2D, Union[design3d.Point3D]
- frame_mapping(frame: Frame3D | Frame2D, side: str)[source]¶
Returns a new Revolution Surface positioned in the specified frame.
- Parameters:
frame (design3d.Frame3D) – Frame of reference
side – ‘old’ or ‘new’
- classmethod from_bsplines(bsplines: List[BSplineCurve], discretization_points: int = 10, name: str = '')[source]¶
Creates a B-spline curve from a list of B-spline curves.
- Parameters:
bsplines (List[
design3d.edges.BSplineCurve
]) – A list of B-spline curvediscretization_points (int, optional.) – The number of points for the discretization. Default value is 10
name – object’s name.
- Returns:
A merged B-spline curve
- Return type:
- classmethod from_geomdl_curve(curve, name: str = '')[source]¶
# TODO: to be completed.
- Parameters:
curve
name – curve name.
- Returns:
A reversed B-spline curve
- Return type:
- classmethod from_points_approximation(points: List[Point2D] | List[Point3D], degree: int, name: str = '', **kwargs)[source]¶
Creates a B-spline curve approximation using least squares method with fixed number of control points.
It is recommended to specify the number of control points. Please refer to The NURBS Book (2nd Edition), pp.410-413 for details.
- Parameters:
points (Union[List[
design3d.Point2D
], List[design3d.Point3D
]]) – The data pointsdegree (int) – The degree of the output parametric curve
name – (optional) Curve name.
kwargs – See below
centripetal – Activates centripetal parametrization method. Default value is False
ctrlpts_size – Number of control points. Default value is len(points) - 1
- Returns:
A B-spline curve from points approximation
- Return type:
- classmethod from_points_interpolation(points: List[Point2D] | List[Point3D], degree: int, centripetal: bool = True, name: str = ' ')[source]¶
Creates a B-spline curve interpolation through the data points.
Please refer to Algorithm A9.1 on The NURBS Book (2nd Edition), pp.369-370 for details.
- Parameters:
points (Union[List[
design3d.Point2D
], List[design3d.Point3D
]]) – The data pointsdegree (int) – The degree of the output parametric curve
centripetal – Please refer to Algorithm A9.1 on The NURBS Book (2nd Edition),
pp.369-370 for details. :type centripetal: bool :param name: curve name. :return: A B-spline curve from points interpolation :rtype:
design3d.edges.BSplineCurve
- get_abscissa_discretization(abscissa1, abscissa2, number_points: int = 10, return_abscissas: bool = False)[source]¶
Gets n discretization points between two given points of the edge.
- Parameters:
abscissa1 – Starting abscissa.
abscissa2 – Ending abscissa edge.
number_points – number of points to discretize locally.
return_abscissas – If True, returns the list of abscissas of the discretization points.
- Returns:
list of locally discretized points.
- get_geo_lines(tag: int, control_points_tags: List[int])[source]¶
Gets the lines that define a BsplineCurve in a .geo file.
- Parameters:
tag (int) – The BsplineCurve index
- Returns:
A line
- Return type:
str
- get_linesegment_intersections(linesegment)[source]¶
Calculates intersections between a BSplineCurve and a LineSegment.
- Parameters:
linesegment – linesegment to verify intersections.
- Returns:
list with the intersections points.
- get_reverse()[source]¶
Reverses the BSpline’s direction by reversing its control points.
- Returns:
A reversed B-Spline curve.
- Return type:
Gets the shared section between two BSpline curves.
- Parameters:
other_bspline2 – other arc to verify for shared section.
abs_tol – tolerance.
- Returns:
shared arc section.
- is_close(other_edge, tol: float = 1e-06)[source]¶
Checks if two bsplines are the same considering the Euclidean distance.
- Parameters:
other_edge – other bspline.
tol (float, optional) – The tolerance under which the Euclidean distance is considered equal to 0, defaults to 1e-6.
Verifies if it there is any possibility of the two bsplines share a section.
- Parameters:
other_bspline2 – other bspline.
tol – tolerance used.
- Returns:
True or False.
- property knotvector¶
Return the knot vector.
- length()[source]¶
Returns the length of the B-spline curve.
- Returns:
The length of the B-spline curve.
- Return type:
float
- line_intersections(line, tol: float = 1e-06)[source]¶
Calculates the intersections of a BSplineCurve (2D or 3D) with a Line (2D or 3D).
- Parameters:
line – line to verify intersections
tol – tolerance.
- Returns:
list of intersections
- local_discretization(point1, point2, number_points: int = 10)[source]¶
Gets n discretization points between two given points of the edge.
- Parameters:
point1 – point 1 on edge.
point2 – point 2 on edge.
number_points – number of points to discretize locally.
- Returns:
list of locally discretized points.
- local_intersections_search(line, point1, point2, abs_tol: float = 1e-06)[source]¶
Gets local intersections, between a BSpline and an infinite line.
- Parameters:
line – other line.
point1 – local point 1.
point2 – local point 2.
abs_tol – tolerance.
- Returns:
distance to edge.
- merge_with(bspline_curve: BSplineCurve)[source]¶
Merges consecutive B-spline curves to define a new merged one.
- Parameters:
bspline_curve (
design3d.edges.BSplineCurve
) – Another B-spline curve- Returns:
A merged B-spline curve
- Return type:
- merge_with_curves(curves: List[BSplineCurve])[source]¶
Merges consecutive B-spline curves to define a new merged one.
- Parameters:
curves (List[
design3d.edges.BSplineCurve
]) – A list of B-spline curves- Returns:
A merged B-spline curve
- Return type:
- normal_vector(abscissa)[source]¶
Calculates the normal vector to the BSpline curve at given abscissa.
- Returns:
the normal vector
- property periodic¶
Return True if the BSpline is periodic.
- point_at_abscissa(abscissa)[source]¶
Calculates a point in the BSplineCurve at a given abscissa.
- Parameters:
abscissa – abscissa where in the curve the point should be calculated.
- Returns:
Corresponding point.
- point_belongs(point: Point2D | Point3D, abs_tol: float = 1e-06)[source]¶
Checks if a 2D or 3D point belongs to the B-spline curve or not. It uses the point_distance.
- Parameters:
point (Union[
design3d.Point2D
,design3d.Point3D
]) – The point to be checked.abs_tol (float, optional.) – The precision in terms of distance. Default value is 1e-6
- Returns:
True if the point belongs to the B-spline curve, False otherwise
- Return type:
bool
- point_inversion(u0: float, point, maxiter: int = 50, tol1: float = 1e-07, tol2: float = 1e-08)[source]¶
Finds the equivalent B-Spline curve parameter u to a given a point 3D or 2D using an initial guess u0.
- Parameters:
u0 (float) – An initial guess between 0 and 1.
point (Union[design3d.Point2D, design3d.Point3D]) – Point to evaluation.
maxiter (int) – Maximum number of iterations.
tol1 (float) – Distance tolerance to stop.
tol2 (float) – Zero cos tolerance to stop.
- Returns:
u parameter and convergence check
- Return type:
int, bool
- point_projection(point)[source]¶
Calculates the projection of a point on the B-Spline.
- Parameters:
point – point to be verified.
- Returns:
point projection.
- point_to_parameter(point: Point2D | Point3D)[source]¶
Search for the value of the normalized evaluation parameter u.
- Returns:
the given point when the BSplineCurve3D is evaluated at the u value.
- property points¶
Evaluate the BSpline points based on the set delta value of the curve.
- property sample_size¶
Sample size.
Sample size defines the number of evaluated points to generate. It also sets the
delta
property.- Getter:
Gets sample size
- Setter:
Sets sample size
- Type:
int
- property simplify¶
Search another simplified edge that can represent the bspline.
- split(split_point: Point2D | Point3D, tol: float = 1e-06)[source]¶
Splits of B-spline curve in two pieces using a 2D or 3D point.
- Parameters:
split_point (Union[
design3d.Point2D
,design3d.Point3D
]) – The point where the B-spline curve is splittol (float, optional) – The precision in terms of distance. Default value is 1e-6
- Returns:
A list containing the first and second split of the B-spline curve
- Return type:
- straight_line_point_belongs(point)[source]¶
Verifies if a point belongs to the surface created by closing the edge.
- Parameters:
point – Point to be verified
- Returns:
Return True if the point belongs to this surface, or False otherwise
- tangent(position: float = 0.0, normalize: bool = True)[source]¶
Evaluates the tangent vector of the B-spline curve at the input parameter value.
- Parameters:
position (float) – Value of the parameter, between 0 and 1
normalize – By default return a normalized tangent vector.
- Returns:
The tangent vector
- Return type:
Union[
design3d.Point2D
,design3d.Point3D
]
- translation(offset: Vector2D | Vector3D)[source]¶
Translates the B-spline curve.
- Parameters:
offset (Union[
design3d.Vector2D
,design3d.Vector3D
]) – The translation vector- Returns:
A new translated BSplineCurve
- Return type:
- trim(point1: Point3D, point2: Point3D, same_sense: bool = True, abs_tol: float = 1e-06)[source]¶
Trims a bspline curve between two points.
- Parameters:
point1 – point 1 used to trim.
point2 – point2 used to trim.
same_sense – Used for periodical curves only. Indicates whether the curve direction agrees with (True) or is in the opposite direction (False) to the edge direction. By default, it’s assumed True
abs_tol – Point confusion precision.
- Returns:
New BSpline curve between these two points.
- class design3d.edges.BSplineCurve2D(degree: int, control_points: List[Point2D], knot_multiplicities: List[int], knots: List[float], weights: List[float] = None, name: str = '')[source]¶
Bases:
BSplineCurve
A class for 2-dimensional B-spline curves.
The following rule must be respected : number of knots = number of control points + degree + 1.
- Parameters:
degree (int) – The degree of the 2-dimensional B-spline curve
control_points (List[
design3d.Point2D
]) – A list of 2-dimensional pointsknot_multiplicities (List[int]) – The vector of multiplicities for each knot
knots (List[float]) – The knot vector composed of values between 0 and 1
weights (List[float], optional) – The weight vector applied to the knot vector. Default value is None
periodic (bool, optional) – If True the B-spline curve is periodic. Default value is False
name (str, optional) – The name of the B-spline curve. Default value is ‘’
- arc_intersections(arc, abs_tol=1e-06)[source]¶
Calculates intersections between a BSpline Curve 2D and an arc 2D.
- Parameters:
arc – arc to verify intersections.
abs_tol – tolerance.
- Returns:
list with the intersections points.
- property bounding_rectangle¶
Computes the bounding rectangle of the 2-dimensional B-spline curve.
- Returns:
The bounding rectangle.
- Return type:
- bsplinecurve_intersections(bspline, abs_tol=1e-06)[source]¶
Calculates intersections between two BSpline Curve 2D.
- Parameters:
bspline – bspline to verify intersections.
abs_tol – tolerance.
- Returns:
list with the intersections points.
Verifies if it there is any possibility of the two bsplines share a section.
- Parameters:
other_bspline2 – other bspline.
tol – tolerance used.
- Returns:
True or False.
- linesegment_intersections(linesegment2d, abs_tol: float = 1e-06)[source]¶
Calculates intersections between a BSpline Curve 2D and a Line Segment 2D.
- Parameters:
linesegment2d – line segment to verify intersections.
abs_tol – tolerance.
- Returns:
list with the intersections points.
- offset(offset_length: float)[source]¶
Offsets a BSplineCurve2D in one of its normal direction.
- Parameters:
offset_length – the length taken to offset the BSpline. if positive, the offset is in the normal direction of the curve. if negative, in the opposite direction of the normal.
- Returns:
returns an offset bsplinecurve2D, created with from_points_interpolation.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Plot a B-Spline curve 2D.
- class design3d.edges.BSplineCurve3D(degree: int, control_points: List[Point3D], knot_multiplicities: List[int], knots: List[float], weights: List[float] = None, name: str = '')[source]¶
Bases:
BSplineCurve
A class for 3-dimensional B-spline curves.
The following rule must be respected : number of knots = number of control points + degree + 1
- Parameters:
degree (int) – The degree of the 3-dimensional B-spline curve
control_points (List[
design3d.Point3D
]) – A list of 3-dimensional pointsknot_multiplicities (List[int]) – The vector of multiplicities for each knot
knots (List[float]) – The knot vector composed of values between 0 and 1
weights (List[float], optional) – The weight vector applied to the knot vector. Default value is None
periodic (bool, optional) – If True the B-spline curve is periodic. Default value is False
name (str, optional) – The name of the B-spline curve. Default value is ‘’
- arc_intersections(arc, abs_tol=1e-06)[source]¶
Calculates intersections between a BSpline Curve 3D and an arc 3D.
- Parameters:
arc – arc to verify intersections.
abs_tol – tolerance.
- Returns:
list with the intersections points.
- property bounding_box¶
Returns bounding box.
- circle_intersections(circle, abs_tol: float = 1e-06)[source]¶
Get the intersections with the specified circle.
- curvature(u: float, point_in_curve: bool = False)[source]¶
Returns the curvature of a curve and the point where it is located.
- curve_intersections(curve, abs_tol: float = 1e-06)[source]¶
Get the intersections with the specified curve.
- direction_vector(abscissa=0.0)[source]¶
Gets direction vector at given abscissa value (value between o and bspline length).
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Converts a step primitive to a BSplineCurve3D.
- Parameters:
arguments (list) – The arguments of the step primitive.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated
- Returns:
The corresponding BSplineCurve3D.
- Return type:
- get_direction_vector(abscissa=0.0)[source]¶
Calculates direction vector at given abscissa value (value between o and bspline length).
- global_maximum_curvature(nb_eval: int = 21, point_in_curve: bool = False)[source]¶
Returns the global maximum curvature of a curve and the point where it is located.
Verifies if it there is any possibility of the two bsplines share a section.
- Parameters:
other_bspline2 – other bspline.
tol – tolerance used.
- Returns:
True or False.
- linesegment_intersections(linesegment3d: LineSegment3D, abs_tol: float = 1e-06)[source]¶
Calculates intersections between a BSplineCurve3D and a LineSegment3D.
- Parameters:
linesegment3d – linesegment to verify intersections.
abs_tol – tolerance.
- Returns:
list with the intersections points.
- look_up_table(resolution: int = 20, start_parameter: float = 0, end_parameter: float = 1)[source]¶
Creates a table of equivalence between parameter t (evaluation of BSplineCurve) and the cumulative distance.
- Parameters:
resolution (int, optional) – The precision of the table. Auto-adjusted by the algorithm. Default value set to 20
start_parameter (float, optional) – First parameter evaluated in the table. Default value set to 0
end_parameter – Last parameter evaluated in the table. Default value set to 1
- Returns:
Yields a list of tuples containing the parameter and the cumulated distance along the BSplineCruve3D from the evaluation of start_parameter
- Return type:
Tuple[float, float]
- maximum_curvature(point_in_curve: bool = False)[source]¶
Returns the maximum curvature of a curve and the point where it is located.
- minimum_radius(point_in_curve=False)[source]¶
Returns the minimum curvature radius of a curve and the point where it is located.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Matplotlib plot method for a BSpline Curve 3D.
- revolution(axis_point, axis, angle)[source]¶
Returns the face generated by the revolution of the BSpline Curve 3D.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
BSplineCurve3D rotation.
- Parameters:
center – rotation center
axis – rotation axis
angle – angle rotation
- Returns:
a new rotated BSplineCurve3D
- sweep(*args, **kwargs)[source]¶
Bspline 3D is used as path for sweeping given section through it.
- Returns:
- to_2d(plane_origin, x, y)[source]¶
Transforms a BSplineCurve3D into an BSplineCurve2D, given a plane origin and an u and v plane vector.
- Parameters:
plane_origin – plane origin.
x – plane u vector.
y – plane v vector.
- Returns:
BSplineCurve2D.
- trim_between_evaluations(parameter1: float, parameter2: float)[source]¶
Trims the Bspline between two abscissa evaluation parameters.
- Parameters:
parameter1 – evaluation parameter 1, bigger than 0 and smaller than its length.
parameter2 – evaluation parameter 2, bigger than 0 and smaller than its length.
- class design3d.edges.BezierCurve2D(degree: int, control_points: List[Point2D], name: str = '')[source]¶
Bases:
BSplineCurve2D
A class for 2-dimensional Bézier curves.
- Parameters:
degree (int) – The degree of the Bézier curve.
control_points (List[
design3d.Point2D
]) – A list of 2-dimensional pointsname (str, optional) – The name of the B-spline curve. Default value is ‘’
- class design3d.edges.BezierCurve3D(degree: int, control_points: List[Point3D], name: str = '')[source]¶
Bases:
BSplineCurve3D
A class for 3-dimensional Bézier curves.
- Parameters:
degree (int) – The degree of the Bézier curve
control_points (List[
design3d.Point3D
]) – A list of 3-dimensional pointsname (str, optional) – The name of the B-spline curve. Default value is ‘’
- class design3d.edges.Edge(start, end, reference_path: str = '#', name='')[source]¶
Bases:
DataEqualityObject
Defines a simple edge Object.
- abscissa(point, tol: float = 1e-06)[source]¶
Computes the abscissa of an Edge.
- Parameters:
point (Union[
design3d.Point2D
,design3d.Point3D
].) – The point located on the edge.tol (float, optional.) – The precision in terms of distance. Default value is 1e-4.
- Returns:
The abscissa of the point.
- Return type:
float
- abscissa_discretization(abscissa1, abscissa2, max_number_points: int = 10, return_abscissas: bool = True)[source]¶
Gets n discretization points between two given points of the edge.
- Parameters:
abscissa1 – Initial abscissa.
abscissa2 – Final abscissa.
max_number_points – Expected number of points to discretize locally.
return_abscissas – By default, returns also a list of abscissas corresponding to the discretization points
- Returns:
list of locally discretized point and a list containing the abscissas’ values.
Deletes from self, the section shared with the other arc.
- Parameters:
other_arc2
abs_tol – tolerance.
- Returns:
- direction_independent_is_close(other_edge, tol: float = 1e-06)[source]¶
Verifies if two line segments are the same, not considering its direction.
- direction_vector(abscissa)[source]¶
Calculates the direction vector the edge at given abscissa.
- Parameters:
abscissa – edge abscissa
- Returns:
direction vector
- discretization_points(*, number_points: int = None, angle_resolution: int = None)[source]¶
Discretize an Edge to have “n” points.
- Parameters:
number_points – the number of points (including start and end points) if unset, only start and end will be returned
angle_resolution – if set, the sampling will be adapted to have a controlled angular distance. Useful to mesh an arc
- Returns:
a list of sampled points
- classmethod from_step(arguments, object_dict, **kwargs)[source]¶
Converts a step primitive to an Edge type object.
- Parameters:
arguments (list) – The arguments of the step primitive.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated
- Returns:
The corresponding Edge object
- Return type:
Generic method to Get the shared section between two arcs of ellipse.
- Parameters:
other_edge – other edge to verify for shared section.
abs_tol – tolerance.
- Returns:
shared arc section.
- generic_minimum_distance(element, return_points=False)[source]¶
Gets the minimum distance between two elements.
This is a generalized method in a case an analytical method has not yet been defined.
- Parameters:
element – other element.
return_points – Weather to return the corresponding points or not.
- Returns:
distance to edge.
Gets the shared section between two arcs of ellipse.
- intersections(edge2: Edge, abs_tol: float = 1e-06, force_sort: bool = False)[source]¶
Gets the intersections between two edges.
- Parameters:
edge2 – other edge.
abs_tol – tolerance.
- Returns:
list of intersection points.
- is_close(other_edge, tol: float = 1e-06)[source]¶
Verify if two edges are equal, considering a certain tolerance.
- is_point_edge_extremity(other_point, abs_tol: float = 1e-06)[source]¶
Verifies if a point is the start or the end of the edge.
- Parameters:
other_point – other point to verify if it is any end of the edge.
abs_tol – tolerance.
- Returns:
True of False.
- local_discretization(point1, point2, number_points: int = 10)[source]¶
Gets n discretization points between two given points of the edge.
- Parameters:
point1 – point 1 on edge.
point2 – point 2 on edge.
number_points – number of points to discretize locally.
- Returns:
list of locally discretized points.
- minimum_distance(element, return_points=False)[source]¶
Evaluates the minimal distance between the edge and another specified primitive.
- Parameters:
element – Another primitive object to compute the distance to.
return_points (bool) – (optional) If True, return the closest points on both primitives.
- Returns:
The minimum distance between the edge and the specified primitive. tuple, optional: A tuple containing the closest points if return_points is True.
- normal_vector(abscissa)[source]¶
Calculates the normal vector the edge at given abscissa.
- Returns:
the normal vector
- property periodic¶
Returns True if edge is periodic.
- point_belongs(point, abs_tol: float = 1e-06)[source]¶
Checks if a point belongs to the edge.
- Parameters:
point (Union[
design3d.Point2D
,design3d.Point3D
]) – The point to be checkedabs_tol (float, optional) – The precision in terms of distance. Default value is 1e-6
- Returns:
True if the point belongs to the edge, False otherwise
- Return type:
bool
- point_distance(point: Point2D | Point3D)[source]¶
Calculates the distance from a given point.
- Parameters:
point (Union[
design3d.Point2D
,design3d.Point3D
]) – The point to be checked.- Returns:
distance.
- property simplify¶
Search another simplified edge that can represent the edge.
- sort_points_along_curve(points: List[Point2D | Point3D])[source]¶
Sort point along a curve.
- Parameters:
points – list of points to be sorted.
- Returns:
sorted points.
- straight_line_point_belongs(point)[source]¶
Verifies if a point belongs to the surface created by closing the edge.
- Parameters:
point – Point to be verified
- Returns:
Return True if the point belongs to this surface, or False otherwise
- to_step(current_id: int, *args, **kwargs)[source]¶
Converts the object to a STEP representation.
- Parameters:
current_id (int) – The ID of the last written primitive.
- Returns:
The STEP representation of the object and the last ID.
- Return type:
tuple[str, list[int]]
- touching_points(edge2)[source]¶
Verifies if two edges are touching each other.
In case these two edges are touching each other, return these touching points.
- Parameters:
edge2 – edge2 to verify touching points.
- Returns:
list of touching points.
- trim(point1, point2, *args, **kwargs)[source]¶
Trims edge between two points.
- Parameters:
point1 – point 1.
point2 – point 2.
- Returns:
edge trimmed.
- unit_direction_vector(abscissa: float = 0.0)[source]¶
Calculates the unit direction vector the edge at given abscissa.
- Parameters:
abscissa – edge abscissa
- Returns:
unit direction vector
- class design3d.edges.FullArc2D(circle: Circle2D, start_end: Point2D, reference_path: str = '#', name: str = '')[source]¶
Bases:
FullArcMixin
,Arc2D
An edge that starts at start_end, ends at the same point after having described a circle.
- property bounding_rectangle¶
Gets the bounding rectangle for a full arc 2d.
- classmethod dict_to_object(dict_, *args, **kwargs)[source]¶
Create a FullArc2D object from a dictionary representation.
This class method takes a dictionary containing the necessary data for creating a FullArc2D object and returns an instance of the FullArc2D class. It expects the dictionary to have the following keys:
- Parameters:
cls – The FullArc2D class itself (automatically passed).
dict – A dictionary containing the required data for object creation.
args – Additional positional arguments (if any).
kwargs – Additional keyword arguments (if any).
- Returns:
FullArc2D: An instance of the FullArc2D class created from the provided dictionary.
- frame_mapping(frame: Frame2D, side: str)[source]¶
Map the 2D full arc to a new frame or its original frame.
- Parameters:
frame (
design3d.Frame2D
) – The target frame for the mapping.side (str) – Specify whether to map the arc to the new frame (‘new’) or its original frame (‘old’).
- Returns:
The full arc in the specified frame.
- Return type:
- classmethod from_3_points(point1, point2, point3, reference_path: str = '#', name: str = '')[source]¶
Creates a circle 2d from 3 points.
- Returns:
circle 2d.
- linesegment_intersections(linesegment2d: LineSegment2D, abs_tol=1e-09)[source]¶
Full arc 2D intersections with a line segment.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Plots a fullarc using Matplotlib.
- point_belongs(point: Point2D, abs_tol: float = 1e-06)[source]¶
Returns if given point belongs to the FullArc2D.
- straight_line_area()[source]¶
Calculates the area of the full arc, with line drawn from start to end.
- Returns:
straight_line_area.
- straight_line_point_belongs(point)[source]¶
Verifies if a point belongs to the surface created by closing the edge.
- Parameters:
point – Point to be verified.
- Returns:
Return True if the point belongs to this surface, or False otherwise.
- to_3d(plane_origin, x, y)[source]¶
Transforms the full arc 2D into a 3D full arc.
- Parameters:
plane_origin (design3d.Point3D) – The origin of plane to draw the full arc 3D.
x (design3d.Vector3D) – First direction of the plane
y (design3d.Vector3D) – Second direction of the plane.
- Returns:
A 3D full arc.
- Type:
Full Arc 3D.
- class design3d.edges.FullArc3D(circle: Circle3D, start_end: Point3D, name: str = '')[source]¶
Bases:
FullArcMixin
,Arc3D
An edge that starts at start_end, ends at the same point after having described a circle.
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes vector frame_mapping and return a new FullArc3D.
side = ‘old’ or ‘new’
- classmethod from_3_points(point1, point2, point3, name: str = '')[source]¶
Creates a full arc 3D from 3 given points.
- classmethod from_center_normal(center: Point3D, normal: Vector3D, start_end: Point3D, name: str = '')[source]¶
Creates a Full Arc 3D using a center, and a normal vector and a start point.
- Parameters:
center – full arc center.
normal – circle normal
start_end – full arc starting point.
name – full arc’s name.
- Returns:
FullArc3D.
- classmethod from_curve(circle, start_end=None, name: str = '')[source]¶
Initialize a full arc from a circle.
- fullarc_intersections(fullarc3d, abs_tol: float = 1e-06)[source]¶
Calculates the intersections between two full arc 3d.
- Parameters:
fullarc3d – linesegment 3d to verify intersections.
abs_tol – tolerance.
- Returns:
list of points 3d, if there are any intersections, an empty list if otherwise.
- linesegment_intersections(linesegment3d: LineSegment3D, abs_tol=1e-06)[source]¶
Calculates the intersections between a full arc 3d and a line segment 3d.
- Parameters:
linesegment3d – linesegment 3d to verify intersections.
abs_tol – tolerance.
- Returns:
list of points 3d, if there are any intersections, an empty list if otherwise.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True), show_frame=False)[source]¶
Plot fullarc3d using matplotlib.
- point_belongs(point: Point3D, abs_tol: float = 1e-06)[source]¶
Returns if given point belongs to the FullArc3D.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
Rotates the FullArc3D object around a specified axis by a given angle.
- Parameters:
center ((design3d.Point3D)) – The center point of rotation.
axis ((design3d.Vector3D)) – The axis of rotation.
angle ((float)) – The angle of rotation in radians.
- Returns:
A new FullArc3D object that is the result of the rotation.
- Return type:
FullArc3D:
- split(split_point, tol: float = 1e-06)[source]¶
Splits the circle into two arcs at a given point.
- Parameters:
split_point – splitting point.
tol – tolerance.
- Returns:
list of two arcs.
- class design3d.edges.FullArcEllipse(ellipse: Ellipse2D | Ellipse3D, start_end: Point2D | Point3D, name: str = '')[source]¶
Bases:
Edge
Abstract class to define an ellipse.
- abscissa(point, tol: float = 1e-06)[source]¶
Computes the abscissa of an Edge.
- Parameters:
point (Union[
design3d.Point2D
,design3d.Point3D
].) – The point located on the edge.tol (float, optional.) – The precision in terms of distance. Default value is 1e-4.
- Returns:
The abscissa of the point.
- Return type:
float
- property angle_end¶
Get ellipse starting angle.
- property angle_start¶
Get ellipse starting angle.
- property center¶
Gets ellipse’s center point.
- classmethod from_curve(ellipse, name: str = '')[source]¶
Creates a fullarc ellipse from a ellipse curve.
- get_reverse()[source]¶
Defines a new FullArcEllipse, identical to self, but in the opposite direction.
- length()[source]¶
Calculates the length of the ellipse.
Ramanujan’s approximation for the perimeter of the ellipse. P = math.pi * (a + b) [ 1 + (3h) / (10 + √(4 - 3h) ) ], where h = (a - b)**2/(a + b)**2.
- Returns:
Perimeter of the ellipse
- Return type:
float
- property periodic¶
Returns True if edge is periodic.
- point_belongs(point: Point2D | Point3D, abs_tol: float = 0.01)[source]¶
Verifies if a given point lies on the ellipse.
- Parameters:
point – point to be verified.
abs_tol – Absolute tolerance to consider the point on the ellipse (0.99 should be considered True).
- Returns:
True is point lies on the ellipse, False otherwise
- class design3d.edges.FullArcEllipse2D(ellipse: Ellipse2D, start_end: Point2D, name: str = '')[source]¶
Bases:
FullArcEllipse
,ArcEllipse2D
Defines a FullArcEllipse2D.
- abscissa(point: Point2D | Point3D, tol: float = 1e-06)[source]¶
Calculates the abscissa of a given point.
- Parameters:
point – point for calculating abscissa.
tol – tolerance.
- Returns:
a float, between 0 and the ellipse’s length.
- frame_mapping(frame: Frame2D, side: str)[source]¶
Changes frame_mapping and return a new FullArcEllipse2D.
- Parameters:
frame (design3d.Frame2D) – Local coordinate system.
side (str) – ‘old’ will perform a transformation from local to global coordinates. ‘new’ will perform a transformation from global to local coordinates.
- Returns:
A new transformed FulLArcEllipse2D.
- Return type:
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Matplotlib plot for an ellipse.
- to_3d(plane_origin, x, y)[source]¶
Transforms the full arc of ellipse 2D into a 3D full arc of ellipse.
- Parameters:
plane_origin (design3d.Point3D) – The origin of plane to draw the full arc of ellipse 3D.
x (design3d.Vector3D) – First direction of the plane
y (design3d.Vector3D) – Second direction of the plane.
- Returns:
A 3D full arc of ellipse.
- Return type:
- class design3d.edges.FullArcEllipse3D(ellipse: Ellipse3D, start_end: Point3D, name: str = '')[source]¶
Bases:
FullArcEllipse
,ArcEllipse3D
Defines a FullArcEllipse3D.
- abscissa(point: Point3D, tol: float = 1e-06)[source]¶
Calculates the abscissa a given point.
- Parameters:
point – point to calculate abscissa.
tol – tolerance allowed.
- Returns:
abscissa
- classmethod dict_to_object(dict_, *args, **kwargs)[source]¶
Create a FullArcEllipse3D object from a dictionary representation.
This class method takes a dictionary containing the necessary data for creating a FullArcEllipse3D object and returns an instance of the FullArcEllipse3D class. It expects the dictionary to have the following keys:
- Parameters:
cls – The FullArcEllipse3D class itself (automatically passed).
dict – A dictionary containing the required data for object creation.
args – Additional positional arguments (if any).
kwargs – Additional keyword arguments (if any).
- Returns:
FullArcEllipse3D: An instance of the FullArcEllipse3D class created from the provided dictionary.
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes frame_mapping and return a new FullArcEllipse3D.
- Parameters:
frame (design3d.Frame3D) – Local coordinate system.
side (str) – ‘old’ will perform a transformation from local to global coordinates. ‘new’ will perform a transformation from global to local coordinates.
- Returns:
A new transformed FulLArcEllipse3D.
- Return type:
- line_intersections(line, abs_tol: float = 1e-06)[source]¶
Gets intersections between an Ellipse 3D and a Line3D.
- Parameters:
line – Other Line 3D.
abs_tol – tolerance.
- Returns:
A list of points, containing all intersections between the Line 3D and the Ellipse3D.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Ellipse plot.
- split(split_point, tol: float = 1e-06)[source]¶
Splits the ellipse into two arc of ellipse at a given point.
- Parameters:
split_point – splitting point.
tol – tolerance.
- Returns:
list of two Arc of ellipse.
- to_2d(plane_origin, x, y)[source]¶
Transforms a FullArcEllipse3D into an FullArcEllipse2D, given an plane origin and a u and v plane vector.
- Parameters:
plane_origin – plane origin.
x – plane u vector.
y – plane v vector.
- Returns:
FullArcEllipse2D.
- to_dict(use_pointers: bool = False, memo=None, path: str = '#')[source]¶
Transforms an instance of a Full arc ellipse into a dictionary.
- class design3d.edges.FullArcMixin(circle: Circle2D | Circle3D, start_end: Point2D | Point3D, name: str = '')[source]¶
Bases:
ArcMixin
Abstract class for representing a circle with a start and end points that are the same.
- property angle¶
Angle of Full Arc.
- property periodic¶
Return True if an edge is periodic.
- class design3d.edges.LineSegment(start: Point2D | Point3D, end: Point2D | Point3D, reference_path: str = '#', name: str = '')[source]¶
Bases:
Edge
Abstract class.
- abscissa(point, tol=1e-06)[source]¶
Calculates the abscissa parameter of a Line Segment, at a point.
- Parameters:
point – point to verify abscissa.
tol – tolerance.
- Returns:
abscissa parameter.
- direction_vector(abscissa=0.0)[source]¶
Returns a direction vector at a given abscissa, it is not normalized.
- Parameters:
abscissa – defines where in the line segment direction vector is to be calculated.
- Returns:
The direction vector of the LineSegment.
- get_geo_lines(tag: int, start_point_tag: int, end_point_tag: int)[source]¶
Gets the lines that define a LineSegment in a .geo file.
- Parameters:
tag (int) – The linesegment index
start_point_tag (int) – The linesegment’ start point index
end_point_tag (int) – The linesegment’ end point index
- Returns:
A line
- Return type:
str
Gets the shared section between two line segments.
- Parameters:
other_linesegment – other line segment to verify for shared section.
abs_tol – tolerance.
- Returns:
shared line segment section.
- is_close(other_edge, tol: float = 1e-06)[source]¶
Checks if two line segments are the same considering the Euclidean distance.
- Parameters:
other_edge – other line segment.
tol (float, optional.) – The tolerance under which the Euclidean distance is considered equal to 0, defaults to 1e-6.
- property line¶
Returns the line from which the line segment was extracted.
- normal_vector(abscissa=0.0)[source]¶
Returns a normal vector at a given abscissa, it is not normalized.
- Parameters:
abscissa – defines where in the line_segment
normal vector is to be calculated. :return: The normal vector of the LineSegment.
- point_at_abscissa(abscissa)[source]¶
Calculates a point in the LineSegment at a given abscissa.
- Parameters:
abscissa – abscissa where in the curve the point should be calculated.
- Returns:
Corresponding point.
- point_belongs(point: Point2D | Point3D, abs_tol: float = 1e-06)[source]¶
Checks if a point belongs to the line segment. It uses the point_distance.
- Parameters:
point (Union[
design3d.Point2D
,design3d.Point3D
]) – The point to be checkedabs_tol (float, optional) – The precision in terms of distance. Default value is 1e-6
- Returns:
True if the point belongs to the B-spline curve, False otherwise
- Return type:
bool
- point_projection(point)[source]¶
Calculates the projection of a point on a Line Segment.
- Parameters:
point – point to be verified.
- Returns:
point projection.
- split(split_point, tol: float = 1e-06)[source]¶
Split a Line Segment at a given point into two Line Segments.
- Parameters:
split_point – splitting point.
tol – tolerance.
- Returns:
list with the two split line segments.
- straight_line_point_belongs(point)[source]¶
Closing straight line point belongs verification.
Verifies if a point belongs to the surface created by closing the edge with a line between its start and end points.
- Parameters:
point – Point to be verified.
- Returns:
Return True if the point belongs to this surface, or False otherwise.
- class design3d.edges.LineSegment2D(start: Point2D, end: Point2D, reference_path: str = '#', name: str = '')[source]¶
Bases:
LineSegment
Define a line segment limited by two points.
- property bounding_rectangle¶
Evaluates the bounding rectangle of the Line segment.
- closest_point_on_segment(point)[source]¶
Gets the closest point on the line segment and another given point.
- distance_linesegment(linesegment, return_points=False)[source]¶
Calculates the minimum distance between two line segments.
- Parameters:
linesegment – other line segment.
return_points – boolean weather to return the minimum distance corresponding points or not.
- Returns:
minimum distance / minimal distance with corresponding points.
- frame_mapping(frame: Frame2D, side: str)[source]¶
Changes vector frame_mapping and return a new LineSegment2D.
side = ‘old’ or ‘new’.
- line_distance(line, return_points: bool = False)[source]¶
Calculates the distance between a Line Segment and an infinite Line.
- Parameters:
line – other line.
return_points – weather to return corresponding points or not.
- Returns:
distance between line and line segment.
- linesegment_intersections(linesegment2d: LineSegment2D, abs_tol=1e-06)[source]¶
Touching line segments does not intersect.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Plots the Linesegment2D.
- point_distance(point, return_other_point=False)[source]¶
Computes the distance of a point to segment of line.
- Parameters:
point – point to calculate distance.
return_other_point – Boolean variable to return line segment’s corresponding point or not.
- rotation(center: Point2D, angle: float)[source]¶
LineSegment2D rotation.
- Parameters:
center – rotation center
angle – angle rotation
- Returns:
a new rotated LineSegment2D
- straight_line_area()[source]¶
Calculates the area of the LineSegment2D, with line drawn from start to end.
- Returns:
straight_line_area.
- straight_line_second_moment_area(*args, **kwargs)[source]¶
Straight line second moment area for a line segment.
- to_3d(plane_origin, x1, x2)[source]¶
Transforms the Line segment 2D into a 3D line segment.
- Parameters:
plane_origin (design3d.Point3D) – The origin of plane to draw the Line segment 3D.
x1 (design3d.Vector3D) – First direction of the plane
x2 (design3d.Vector3D) – Second direction of the plane.
- Returns:
A 3D line segment.
- Return type:
- class design3d.edges.LineSegment3D(start: Point3D, end: Point3D, reference_path: str = '#', name: str = '')[source]¶
Bases:
LineSegment
Define a line segment limited by two points.
- property bounding_box¶
Gets bounding box for Line Segment 3D.
- distance_arc(arc3d, return_points=False)[source]¶
Calculates the minimum distance between a line segment and an arc in 3d.
- Parameters:
arc3d – other line segment.
return_points – boolean weather to return the minimum distance corresponding points or not.
- Returns:
minimum distance / minimal distance with corresponding points.
- distance_linesegment(linesegment, return_points=False)[source]¶
Calculates the minimum distance between two line segments in 3d.
- Parameters:
linesegment – other line segment.
return_points – boolean weather to return the minimum distance corresponding points or not.
- Returns:
minimum distance / minimal distance with corresponding points.
- extrusion(extrusion_vector)[source]¶
Extrusion of a Line Segment 3D, in a specific extrusion direction.
- Parameters:
extrusion_vector – the extrusion vector used.
- Returns:
An extruded Plane Face 3D.
- frame_mapping(frame: Frame3D, side: str)[source]¶
Changes LineSegment3D frame_mapping and return a new LineSegment3D.
side = ‘old’ or ‘new’
- line_distance(line, return_points: bool = False)[source]¶
Calculates the distance between a Line Segment and an infinite Line.
- Parameters:
line – other line.
return_points – weather to return corresponding points or not.
- Returns:
distance between line and line segment.
- line_intersections(line, tol: float = 1e-06)[source]¶
Gets the intersection between a line segment 3d and line3D.
- Parameters:
line – other line.
tol – maximum tolerance.
- Returns:
a list with the intersection points.
- linesegment_intersections(linesegment, abs_tol: float = 1e-06)[source]¶
Gets the intersection between a line segment 3d and another line segment 3D.
- Parameters:
linesegment – other line segment.
abs_tol – tolerance.
- Returns:
a list with the intersection points.
- matrix_distance(other_line)[source]¶
Gets the points corresponding to the distance between to lines using matrix distance.
- Parameters:
other_line – Other line.
- Returns:
Two points corresponding to the distance between to lines.
- minimum_distance_points(other_line)[source]¶
Returns the points on this line and on the other line that are the closest of lines.
- normal_vector(abscissa=0.0)[source]¶
Returns the normal vector to the curve at the specified abscissa.
- parallel_distance(other_linesegment)[source]¶
Calculates the parallel distance between two Line Segments 3D.
- plane_projection2d(center, x, y)[source]¶
Calculates the projection of a line segment 3d on to a plane.
- Parameters:
center – plane center.
x – plane u direction.
y – plane v direction.
- Returns:
line segment 3d.
- plot(ax=None, edge_style: EdgeStyle = EdgeStyle(color='k', alpha=1, edge_ends=False, edge_direction=False, width=None, arrow=False, plot_points=False, dashed=True, linestyle='-', linewidth=1, equal_aspect=True))[source]¶
Plots the Line segment 3d using matplotlib.
- plot2d(x_3d, y_3d, ax=None, color='k', width=None)[source]¶
Creates a 2d plot of the Line segment 3d using matplotlib.
- revolution(axis_point, axis, angle)[source]¶
Returns the face generated by the revolution of the line segments.
- rotation(center: Point3D, axis: Vector3D, angle: float)[source]¶
LineSegment3D rotation.
- Parameters:
center – rotation center
axis – rotation axis
angle – angle rotation
- Returns:
a new rotated LineSegment3D
- sweep(*args)[source]¶
Line Segment 3D is used as path for sweeping given section through it.
- Returns:
- to_2d(plane_origin, x, y)[source]¶
Transforms a LineSegment3D into an LineSegment2D, given a plane origin and an u and v plane vector.
- Parameters:
plane_origin – plane origin.
x – plane u vector.
y – plane v vector.
- Returns:
LineSegment2D.