Edges#

Edges related classes.

class volmdlr.edges.Arc2D(circle: Circle2D, start: Point2D, end: Point2D, reference_path: str = '#', name: str = '')#

Bases: ArcMixin, Edge

Class to draw Arc2D.

angle: the angle measure always >= 0

abscissa(point: Point2D, tol=1e-06)#

Return the abscissa of a given point 2d.

property angle#

Arc angle property.

Returns:

arc angle.

arc_intersections(arc, abs_tol: float = 1e-06)#

Intersections between two arc 2d.

arcellipse_intersections(arcellipse, abs_tol: float = 1e-06)#

Intersections between an arc 2d and arc-ellipse 2d.

Parameters:
  • arcellipse – arc-ellipse 2d.

  • abs_tol – tolerance

Returns:

list of intersection points.

area()#

Calculate the area of the Arc2D.

Returns:

the area of the Arc2D.

axial_symmetry(line)#

Find out the symmetric arc 2D according to a line.

property bounding_rectangle#

Get the bounding rectangle for an Arc 2D.

bsplinecurve_intersections(bspline, abs_tol: float = 1e-06)#

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()#

Calculate the center of mass of the Arc2D.

Returns:

center of mass point.

complementary()#

Get the complementary Arc 2D.

frame_mapping(frame: Frame2D, side: str)#

Change vector frame_mapping and return a new Arc2D.

side = ‘old’ or ‘new’

classmethod from_3_points(point1, point2, point3, reference_path: str = '#', name: str = '')#

Create a circle 2d from 3 points.

Returns:

circle 2d.

get_start_end_angles()#

Return the start and end angle of the arc.

infinite_primitive(offset)#

Create an offset curve from a distance of the original curve.

property is_trigo#

Return True if circle is counterclockwise.

line_intersections(line: Line2D)#

Calculate the intersection between a line and an Arc2D.

Parameters:

line – Line2D to verify intersections.

Returns:

a list with intersections points.

linesegment_intersections(linesegment: LineSegment2D, abs_tol=1e-06)#

Calculate the intersection between a LineSegment2D and an Arc2D.

Parameters:
  • linesegment – LineSegment2D to verify intersections.

  • abs_tol – tolerance.

Returns:

a list with intersections points.

mirror(center: Point2D, axis_direction: Vector2D)#

Mirror an Arc2D relative to the axis direction given.

plot(ax=None, edge_style: EdgeStyle | None = None)#

Plot arc 2d with Matplotlib.

plot_data(edge_style: EdgeStyle | None = None)#

Plot data method for a Arc2D.

Parameters:

edge_style (plot_data.EdgeStyle) – edge style.

Returns:

plot_data.Arc2D object.

point_belongs(point, abs_tol=1e-06)#

Check if a Point2D belongs to the Arc2D.

property points#
rotation(center: Point2D, angle: float)#

Arc2D rotation.

Parameters:
  • center – rotation center

  • angle – angle rotation.

Returns:

a new rotated Arc2D.

second_moment_area(point)#

Second moment area of part of disk.

straight_line_area()#

Calculate the area of the arc 2D, with line drawn from start to end.

Returns:

straight_line_area.

straight_line_center_of_mass()#

Straight line center of mass.

straight_line_point_belongs(point)#

Verify 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)#

Straight line second moment area for an Arc 2D.

to_3d(plane_origin, x, y)#

Transform the arc 2D into a 3D arc.

Parameters:
  • plane_origin (volmdlr.Point3D) – The origin of plane to draw the arc 3D.

  • x (volmdlr.Vector3D) – First direction of the plane

  • y (volmdlr.Vector3D) – Second direction of the plane.

Returns:

A 3D arc.

Type:

Arc3D.

to_dict(use_pointers: bool = False, memo=None, path: str = '#', id_method=True, id_memo=None, **kwargs)#

Store all Arc 2D attributes in a dict object.

to_full_arc_2d()#

Convert to a full arc2d.

translation(offset: Vector2D, memo=None)#

Arc2D translation.

Parameters:
  • offset – translation vector.

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

A new translated Arc2D.

class volmdlr.edges.Arc3D(circle, start, end, name='')#

Bases: ArcMixin, Edge

An arc is defined by a starting point, an end point and an interior point.

abscissa(point: Point3D, tol: float = 1e-06)#

Calculate 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)#

Calculate 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)#

Calculate 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.

complementary()#

Create the corresponding complementary arc.

direction_vector(abscissa)#

Calculate 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)#

Get 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)#

Get 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.

extrusion(extrusion_vector)#

Extrudes an arc 3d in the given extrusion vector direction.

frame_mapping(frame: Frame3D, side: str)#

Change vector frame_mapping and return a new Arc3D.

side = ‘old’ or ‘new’

classmethod from_3_points(point1, point2, point3, name: str = '')#

Create 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 = '')#

Give the arc3D from a start, an angle and an axis.

get_bounding_box()#

Calculate the bounding box of the Arc3D.

Returns:

Bounding Box object.

get_reverse()#

Define a new Arc3D, identical to self, but in the opposite direction.

property is_trigo#

Return True if circle is counterclockwise.

line_intersections(line: Line3D, tol: float = 1e-06)#

Calculate intersections between an Arc3D and a Line3D.

Parameters:
  • line – line to verify intersections.

  • tol – maximum tolerance.

Returns:

list with intersections points between line and Arc3D.

linesegment_intersections(linesegment: LineSegment3D, abs_tol: float = 1e-06)#

Calculate intersections between an Arc3D and a LineSegment3D.

Parameters:
  • linesegment – 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)#

Calculate the minimum distance points between two arcs.

move_frame_along(frame)#

Move frame along edge.

plot(ax=None, edge_style: EdgeStyle | None = None)#

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')#

Plot data.

point_at_abscissa(abscissa)#

Calculate 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)#

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#

Get arc points.

Returns:

list with arc points.

revolution(axis_point: Point3D, axis: Vector3D, angle: float)#

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)#

Arc3D rotation.

Parameters:
  • center – rotation center

  • axis – rotation axis

  • angle – angle rotation

Returns:

a new rotated Arc3D

sweep(*args, **kwargs)#

Arc 3D is used as path for sweeping given section through it.

Returns:

to_2d(plane_origin, x, y)#

Transform 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)#

Save the object parameters into a dictionary.

translation(offset: Vector3D, memo=None)#

Arc3D translation.

Parameters:
  • offset – translation vector.

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

A new translated Arc3D.

triangulation()#

Triangulation for an Arc3D.

class volmdlr.edges.ArcEllipse2D(ellipse: Ellipse2D, start: Point2D, end: Point2D, name: str = '')#

Bases: ArcEllipseMixin, Edge

An 2-dimensional elliptical arc.

Parameters:
  • ellipse (volmdlr.curves.Ellipse2D.) – An ellipse curve, as base for the arc ellipse.

  • start (volmdlr.Point2D) – The starting point of the elliptical arc

  • end (volmdlr.Point2D) – The end point of the elliptical arc

  • name (str, optional) – The name of the elliptical arc. Default value is ‘’

abscissa(point: Point2D, tol: float = 1e-06)#

Calculate 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#

Get arc of ellipse angle.

property angle_end#

Get arc of ellipse ending angle.

property angle_start#

Get arc of ellipse starting angle.

property bounding_rectangle#

Calculate the bounding rectangle for the arc ellipse 2d.

Returns:

Bounding Rectangle object.

bsplinecurve_intersections(bspline, abs_tol: float = 1e-06)#

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#

Get ellipse’s center point.

complementary()#

Get the complementary arc of ellipse.

direction_vector(abscissa)#

Calculate 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:

volmdlr.Vector2D.

Raises:

ValueError If the abscissa is out of range.

discretization_points(*, number_points: int | None = None, angle_resolution: int | None = None)#

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)#

Change 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 = '')#

Create 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.

get_end_angle()#

Get angle for the end point.

get_reverse()#

Get the arc ellipse in the reverse direction.

get_start_angle()#

Get angle for the start point.

is_close(other_edge, tol: float = 1e-06)#

Check 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.

length()#

Calculate the length of the arc-ellipse 2d.

Returns:

arc ellipse 2d’s length

line_intersections(line: Line2D, tol: float = 1e-06)#

Intersections between an Arc Ellipse 2D and a Line 2D.

Parameters:
  • line – Line 2D to verify intersections

  • tol – maximum tolerance.

Returns:

List with all intersections

linesegment_intersections(linesegment: LineSegment2D, abs_tol=1e-06)#

Intersections between an Arc Ellipse 2D and a Line Segment 2D.

Parameters:
  • linesegment – LineSegment 2D to verify intersections.

  • abs_tol – tolerance.

Returns:

List with all intersections.

normal_vector(abscissa)#

Calculate 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:

volmdlr.Vector2D.

Raises:

ValueError If the abscissa is out of range.

plot(ax=None, edge_style: EdgeStyle | None = None)#

Plot arc-ellipse 2d using Matplotlib.

Parameters:
  • ax – Matplotlib plot if there exists any.

  • edge_style – edge styles.

Returns:

Matplotlib plot

point_at_abscissa(abscissa)#

Get a point at given abscissa.

point_belongs(point, abs_tol: float = 1e-06)#

Verify 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)#

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)#

Split arc-ellipse at a given point.

Parameters:
  • split_point – splitting point.

  • tol – tolerance.

Returns:

list of two Arc-Ellipse.

straight_line_area()#

Calculate the area of the elliptic arc, with line drawn from start to end.

Returns:

straight_line_area.

straight_line_center_of_mass()#

Straight line center of mass.

PS.: This is an approximation.

straight_line_point_belongs(point)#

Verify 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)#

Transform the arc of ellipse 2D into a 3D arc of ellipse.

Parameters:
  • plane_origin (volmdlr.Point3D) – The origin of plane to draw the arc of ellipse 3D.

  • x (volmdlr.Vector3D) – First direction of the plane

  • y (volmdlr.Vector3D) – Second direction of the plane.

Returns:

A 3D arc of ellipse.

Type:

ArcEllipse3D.

translation(offset: Vector2D, memo=None)#

Translate the Arc ellipse given an offset vector.

Parameters:
  • offset – offset vector

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

new translated arc ellipse 2d.

valid_abscissa_start_end_angle(angle_abscissa)#

Get valid abscissa angle for start and end.

class volmdlr.edges.ArcEllipse3D(ellipse: Ellipse3D, start: Point3D, end: Point3D, name='')#

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)#

Calculate the abscissa a given point.

Parameters:
  • point – point to calculate abscissa.

  • tol – tolerance allowed.

Returns:

abscissa

arcellipse_intersections(arcellipse3d, abs_tol: float = 1e-06)#

Get 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#

Get ellipse’s center point.

complementary()#

Get the complementary arc of ellipse.

direction_vector(abscissa)#

Return the tangent vector at a given abscissa along the ArcEllipse3D.

This method Calculate 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 = None, angle_resolution: int = 20)#

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)#

Change frame_mapping and return a new ArcEllipse3D.

Parameters:
  • frame (volmdlr.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:

ArcEllipse3D

get_bounding_box()#

Calculate the bounding box of the Arc3D.

Returns:

Bounding Box object.

get_reverse()#

Get the same ellipse but in the reverse direction.

get_start_end_angles()#

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, tol: float = 1e-06)#

Verify if two arc ellipses are the same, considereing given tolerance.

Parameters:
  • other_arcellipse – other arc ellipse.

  • tol – tolerance.

Returns:

True or False.

length()#

Compute the length.

line_intersections(line, abs_tol: float = 1e-06)#

Get 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)#

Get 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#

Get ellipse’s normal direction.

normal_vector(abscissa)#

Return the normal vector at a given abscissa.

plot(ax=None, edge_style: EdgeStyle | None = None)#

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')#

Plot 2d for an arc ellipse 3d.

point_at_abscissa(abscissa)#

Calculate the point at a given abscissa.

Parameters:

abscissa – abscissa to calculate point.

Returns:

volmdlr.Point3D

point_belongs(point, abs_tol: float = 1e-06)#

Verify 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)#

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)#

Split 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)#

Transform 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.

translation(offset: Vector3D, memo=None)#

ArcEllipse3D translation.

Parameters:
  • offset – translation vector.

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

A new translated ArcEllipse3D.

triangulation()#

Triangulation for an Arc Ellipse 3D.

validate_intersections(intersections: list[Point3D], abs_tol: float = 1e-06)#

Helper function to validate edge intersections.

class volmdlr.edges.ArcEllipseMixin#

Bases: object

Abstract class for ArcEllipses.

get_shared_section(other_edge, abs_tol: float = 1e-06)#

Get the shared section between two arcs of ellipse.

Parameters:
  • other_edge – other arc ellipse to verify for shared section.

  • abs_tol – tolerance.

Returns:

shared arc section.

class volmdlr.edges.ArcMixin(circle, start, end, name: str = '')#

Bases: object

Abstract class representing an arc.

Parameters:

circle (Union['volmdlr.curves.Circle2D', 'volmdlr.curves.Circle3D'].) – arc related circle curve.

# :param start: The starting point # :type start: Union[volmdlr.Point2D, volmdlr.Point3D] # :param end: The finish point # :type end: Union[volmdlr.Point2D, volmdlr.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#

Get arc center.

direction_vector(abscissa: float)#

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 = None, angle_resolution: int = 20)#

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#

Get the arc frame.

get_arc_point_angle(point)#

Return the angle of point on a trigonometric arc.

get_geo_lines(tag: int, start_point_tag: int, center_point_tag: int, end_point_tag: int)#

Get 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()#

Get the points that define an Arc to use them in a .geo file.

Returns:

A list of characteristic arc points

Return type:

List

get_reverse()#

Get the reverse version of an arc.

Returns:

An arc

get_shared_section(other_edge, abs_tol: float = 1e-06)#

Get the shared section between two arcs.

Parameters:
  • other_edge – other arc to verify for shared section.

  • abs_tol – tolerance.

Returns:

shared arc section.

get_start_end_angles()#

Return the start and end angle of the arc.

is_close(other_edge, tol: float = 1e-06)#

Check 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()#

Calculate the length of the Arc, with its radius, and its arc angle.

Returns:

the length of the Arc.

normal_vector(abscissa: float)#

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)#

Calculate a point in the Arc at a given abscissa.

Parameters:

abscissa – abscissa where in the curve the point should be calculated.

Returns:

Corresponding point.

point_distance(point)#

Return the minimal distance to a point.

property radius#

Get arc radius.

split(split_point, tol: float = 1e-06)#

Split arc at a given point.

Parameters:
  • split_point – splitting point.

  • tol – tolerance.

Returns:

list of two Arc.

class volmdlr.edges.BSplineCurve(degree: int, control_points: list[Point2D] | list[Point3D], knot_multiplicities: list[int] | ndarray[Any, dtype[_ScalarType_co]], knots: list[float] | ndarray[Any, dtype[_ScalarType_co]], weights: list[float] | ndarray[Any, dtype[_ScalarType_co]] | None = None, name: str = '')#

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[volmdlr.Point2D], list[volmdlr.Point3D]]) – A list of 2 or 3-dimensional points

  • knot_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)#

Compute the abscissa of a 2D or 3D point using the least square method.

Parameters:
  • point (Union[volmdlr.Point2D, volmdlr.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)#

Search for the value of the normalized evaluation parameter u.

Returns:

the given point when the BSplineCurve3D is evaluated at the u value.

static arc_to_nurbs_parameters(arc)#

Given an arc, return the parameters to form an equivalent NURBS line.

Parameters:

arc – 2D or 3D arc

Returns:

control_points list, knots list, knot_multiplicities list, weights list

property control_points: list[Point2D | Point3D]#

Return the control points of the bspline curve updating start and end points.

copy(deep: bool = True, memo=None)#

Return a copy of the instance.

Parameters:
  • deep – If False, perform a shallow copy. If True, perform a deep copy.

  • memo – (Optional) A dictionary to keep track of objects that have been already copied.

property ctrlpts#

Return the control points of the bspline curve as an array.

property ctrlptsw#

Return the control points of the bspline curve as an array.

cut_after(parameter: float)#

Return 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)#

Return 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#

Return a dictionary of the BSpline data.

decompose(return_params: bool = False)#

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:

Get the delta value

Setter:

Sets the delta value

Type:

float

derivatives(u, order)#

Evaluate n-th order curve derivatives at the given parameter value.

The output of this method is list of n-th order derivatives. If order is 0, then it will only output the evaluated point. Similarly, if order is 2, 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[volmdlr.Vector2D], list[volmdlr.Vector3D]]

direction_vector(abscissa)#

Calculate the direction vector on the BSpline curve at given abscissa.

Parameters:

abscissa – edge abscissa

Returns:

direction vector

discretization_points(*, number_points: int | None = None, angle_resolution: int | None = None)#

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:

list[`volmdlr.Point2D] or list[`volmdlr.Point3D]

property domain#

Domain.

Domain is determined using the knot vector(s).

Getter:

Get the domain

evaluate(**kwargs)#

Evaluate the curve.

The evaluated points are stored in evalpts property.

Keyword Arguments:
  • start: start parameter

  • stop: stop parameter

The start and stop parameters allow evaluation of a curve segment in the range [start, stop], i.e. the curve will also be evaluated at the stop parameter value.

The following examples illustrate the usage of the keyword arguments.

evaluate_single(u)#

Calculate 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[volmdlr.Point2D, Union[volmdlr.Point3D]

frame_mapping(frame: Frame3D | Frame2D, side: str)#

Return a new Revolution Surface positioned in the specified frame.

Parameters:
  • frame (volmdlr.Frame3D) – Frame of reference

  • side – ‘old’ or ‘new’

classmethod from_arc(arc)#

Given an arc, return an equivalent NURBS line.

Parameters:

arc – 2D or 3D arc

Returns:

BSplineCurve2D or BSplineCurve3D

classmethod from_bsplines(bsplines: list[BSplineCurve], discretization_points: int = 10, name: str = '')#

Create a B-spline curve from a list of B-spline curves.

Parameters:
  • bsplines (list[volmdlr.edges.BSplineCurve]) – A list of B-spline curve

  • discretization_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:

volmdlr.edges.BSplineCurve

classmethod from_geomdl_curve(curve, name: str = '')#

# TODO: to be completed.

Parameters:
  • curve

  • name – curve name.

Returns:

A reversed B-spline curve

Return type:

volmdlr.edges.BSplineCurve

classmethod from_points_approximation(points: list[Point2D] | list[Point3D], degree: int, name: str = '', **kwargs)#

Create 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[volmdlr.Point2D], list[volmdlr.Point3D]]) – The data points

  • degree (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:

volmdlr.edges.BSplineCurve

classmethod from_points_interpolation(points: list[Point2D] | list[Point3D], degree: int, centripetal: bool = True, name: str = ' ')#

Create 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[volmdlr.Point2D], list[volmdlr.Point3D]]) – The data points

  • degree (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: volmdlr.edges.BSplineCurve

get_abscissa_discretization(abscissa1, abscissa2, number_points: int = 10, return_abscissas: bool = False)#

Get 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_bounding_element()#

Get bounding box if a 3D object, or bounding rectangle if 2D.

get_geo_lines(tag: int, control_points_tags: list[int])#

Get the lines that define a BsplineCurve in a .geo file.

Parameters:

tag (int) – The BsplineCurve index

Returns:

A line

Return type:

str

get_geo_points()#

Get the points that define a BsplineCurve in a .geo file.

get_linesegment_intersections(linesegment)#

Calculate intersections between a BSplineCurve and a LineSegment.

Parameters:

linesegment – linesegment to verify intersections.

Returns:

list with the intersections points.

get_reverse()#

Reverses the BSpline’s direction by reversing its control points.

Returns:

A reversed B-Spline curve.

Return type:

volmdlr.edges.BSplineCurve.

get_shared_section(other_edge, abs_tol: float = 1e-06)#

Get the shared section between two BSpline curves.

Parameters:
  • other_edge – other arc to verify for shared section.

  • abs_tol – tolerance.

Returns:

shared arc section.

is_close(other_edge, tol: float = 1e-06)#

Check 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.

is_shared_section_possible(other_bspline2, tol)#

Verify 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()#

Return 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)#

Calculate 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)#

Get 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.

Get 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)#

Merge consecutive B-spline curves to define a new merged one.

Parameters:

bspline_curve (volmdlr.edges.BSplineCurve) – Another B-spline curve

Returns:

A merged B-spline curve

Return type:

volmdlr.edges.BSplineCurve

merge_with_curves(curves: list[BSplineCurve])#

Merge consecutive B-spline curves to define a new merged one.

Parameters:

curves (list[volmdlr.edges.BSplineCurve]) – A list of B-spline curves

Returns:

A merged B-spline curve

Return type:

volmdlr.edges.BSplineCurve

normal_vector(abscissa)#

Calculate the normal vector to the BSpline curve at given abscissa.

Returns:

the normal vector

parameter(point, tol: float = 1e-06)#

Get curve parametric value for a given point.

property periodic#

Return True if the BSpline is periodic.

point_at_abscissa(abscissa)#

Calculate 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)#

Check if a 2D or 3D point belongs to the B-spline curve or not. It uses the point_distance.

Parameters:
  • point (Union[volmdlr.Point2D, volmdlr.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)#

Find 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[volmdlr.Point2D, volmdlr.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)#

Calculate the projection of a point on the B-Spline.

Parameters:

point – point to be verified.

Returns:

point projection.

point_to_parameter(point: Point2D | Point3D)#

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:

Get 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)#

Split of B-spline curve in two pieces using a 2D or 3D point.

Parameters:
  • split_point (Union[volmdlr.Point2D, volmdlr.Point3D]) – The point where the B-spline curve is split

  • tol (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:

list[volmdlr.edges.BSplineCurve]

straight_line_point_belongs(point)#

Verify 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)#

Evaluate 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[volmdlr.Point2D, volmdlr.Point3D]

to_dict(*args, **kwargs)#

Avoids storing points in memo that makes serialization slow.

to_geomdl()#

Convert the BSpline curve into a geomdl curve.

translation(offset: Vector2D | Vector3D, memo=None)#

Translate the B-spline curve.

Parameters:
  • offset (Union[volmdlr.Vector2D, volmdlr.Vector3D]) – The translation vector

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

A new translated BSplineCurve

Return type:

volmdlr.edges.BSplineCurve

trim(point1: Point3D, point2: Point3D, same_sense: bool = True, abs_tol: float = 1e-06)#

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 volmdlr.edges.BSplineCurve2D(degree: int, control_points: list[Point2D], knot_multiplicities: list[int], knots: list[float], weights: list[float] | None = None, name: str = '')#

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[volmdlr.Point2D]) – A list of 2-dimensional points

  • knot_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)#

Calculate 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.

axial_symmetry(line)#

Find out the symmetric bsplinecurve2d according to a line.

property bounding_rectangle#

Compute the bounding rectangle of the 2-dimensional B-spline curve.

Returns:

The bounding rectangle.

Return type:

volmdlr.core.BoundingRectangle

bsplinecurve_intersections(bspline, abs_tol=1e-06)#

Calculate intersections between two BSpline Curve 2D.

Parameters:
  • bspline – bspline to verify intersections.

  • abs_tol – tolerance.

Returns:

list with the intersections points.

get_bounding_element()#

Get bounding box if a 3D object, or bounding rectangle if 2D.

get_reverse()#

Reverse the BSpline’s direction by reversing its start and end points.

is_shared_section_possible(other_bspline2, tol)#

Verify 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.

line_crossings(line2d: Line2D)#

Bspline Curve crossings with a line 2d.

linesegment_intersections(linesegment, abs_tol: float = 1e-06)#

Calculate intersections between a BSpline Curve 2D and a Line Segment 2D.

Parameters:
  • linesegment – line segment to verify intersections.

  • abs_tol – tolerance.

Returns:

list with the intersections points.

nearest_point_to(point)#

Find out the nearest point on the linesegment to point.

normal(position: float = 0.0)#

Normal vector to BPlineCurve2D.

ocp_curve() Geom2d_BSplineCurve#

Cached OCP curve representation.

Returns the OpenCASCADE curve, creating and caching it on first access.

Returns:

The cached OpenCASCADE curve representation.

offset(offset_length: float)#

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 | None = None)#

Plot a B-Spline curve 2D.

plot_data(edge_style: EdgeStyle | None = None, surface_style: SurfaceStyle | None = None)#

Create a discretized representation.

rotation(center: Point2D, angle: float)#

BSplineCurve2D rotation.

Parameters:
  • center – rotation center

  • angle – angle rotation

Returns:

a new rotated Line2D

straight_line_area()#

Use shoelace algorithm for evaluating the area.

straight_line_center_of_mass()#

Straight line center of mass.

tessellate(linear_deflection: float | None = None, angular_deflection: float | None = 5.0) list[Point2D]#

Discretize the curve with tangential deflection (adaptive).

Parameters:
  • linear_deflection – Max orthogonal distance between the curve and the polygon.

  • angular_deflection – Max angular difference in degrees between two consecutive segments in the polygon.

Returns:

A list of discretized points on the curve.

tessellate_uniform_deflection(deflection: float | None = None) list[Point2D]#

Discretize the curve with uniform deflection (adaptive).

Parameters:

deflection – Max distance between the curve and the polygon.

Returns:

A list of discretized points on the curve.

to_3d(plane_origin, x1, x2)#

Transform a B-Spline Curve 2D in 3D.

to_step(current_id, *args, **kwargs)#

Export to STEP format.

class volmdlr.edges.BSplineCurve3D(degree: int, control_points: list[Point3D], knot_multiplicities: list[int], knots: list[float], weights: list[float] | None = None, name: str = '')#

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[volmdlr.Point3D]) – A list of 3-dimensional points

  • knot_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)#

Calculate 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#

Return bounding box.

circle_intersections(circle, abs_tol: float = 1e-06)#

Get the intersections with the specified circle.

curvature(u: float, point_in_curve: bool = False)#

Return the curvature of a curve and the point where it is located.

curve_intersections(curve, abs_tol: float = 1e-06)#

Get the intersections with the specified curve.

direction_vector(abscissa=0.0)#

Get direction vector at given abscissa value (value between o and bspline length).

classmethod from_step(arguments, object_dict, **kwargs)#

Convert 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:

volmdlr.edges.BSplineCurve3D

get_bounding_element()#

Get bounding box if a 3D object, or bounding rectangle if 2D.

get_direction_vector(abscissa=0.0)#

Calculate direction vector at given abscissa value (value between o and bspline length).

global_maximum_curvature(nb_eval: int = 21, point_in_curve: bool = False)#

Return the global maximum curvature of a curve and the point where it is located.

insert_knot(knot: float, num: int = 1)#

Return a new BSplineCurve3D.

is_shared_section_possible(other_bspline2, tol)#

Verify 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(linesegment: LineSegment3D, abs_tol: float = 1e-06)#

Calculate intersections between a BSplineCurve3D and a LineSegment3D.

Parameters:
  • linesegment – 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)#

Create 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)#

Return the maximum curvature of a curve and the point where it is located.

minimum_radius(point_in_curve=False)#

Return the minimum curvature radius of a curve and the point where it is located.

move_frame_along(frame, *args, **kwargs)#

Move frame along the edge.

normal(position: float = 0.0)#

Return the normal vector at a given parameter of the curve.

ocp_curve() Geom_BSplineCurve#

Cached OCP curve representation.

Returns the OpenCASCADE curve, creating and caching it on first access.

Returns:

The cached OpenCASCADE curve representation.

plot(ax=None, edge_style: EdgeStyle | None = None)#

Matplotlib plot method for a BSpline Curve 3D.

revolution(axis_point, axis, angle)#

Return the face generated by the revolution of the BSpline Curve 3D.

rotation(center: Point3D, axis: Vector3D, angle: float)#

BSplineCurve3D rotation.

Parameters:
  • center – rotation center

  • axis – rotation axis

  • angle – angle rotation

Returns:

a new rotated BSplineCurve3D

sweep(*args, **kwargs)#

Bspline 3D is used as path for sweeping given section through it.

Returns:

tessellate(linear_deflection: float | None = None, angular_deflection: float | None = 5.0) list[Point3D]#

Discretize the curve with tangential deflection (adaptive).

Parameters:
  • linear_deflection – Max orthogonal distance between the curve and the polygon.

  • angular_deflection – Max angular difference in degrees between two consecutive segments in the polygon.

Returns:

A list of discretized points on the curve.

tessellate_uniform_deflection(deflection: float | None = None) list[Point3D]#

Discretize the curve with uniform deflection (adaptive).

Parameters:

deflection – Max distance between the curve and the polygon.

Returns:

A list of discretized points on the curve.

to_2d(plane_origin, x, y)#

Transform 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.

to_step(current_id, surface_id=None, curve2d=None)#

Export to STEP format.

triangulation()#

Triangulation method for a BSplineCurve3D.

trim_between_evaluations(parameter1: float, parameter2: float)#

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 volmdlr.edges.BezierCurve2D(degree: int, control_points: list[Point2D], name: str = '')#

Bases: BSplineCurve2D

A class for 2-dimensional Bézier curves.

Parameters:
  • degree (int) – The degree of the Bézier curve.

  • control_points (list[volmdlr.Point2D]) – A list of 2-dimensional points

  • name (str, optional) – The name of the B-spline curve. Default value is ‘’

class volmdlr.edges.BezierCurve3D(degree: int, control_points: list[Point3D], name: str = '')#

Bases: BSplineCurve3D

A class for 3-dimensional Bézier curves.

Parameters:
  • degree (int) – The degree of the Bézier curve

  • control_points (list[volmdlr.Point3D]) – A list of 3-dimensional points

  • name (str, optional) – The name of the B-spline curve. Default value is ‘’

copy(deep: bool = True, memo=None)#

Return a copy of the instance.

Parameters:
  • deep – If False, perform a shallow copy. If True, perform a deep copy.

  • memo – (Optional) A dictionary to keep track of objects that have been already copied.

get_reverse()#

Reverses the Bezier’s direction by reversing its control points.

Returns:

A reversed B-Spline curve.

Return type:

volmdlr.edges.BSplineCurve.

class volmdlr.edges.Edge(start, end, reference_path: str = '#', name='')#

Bases: DessiaObject

Define a simple edge Object.

abscissa(point, tol: float = 1e-06)#

Compute the abscissa of an Edge.

Parameters:
  • point (Union[volmdlr.Point2D, volmdlr.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)#

Get 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.

crossings(edge)#

Get the crossings between two edges.

curve()#

Return the curve that defines the geometry of the edge.

delete_shared_section(other_edge, abs_tol: float = 1e-06)#

Delete from self, the section shared with the other edge.

Parameters:
  • other_edge – other edge.

  • abs_tol – tolerance.

Returns:

direction_independent_is_close(other_edge, tol: float = 1e-06)#

Verify if two line segments are the same, not considering its direction.

direction_vector(abscissa)#

Calculate the direction vector the edge at given abscissa.

Parameters:

abscissa – edge abscissa

Returns:

direction vector

discretization_points(*, number_points: int | None = None, angle_resolution: int | None = None)#

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_ocp(ocp_edge: TopoDS_Shape) Edge#

Intaciate an volmdlr edge from an ocp edge.

classmethod from_step(arguments, object_dict, **kwargs)#

Convert 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:

volmdlr.edges.Edge

generic_get_shared_section(other_edge, abs_tol: float = 1e-06)#

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)#

Get 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.

get_reverse()#

Get the same edge, but in the opposite direction.

get_shared_section(*args, **kwargs)#

Get the shared section between two arcs of ellipse.

get_topods()#

Get edge equivalent TopoDS_Edge like shape.

intersections(edge2: Edge, abs_tol: float = 1e-06, force_sort: bool = False)#

Get 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)#

Verify if two edges are equal, considering a certain tolerance.

is_point_edge_extremity(other_point, abs_tol: float = 1e-06)#

Verify 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.

length()#

Calculate the edge’s length.

local_discretization(point1, point2, number_points: int = 10)#

Get 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.

middle_point()#

Get the middle point for an edge.

Returns:

minimum_distance(element, return_points=False)#

Evaluate 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)#

Calculate the normal vector the edge at given abscissa.

Returns:

the normal vector

property periodic#

Return True if edge is periodic.

plot_data(edge_style: EdgeStyle | None = None, surface_style: SurfaceStyle | None = None)#

Workaround to edges that don’t have the plot_data typescript implementation.

plot_data_primitives(edge_style: EdgeStyle | None = None) list[PlotDataObject]#

Get list of plot_data primitives representing self.

point_at_abscissa(abscissa)#

Calculate the point at given abscissa.

point_belongs(point, abs_tol: float = 1e-06)#

Check if a point belongs to the edge.

Parameters:
  • point (Union[volmdlr.Point2D, volmdlr.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 edge, False otherwise

Return type:

bool

point_distance(point: Point2D | Point3D)#

Calculate the distance from a given point.

Parameters:

point (Union[volmdlr.Point2D, volmdlr.Point3D]) – The point to be checked.

Returns:

distance.

polygon_points(discretization_resolution: int)#

Deprecated method of discretization_points.

reverse()#

Get the edge in the reverse direction.

property root_shape: Shape#

Get the root shape.

scale(factor: float, origin: Point3D | Point2D | None = None) Edge#

Perform a scale transformation on the shape.

Parameters:
  • factor – The scaling value.

  • origin – The center of the scale.

Returns:

A new transformed shape.

property simplify#

Search another simplified edge that can represent the edge.

sort_points_along_curve(points: list[Point2D | Point3D])#

Sort point along a curve.

Parameters:

points – list of points to be sorted.

Returns:

sorted points.

split(split_point, tol: float = 1e-06)#

Get the same edge, but in the opposite direction.

split_with_sorted_points(sorted_points, abs_tol: float = 1e-06)#

Split edge in various sections using a list of sorted points along the edge.

Parameters:

sorted_points – sorted list of points.

Returns:

list of edge sections.

straight_line_point_belongs(point)#

Verify 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)#

Convert 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)#

Verify 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)#

Trims edge between two points.

Parameters:
  • point1 – point 1.

  • point2 – point 2.

Returns:

edge trimmed.

unit_direction_vector(abscissa: float = 0.0)#

Calculate the unit direction vector the edge at given abscissa.

Parameters:

abscissa – edge abscissa

Returns:

unit direction vector

unit_normal_vector(abscissa: float = 0.0)#

Calculate the unit normal vector the edge at given abscissa.

Parameters:

abscissa – edge abscissa

Returns:

unit normal vector

validate_crossings(edge, intersection)#

Validate the intersections as crossings: edge not touching the other at one end, or in a tangent point.

property wrapped#

Get OCP wrapped object.

class volmdlr.edges.FullArc2D(circle: Circle2D, start_end: Point2D | None = None, reference_path: str = '#', name: str = '')#

Bases: FullArcMixin, Arc2D

An edge that starts at start_end, ends at the same point after having described a circle.

property bounding_rectangle#

Get the bounding rectangle for a full arc 2d.

center_of_mass()#

Get the center of the full arc 2d.

classmethod dict_to_object(dict_, *args, **kwargs)#

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)#

Map the 2D full arc to a new frame or its original frame.

Parameters:
  • frame (volmdlr.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:

volmdlr.edges.FullArc2D

classmethod from_3_points(point1, point2, point3, reference_path: str = '#', name: str = '')#

Create a circle 2d from 3 points.

Returns:

circle 2d.

get_reverse()#

Reverse of full arc 2D.

line_intersections(line: Line2D, tol=1e-09)#

Full Arc 2D intersections with a Line 2D.

linesegment_intersections(linesegment: LineSegment2D, abs_tol=1e-09)#

Full arc 2D intersections with a line segment.

plot(ax=None, edge_style: EdgeStyle | None = None)#

Plot a fullarc using Matplotlib.

point_belongs(point: Point2D, abs_tol: float = 1e-06)#

Return if given point belongs to the FullArc2D.

polygonization()#

Create a Polygon from a full arc 2d.

rotation(center: Point2D, angle: float)#

Rotation of a full arc 2D.

straight_line_area()#

Calculate the area of the full arc, with line drawn from start to end.

Returns:

straight_line_area.

straight_line_center_of_mass()#

Straight line center of mass.

straight_line_point_belongs(point)#

Verify 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)#

Transform the full arc 2D into a 3D full arc.

Parameters:
  • plane_origin (volmdlr.Point3D) – The origin of plane to draw the full arc 3D.

  • x (volmdlr.Vector3D) – First direction of the plane

  • y (volmdlr.Vector3D) – Second direction of the plane.

Returns:

A 3D full arc.

Type:

Full Arc 3D.

to_dict(use_pointers: bool = False, memo=None, path: str = '#', id_method=True, id_memo=None, **kwargs)#

Store all Full Arc 2D attributes in a dict object.

translation(offset: Vector2D, memo=None)#

Translation of a full arc 2D.

Parameters:
  • offset – translation vector.

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

class volmdlr.edges.FullArc3D(circle: Circle3D, start_end: Point3D | None = None, name: str = '')#

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)#

Change vector frame_mapping and return a new FullArc3D.

side = ‘old’ or ‘new’

classmethod from_3_points(point1, point2, point3, name: str = '')#

Create a full arc 3D from 3 given points.

classmethod from_center_normal(center: Point3D, normal: Vector3D, start_end: Point3D, name: str = '')#

Create 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 = '')#

Initialize a full arc from a circle.

fullarc_intersections(fullarc3d, abs_tol: float = 1e-06)#

Calculate 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.

get_reverse()#

Define a new FullArc3D, identical to self, but in the opposite direction.

linesegment_intersections(linesegment: LineSegment3D, abs_tol=1e-06)#

Calculate the intersections between a full arc 3d and a line segment 3d.

Parameters:
  • linesegment – 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 | None = None, show_frame=False)#

Plot fullarc3d using matplotlib.

point_belongs(point: Point3D, abs_tol: float = 1e-06)#

Return if given point belongs to the FullArc3D.

rotation(center: Point3D, axis: Vector3D, angle: float)#

Rotates the FullArc3D object around a specified axis by a given angle.

Parameters:
  • center ((volmdlr.Point3D)) – The center point of rotation.

  • axis ((volmdlr.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)#

Split the circle into two arcs at a given point.

Parameters:
  • split_point – splitting point.

  • tol – tolerance.

Returns:

list of two arcs.

to_2d(plane_origin, x, y)#

Transform a FullArc3D into an FullArc2D, 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:

FullArc2D.

to_dict(use_pointers: bool = False, memo=None, path: str = '#')#

Object serialization.

to_step(current_id, surface_id=None)#

Export to STEP format.

translation(offset: Vector3D, memo=None)#

Translate the FullArc3D object by a specified offset.

Parameters:
  • offset ((volmdlr.Vector3D).) – The translation offset vector.

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

A new FullArc3D object that is the result of the translation.

Return type:

FullArc3D.

class volmdlr.edges.FullArcEllipse(ellipse: Ellipse2D | Ellipse3D, start_end: Point2D | Point3D, name: str = '')#

Bases: Edge

Abstract class to define an ellipse.

abscissa(point, tol: float = 1e-06)#

Compute the abscissa of an Edge.

Parameters:
  • point (Union[volmdlr.Point2D, volmdlr.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#

Get ellipse’s center point.

classmethod from_curve(ellipse, name: str = '')#

Create a fullarc ellipse from a ellipse curve.

get_reverse()#

Define a new FullArcEllipse, identical to self, but in the opposite direction.

length()#

Calculate 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#

Return True if edge is periodic.

point_belongs(point: Point2D | Point3D, abs_tol: float = 0.01)#

Verify 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

straight_line_point_belongs(point)#

Verify 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

class volmdlr.edges.FullArcEllipse2D(ellipse: Ellipse2D, start_end: Point2D, name: str = '')#

Bases: FullArcEllipse, ArcEllipse2D

Define a FullArcEllipse2D.

abscissa(point: Point2D | Point3D, tol: float = 1e-06)#

Calculate 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)#

Change frame_mapping and return a new FullArcEllipse2D.

Parameters:
  • frame (volmdlr.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:

FullArcEllipse2D

plot(ax=None, edge_style: EdgeStyle | None = None)#

Matplotlib plot for an ellipse.

to_3d(plane_origin, x, y)#

Transform the full arc of ellipse 2D into a 3D full arc of ellipse.

Parameters:
  • plane_origin (volmdlr.Point3D) – The origin of plane to draw the full arc of ellipse 3D.

  • x (volmdlr.Vector3D) – First direction of the plane

  • y (volmdlr.Vector3D) – Second direction of the plane.

Returns:

A 3D full arc of ellipse.

Return type:

FullArcEllipse3D

translation(offset: Vector2D, memo=None)#

Full ArcEllipse 2D translation.

Parameters:
  • offset (volmdlr.Vector2D) – translation vector.

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

A new translated FullArcEllipse2D.

Return type:

FullArcEllipse2D

class volmdlr.edges.FullArcEllipse3D(ellipse: Ellipse3D, start_end: Point3D, name: str = '')#

Bases: FullArcEllipse, ArcEllipse3D

Define a FullArcEllipse3D.

abscissa(point: Point3D, tol: float = 1e-06)#

Calculate the abscissa a given point.

Parameters:
  • point – point to calculate abscissa.

  • tol – tolerance allowed.

Returns:

abscissa

classmethod dict_to_object(dict_, *args, **kwargs)#

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)#

Change frame_mapping and return a new FullArcEllipse3D.

Parameters:
  • frame (volmdlr.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:

FullArcEllipse3D

line_intersections(line, abs_tol: float = 1e-06)#

Get 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 | None = None)#

Ellipse plot.

split(split_point, tol: float = 1e-06)#

Split 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)#

Transform 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 = '#')#

Transform an instance of a Full arc ellipse into a dictionary.

translation(offset: Vector3D, memo=None)#

Ellipse3D translation.

Parameters:
  • offset (volmdlr.Vector3D) – translation vector.

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

A new translated FullArcEllipse3D.

Return type:

FullArcEllipse3D

trim(point1, point2, *args, **kwargs)#

Trims fullarcellipse between two points.

Parameters:
  • point1 – point 1.

  • point2 – point 2.

Returns:

edge trimmed.

class volmdlr.edges.FullArcMixin(circle: Circle2D | Circle3D, start_end: Point2D | Point3D, name: str = '')#

Bases: ArcMixin

Abstract class for representing a circle with a start and end points that are the same.

property angle#

Angle of Full Arc.

classmethod from_curve(circle, name: str = '')#

Create A full arc, 2d or 3d, from circle.

get_start_end_angles()#

Return the start and end angle of the arc.

line_intersections(line: Line3D, tol: float = 1e-06)#

Calculate intersections between an FullArc3D and a Line3D.

Parameters:
  • line – line to verify intersections.

  • tol – maximum tolerance.

Returns:

list with intersections points between line and FullArc3D.

property periodic#

Return True if an edge is periodic.

split(split_point, tol: float = 1e-06)#

Split arc at a given point.

Parameters:
  • split_point – splitting point.

  • tol – tolerance.

Returns:

list of two Arc.

trim(point1, point2, *args, **kwargs)#

Trims fullarc between two points.

Parameters:
  • point1 – point 1.

  • point2 – point 2.

Returns:

edge trimmed.

class volmdlr.edges.LineSegment(start: Point2D | Point3D, end: Point2D | Point3D, reference_path: str = '#', name: str = '')#

Bases: Edge

Abstract class.

abscissa(point, tol=1e-06)#

Calculate 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)#

Return 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)#

Get 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

get_geo_points()#

Return geo points.

get_shared_section(other_edge, abs_tol: float = 1e-06)#

Get the shared section between two line segments.

Parameters:
  • other_edge – other line segment to verify for shared section.

  • abs_tol – tolerance.

Returns:

shared line segment section.

is_close(other_edge, tol: float = 1e-06)#

Check 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.

length()#

Get the length of a Line Segment.

property line#

Return the line from which the line segment was extracted.

middle_point()#

Calculate the middle point of a Line Segment.

Returns:

normal_vector(abscissa=0.0)#

Return 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)#

Calculate 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)#

Check if a point belongs to the line segment. It uses the point_distance.

Parameters:
  • point (Union[volmdlr.Point2D, volmdlr.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_distance(point)#

Abstract method.

point_projection(point)#

Calculate 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)#

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)#

Closing straight line point belongs verification.

Verify 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.

to_dict(*args, **kwargs)#

Define custom base to_dict for LineSegment children.

class volmdlr.edges.LineSegment2D(start: Point2D, end: Point2D, reference_path: str = '#', name: str = '')#

Bases: LineSegment

Define a line segment limited by two points.

axial_symmetry(line)#

Find out the symmetric linesegment2d according to a line.

property bounding_rectangle#

Evaluate the bounding rectangle of the Line segment.

closest_point_on_segment(point)#

Get the closest point on the line segment and another given point.

create_tangent_circle(point, other_line)#

Create a circle tangent to a LineSegment.

distance_linesegment(linesegment, return_points=False)#

Calculate 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)#

Change vector frame_mapping and return a new LineSegment2D.

side = ‘old’ or ‘new’.

get_reverse()#

Invert the sense of the line segment.

infinite_primitive(offset)#

Get an infinite primitive.

is_horizontal(tolerance: float = 1e-06) bool#

Check if line is horizontal (same y-coordinate for start and end points).

is_vertical(tolerance: float = 1e-06) bool#

Check if line is horizontal (same x-coordinate for start and end points).

line_crossings(line: Line2D)#

Line Segment crossings with line 2d.

line_distance(line, return_points: bool = False)#

Calculate 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: Line2D)#

Line Segment intersections with volmdlr_curves.Line2D.

linesegment_intersections(linesegment: LineSegment2D, abs_tol=1e-06)#

Touching line segments does not intersect.

nearest_point_to(point)#

Find out the nearest point on the linesegment to point.

plot(ax=None, edge_style: EdgeStyle | None = None)#

Plot the Linesegment2D.

plot_data(edge_style: EdgeStyle | None = None)#

Plot data method for a LineSegment2D.

Parameters:

edge_style – edge style.

Returns:

plot_data.LineSegment2D object.

point_distance(point, return_other_point=False)#

Compute 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.

point_projection(point)#

If the projection falls outside the LineSegment2D, returns None.

rotation(center: Point2D, angle: float)#

LineSegment2D rotation.

Parameters:
  • center – rotation center

  • angle – angle rotation

Returns:

a new rotated LineSegment2D

straight_line_area()#

Calculate the area of the LineSegment2D, with line drawn from start to end.

Returns:

straight_line_area.

straight_line_center_of_mass()#

Straight line center of mass.

straight_line_second_moment_area(*args, **kwargs)#

Straight line second moment area for a line segment.

to_3d(plane_origin, x1, x2)#

Transform the Line segment 2D into a 3D line segment.

Parameters:
  • plane_origin (volmdlr.Point3D) – The origin of plane to draw the Line segment 3D.

  • x1 (volmdlr.Vector3D) – First direction of the plane

  • x2 (volmdlr.Vector3D) – Second direction of the plane.

Returns:

A 3D line segment.

Return type:

LineSegment3D

to_dict(*args, **kwargs)#

Store all Line Segment 2D attributes in a dict object.

translation(offset: Vector2D, memo=None)#

LineSegment2D translation.

Parameters:
  • offset – translation vector.

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

A new translated LineSegment2D.

class volmdlr.edges.LineSegment3D(start: Point3D, end: Point3D, reference_path: str = '#', name: str = '')#

Bases: LineSegment

Define a line segment limited by two points.

babylon_curves()#

Return the babylon representation of the edge.

property bounding_box#

Get bounding box for Line Segment 3D.

distance_arc(arc3d, return_points=False)#

Calculate 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)#

Calculate 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)#

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)#

Change LineSegment3D frame_mapping and return a new LineSegment3D.

side = ‘old’ or ‘new’

get_reverse()#

Get the reverse of the Line Segment.

line_distance(line, return_points: bool = False)#

Calculate 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)#

Get 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)#

Get 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)#

Get 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)#

Return the points on this line and on the other line that are the closest of lines.

move_frame_along(frame)#

Move frame along edge.

normal_vector(abscissa=0.0)#

Return the normal vector to the curve at the specified abscissa.

parallel_distance(other_linesegment)#

Calculate the parallel distance between two Line Segments 3D.

plane_projection2d(center, x, y)#

Calculate 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 | None = None)#

Plot the Line segment 3d using matplotlib.

plot2d(x_3d, y_3d, ax=None, color='k', width=None)#

Create a 2d plot of the Line segment 3d using matplotlib.

plot_data(x_3d, y_3d, edge_style: EdgeStyle | None = None)#

Plot a Line Segment 3D object using dessia’s plot_data library.

point_distance(point)#

Return the minimal distance to a point.

revolution(axis_point, axis, angle)#

Return the face generated by the revolution of the line segments.

rotation(center: Point3D, axis: Vector3D, angle: float)#

LineSegment3D rotation.

Parameters:
  • center – rotation center

  • axis – rotation axis

  • angle – angle rotation

Returns:

a new rotated LineSegment3D

sweep(*args)#

Line Segment 3D is used as path for sweeping given section through it.

Returns:

to_2d(plane_origin, x, y)#

Transform 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.

to_bspline_curve(resolution=10)#

Convert a LineSegment3D to a BSplineCurve3D.

to_dict(*args, **kwargs)#

Store all Line Segment 3D in a dict object.

translation(offset: Vector3D, memo=None)#

LineSegment3D translation.

Parameters:
  • offset – translation vector

  • memo – (Optional) A dictionary that keeps track of elements that have already been transformed and also save the current transformation. This is useful when transforming data structures where data is intended to be shared between primitives.

Returns:

A new translated LineSegment3D

unit_normal_vector(abscissa=0.0)#

Calculate the Line segment’s unit normal vector.