Base Modules#
Core Compiled#
Cython functions
- class volmdlr.core_compiled.Arrow3D(x, y, z, starting_point=None, *args, **kwargs)#
Bases:
FancyArrowPatch- draw(renderer)#
Draw the arrow by overloading a Matplotlib method. Do not rename this method!
- plot(ax=None, color='b')#
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, arrowstyle=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, connectionstyle=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, mutation_aspect=<UNSET>, mutation_scale=<UNSET>, patchA=<UNSET>, patchB=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, positions=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)#
Set multiple properties at once.
Supported properties are
- Properties:
agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None animated: bool antialiased or aa: bool or None arrowstyle: str or ~matplotlib.patches.ArrowStyle capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None color: :mpltype:`color` connectionstyle: [ ‘arc3’ | ‘angle3’ | ‘angle’ | ‘arc’ | ‘bar’ ] edgecolor or ec: :mpltype:`color` or None facecolor or fc: :mpltype:`color` or None figure: ~matplotlib.figure.Figure fill: bool gid: str hatch: {‘/’, ‘\’, ‘|’, ‘-’, ‘+’, ‘x’, ‘o’, ‘O’, ‘.’, ‘*’} in_layout: bool joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} label: object linestyle or ls: {‘-’, ‘–’, ‘-.’, ‘:’, ‘’, (offset, on-off-seq), …} linewidth or lw: float or None mouseover: bool mutation_aspect: float mutation_scale: float patchA: .patches.Patch patchB: .patches.Patch path_effects: list of .AbstractPathEffect picker: None or bool or float or callable positions: unknown rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float
- class volmdlr.core_compiled.Basis(name: str = '', **kwargs)#
Bases:
DessiaObjectAbstract class of a basis
- copy(deep=True, memo=None)#
Copy object.
- Parameters:
deep – If False, perform a shallow copy. If True, perform a deep copy.
memo – A dict that keep track of references.
- class volmdlr.core_compiled.Basis2D(u: Vector2D, v: Vector2D, name: Text = '')#
Bases:
BasisDefines a 2D basis.
- Parameters:
u (
volmdlr.Vector2D) – First vector of the basisv (
volmdlr.Vector2D) – Second vector of the basis
- copy(deep=True, memo=None)#
Creates a copy of a 2-dimensional basis.
- Parameters:
deep – not used
memo – not used
- Returns:
A copy of the Basis2D
- Return type:
volmdlr.Basis2D
- global_to_local_coordinates(vector: Vector2D) Vector2D#
Convert the given vector’s coordinates from the global landmark to the local landmark of this Basis2D.
- Parameters:
vector (
volmdlr.Vector2D) – The vector to convert, given in global coordinates.- Returns:
The converted vector, in local coordinates.
- Return type:
volmdlr.Vector2D
- inverse_transfer_matrix()#
Computes the inverse transfer matrix of the 2-dimensional basis.
- Returns:
The 2x2 inverse transfer matrix
- Return type:
volmdlr.Matrix22
- local_to_global_coordinates(vector: Vector2D) Vector2D#
Convert the given vector’s coordinates from the local landmark of this Basis2D to the global landmark.
- Parameters:
vector (
volmdlr.Vector2D) – The vector to convert, given in local coordinates.- Returns:
The converted vector, in global coordinates.
- Return type:
volmdlr.Vector2D
- new_coordinates(vector: Vector2D) Vector2D#
Convert the given vector’s coordinates from the global landmark to the local landmark of this Basis2D.
- Parameters:
vector (
volmdlr.Vector2D) – The vector to convert, given in global coordinates.- Returns:
The converted vector, in local coordinates.
- Return type:
volmdlr.Vector2D
Deprecated since version Use: global_to_local_coordinates instead.
- normalize()#
Normalizes the basis, and return a new object.
- Returns:
A new normalized basis
- Return type:
- old_coordinates(vector: Vector2D) Vector2D#
Convert the given vector’s coordinates from the local landmark of this Basis2D to the global landmark.
- Parameters:
vector (
volmdlr.Vector2D) – The vector to convert, given in local coordinates.- Returns:
The converted vector, in global coordinates.
- Return type:
volmdlr.Vector2D
Deprecated since version Use: local_to_global_coordinates instead.
- rotation(angle: float)#
Rotates the 2-dimensional basis and returns a new rotated one.
- Parameters:
angle (float) – The angle of rotation in rad
- Returns:
The rotated Basis2D
- Return type:
volmdlr.Basis2D
- to_dict(*args, **kwargs)#
Serializes a 2-dimensional basis into a dictionary.
- Returns:
A serialized version of the Basis2D
- Return type:
dict
See also
How serialization and deserialization works in dessia_common
- to_frame(origin: Point2D) Frame2D#
Returns the 2-dimensional frame oriented the same way as the Basis2D and having for origin the given 2-dimensional point.
- Parameters:
origin (
volmdlr.Point2D) – The origin of the 2-dimensional frame- Returns:
A 2-dimensional frame
- Return type:
volmdlr.Frame2D
- transfer_matrix()#
Computes the transfer matrix of the 2-dimensional basis.
- Returns:
The 2x2 transfer matrix
- Return type:
volmdlr.Matrix22
- property vectors#
- class volmdlr.core_compiled.Basis3D(u: Vector3D, v: Vector3D, w: Vector3D, name: Text = '')#
Bases:
BasisDefines a 3D basis.
- Parameters:
u (
volmdlr.Vector3D) – First vector of the basisv (
volmdlr.Vector3D) – Second vector of the basisw (
volmdlr.Vector3D) – Third vector of the basis
- copy(deep=True, memo=None)#
Creates a copy of a 3-dimensional basis.
- Parameters:
deep – not used
memo – not used
- Returns:
A copy of the Basis3D
- Return type:
volmdlr.Basis3D
- euler_rotation(angles: Tuple[float, float, float])#
Rotates the 3-dimensional basis using euler rotation and returns a new basis as a result.
- Parameters:
angles (tuple) – Three angles corresponding to psi, theta, phi in rad
- Returns:
The rotated basis
- Return type:
volmdlr.Basis3D
- euler_rotation_parameters(angles: Tuple[float, float, float])#
Computes the new basis’ parameter after rotation of the basis using euler rotation.
- Parameters:
angles (tuple) – Three angles corresponding to psi, theta, phi in rad
- Returns:
The new vectors of rotated basis
- Return type:
tuple
- classmethod from_two_vectors(vector1: Vector3D, vector2: Vector3D, name: str = '') Basis3D#
Creates a basis with first vector1 adimensionned, as u, v is the vector2 subtracted of u component, w is the cross product of u and v.
- Parameters:
vector1 (
volmdlr.Vector3D.) – The first vector of the Basis3Dname – object’s name.
vector2 (
volmdlr.Vector3D) – The second vector of the Basis3D
- global_to_local_coordinates(vector: Vector3D) Vector3D#
Convert the given vector’s coordinates from the global landmark to the local landmark of this Basis3D.
- Parameters:
vector (
volmdlr.Vector3D) – The vector to convert, given in global coordinates.- Returns:
The converted vector, in local coordinates.
- Return type:
volmdlr.Vector3D
- inverse_transfer_matrix()#
Computes the inverse transfer matrix of the 3-dimensional basis.
- Returns:
The 3x3 inverse transfer matrix
- Return type:
volmdlr.Matrix33
- is_normalized(tol: float = 1e-06)#
Check if the basis vectors are normal to each other.
- Parameters:
tol (float) – Tolerance for considering a unit vector.
- Returns:
True if the basis vectors are normalized, False otherwise.
- Return type:
bool
- is_orthogonal(tol: float = 1e-06)#
Check if the basis vectors are orthogonal to each other.
- Parameters:
tol (float) – Tolerance for considering a dot product as zero.
- Returns:
True if the basis vectors are orthogonal, False otherwise.
- Return type:
bool
- is_orthonormal(tol: float = 1e-06)#
Check if the basis vectors are orthonormal to each other.
- Parameters:
tol (float) – Tolerance for considering an orthonormal basis.
- Returns:
True if the basis vectors are orthonormal, False otherwise.
- Return type:
bool
- local_to_global_coordinates(vector: Vector3D) Vector3D#
Convert the given vector’s coordinates from the local landmark of this Basis3D to the global landmark.
- Parameters:
vector (
volmdlr.Vector3D) – The vector to convert, given in local coordinates.- Returns:
The converted vector, in global coordinates.
- Return type:
volmdlr.Vector3D
- new_coordinates(vector: Vector3D) Vector3D#
Convert the given vector’s coordinates from the global landmark to the local landmark of this Basis3D.
- Parameters:
vector (
volmdlr.Vector3D) – The vector to convert, given in global coordinates.- Returns:
The converted vector, in local coordinates.
- Return type:
volmdlr.Vector3D
Deprecated since version Use: global_to_local_coordinates instead.
- normalize()#
Normalizes the basis, modifying its coordinates in place.
- Returns:
New normalized basis
- Return type:
- old_coordinates(vector: Vector3D) Vector3D#
Convert the given vector’s coordinates from the local landmark of this Basis3D to the global landmark.
- Parameters:
vector (
volmdlr.Vector3D) – The vector to convert, given in local coordinates.- Returns:
The converted vector, in global coordinates.
- Return type:
volmdlr.Vector3D
Deprecated since version Use: local_to_global_coordinates instead.
- rotation(axis: Vector3D, angle: float)#
Rotates the 3-dimensional basis and returns a new rotated one.
- Parameters:
axis (
volmdlr.Vector3D) – The axis around which the rotation is madeangle (float) – The angle of rotation in rad
- Returns:
The rotated Basis3D
- Return type:
volmdlr.Basis3D
- to_dict(*args, **kwargs)#
Serializes a 3-dimensional basis into a dictionary.
- Returns:
A serialized version of the Basis3D
- Return type:
dict
See also
How serialization and deserialization works in dessia_common
- to_frame(origin)#
Returns the 3-dimensional frame oriented the same way as the Basis3D and having for origin the given 3-dimensional point.
- Parameters:
origin (
volmdlr.Point3D) – The origin of the 3-dimensional frame- Returns:
A 3-dimensional frame
- Return type:
volmdlr.Frame3D
- transfer_matrix()#
Computes the transfer matrix of the 3-dimensional basis.
- Returns:
The 3x3 transfer matrix
- Return type:
volmdlr.Matrix33
- property vectors#
- x_rotation(angle: float)#
Rotates the basis around the X axis and a new basis is returned as a result.
- Parameters:
angle (float) – The rotation angle
- Returns:
The rotated Basis3D
- Return type:
volmdlr.Basis3D
- y_rotation(angle: float)#
Rotates the basis around the Y axis and a new basis is returned as a result.
- Parameters:
angle (float) – The rotation angle
- Returns:
The rotated Basis3D
- Return type:
volmdlr.Basis3D
- z_rotation(angle: float)#
Rotates the basis around the Z axis and a new basis is returned as a result.
- Parameters:
angle (float) – The rotation angle
- Returns:
The rotated Basis3D
- Return type:
volmdlr.Basis3D
- class volmdlr.core_compiled.Frame2D(origin: Point2D, u: Vector2D, v: Vector2D, name: Text = '')#
Bases:
Basis2DDefines a 2D basis :param origin:Point2D: origin of the basis :param u:Vector2D: first vector of the basis :param v:Vector2D: second vector of the basis
- Draw(ax=None, style='ok')#
# TODO : unused ? to be deleted ?
- Parameters:
ax
style
- Returns:
- basis()#
Returns the 2-dimensional basis oriented the same way as the Frame2D.
- Returns:
A 2-dimensional basis
- Return type:
volmdlr.Basis2D
- copy(deep=True, memo=None)#
Creates a copy of a 2-dimensional frame.
- Parameters:
deep – not used
memo – not used
- Returns:
A copy of the Frame2D
- Return type:
volmdlr.Frame2D
- global_to_local_coordinates(vector: Vector2D) Vector2D#
Convert the given vector’s coordinates from the global landmark to the local landmark of this Frame2D.
- Parameters:
vector (
volmdlr.Vector2D) – The vector to convert, given in global coordinates.- Returns:
The converted vector, in local coordinates.
- Return type:
volmdlr.Vector2D
- is_close(other_frame, abs_tol: float = 1e-06)#
Verifies if two frames are the same, up to given tolerance.
- Parameters:
other_frame – other frame.
abs_tol – tolerance used
- Returns:
- local_to_global_coordinates(vector: Vector2D) Vector2D#
Convert the given vector’s coordinates from the local landmark of this Frame2D to the global landmark.
- Parameters:
vector (
volmdlr.Vector2D) – The vector to convert, given in local coordinates.- Returns:
The converted vector, in global coordinates.
- Return type:
volmdlr.Vector2D
- new_coordinates(vector: Vector2D) Vector2D#
Convert the given vector’s coordinates from the global landmark to the local landmark of this Frame2D.
- Parameters:
vector (
volmdlr.Vector2D) – The vector to convert, given in global coordinates.- Returns:
The converted vector, in local coordinates.
- Return type:
volmdlr.Vector2D
Deprecated since version Use: global_to_local_coordinates instead.
- normalize()#
Normalizes the Frame, and return a new object.
- Returns:
A new normalized basis
- Return type:
- old_coordinates(vector: Vector2D) Vector2D#
Convert the given vector’s coordinates from the local landmark of this Frame2D to the global landmark.
- Parameters:
vector (
volmdlr.Vector2D) – The vector to convert, given in local coordinates.- Returns:
The converted vector, in global coordinates.
- Return type:
volmdlr.Vector2D
Deprecated since version Use: local_to_global_coordinates instead.
- plot(ax=None, color='b', alpha=1.0, plot_points=True, ratio=1.0)#
Plots the 2-dimensional frame.
- Parameters:
ax (
matplotlib.axes.Axes, optional) – The Axes on which the Point2D will be drawn. Default value is None, creating a new drawing figurecolor (str, optional) – not used
alpha (float, optional) – not used
plot_points (bool, optional) – not used
ratio (float, optional) – A ratio for controlling the size of the 2-dimensional frame. Default value is 1
- Returns:
A matplotlib Axes object on which the Point2D have been plotted
- Return type:
matplotlib.axes.Axes
- rotation(center: Point2D, angle: float, rotate_basis: bool = False)#
Returns a rotated 2-dimensional frame.
- Parameters:
center (
volmdlr.Point2D) – The center of rotationangle (float) – The rotation angle
- Returns:
New rotated frame
- Return type:
volmdlr.Frame2D
- to_dict(*args, **kwargs)#
Serializes a 2-dimensional frame into a dictionary.
- Returns:
A serialized version of the Frame2D
- Return type:
dict
See also
How serialization and deserialization works in dessia_common
- translation(vector)#
Returns a translated 2-dimensional frame.
- Parameters:
vector (
volmdlr.Vector2D) – The translation vector- Returns:
A new translated 2-dimensional frame
- Return type:
volmdlr.Frame2D
- class volmdlr.core_compiled.Frame3D(origin: Point3D, u: Vector3D, v: Vector3D, w: Vector3D, name: Text = '')#
Bases:
Basis3DDefines a 3D frame :param origin:Point3D: origin of the basis :param u:Vector3D: first vector of the basis :param v:Vector3D: second vector of the basis :param w:Vector3D: third vector of the basis
- basis()#
Returns the 3-dimensional basis oriented the same way as the Frame3D.
- Returns:
A 3-dimensional basis
- Return type:
volmdlr.Basis3D
- copy(deep=True, memo=None)#
Creates a copy of a 3-dimensional frame.
- Parameters:
deep – not used
memo – not used
- Returns:
A copy of the Frame3D
- Return type:
volmdlr.Frame3D
- classmethod from_3_points(point1, point2, point3, name: str = '')#
Creates a frame 3d from 3 points.
- Parameters:
point1 – point 1.
point2 – point 2.
point3 – point 3.
name – object’s name.
- Returns:
a frame 3d.
- classmethod from_origin_xyz(origin: Point3D)#
Returns a frame positioned in the given point and directions equivalent to the global coordinates systems.
- classmethod from_origin_yzx(origin: Point3D)#
Returns a frame positioned in the given point and with main axis (z direction) equal (1.0, 0.0, 0.0).
- classmethod from_origin_zxy(origin: Point3D)#
Returns a frame positioned in the given point and with main axis (z direction) equal (0.0, 1.0, 0.0).
- classmethod from_point_and_normal(origin, normal, name: str = '')#
Creates a frame 3D from a point and a normal vector.
- classmethod from_point_and_vector(point: Point3D, vector: Vector3D, main_axis: Vector3D = Vector3D(1.0, 0.0, 0.0), name: str = '')#
Creates a new frame from a point and vector by rotating the global frame. Global frame rotates in order to have ‘vector’ and ‘main_axis’ collinear. This method is very useful to compute a local frame of an object.
- Parameters:
point (
volmdlr.Point3D) – The origin of the new framevector (
volmdlr.Vector3D) – The vector used to define one of the main axis (by default X-axis) of the local framemain_axis (
volmdlr.Vector3D, optional) – The axis of global frame you want to match ‘vector’ (can be X3D, Y3D or Z3D). Default value is X3D, the vector (1, 0, 0)name (str) – Frame’s name.
- Returns:
The created local frame
- Return type:
volmdlr.Frame3D
- classmethod from_step(arguments, object_dict, **kwargs)#
Converts a step primitive from a 3-dimensional point to a Frame3D.
- Parameters:
arguments (list) – The arguments of the step primitive. The last element represents the unit_conversion_factor.
object_dict (dict) – The dictionary containing all the step primitives that have already been instantiated
- Returns:
The corresponding Frame3D object
- Return type:
volmdlr.Frame3D
- global_to_local_coordinates(vector: Vector3D) Vector3D#
Convert the given vector’s coordinates from the global landmark to the local landmark of this Frame3D.
- Parameters:
vector (
volmdlr.Vector3D) – The vector to convert, given in global coordinates.- Returns:
The converted vector, in local coordinates.
- Return type:
volmdlr.Vector3D
- is_close(other_frame, abs_tol: float = 1e-06)#
Verifies if two frames are the same, up to given tolerance.
- Parameters:
other_frame – other frame.
abs_tol – tolerance used
- Returns:
- local_to_global_coordinates(vector: Vector3D) Vector3D#
Convert the given vector’s coordinates from the local landmark of this Frame3D to the global landmark.
- Parameters:
vector (
volmdlr.Vector3D) – The vector to convert, given in local coordinates.- Returns:
The converted vector, in global coordinates.
- Return type:
volmdlr.Vector3D
- new_coordinates(vector: Vector3D) Vector3D#
Convert the given vector’s coordinates from the global landmark to the local landmark of this Frame3D.
- Parameters:
vector (
volmdlr.Vector3D) – The vector to convert, given in global coordinates.- Returns:
The converted vector, in local coordinates.
- Return type:
volmdlr.Vector3D
Deprecated since version Use: global_to_local_coordinates instead.
- normalize()#
Normalizes the Frame, and return a new object.
- Returns:
A new normalized basis
- Return type:
- old_coordinates(vector: Vector3D) Vector3D#
Convert the given vector’s coordinates from the local landmark of this Frame3D to the global landmark.
- Parameters:
vector (
volmdlr.Vector3D) – The vector to convert, given in local coordinates.- Returns:
The converted vector, in global coordinates.
- Return type:
volmdlr.Vector3D
Deprecated since version Use: local_to_global_coordinates instead.
- classmethod oxyz()#
Returns a frame equivalent to the global coordinates systems.
- classmethod oyzx()#
Returns a frame positioned in the origin and with main axis (z direction) equal (1.0, 0.0, 0.0).
- classmethod ozxy()#
Returns a frame positioned in the origin and with main axis (z direction) equal (0.0, 1.0, 0.0).
- plot(ax=None, color='b', alpha=1.0, plot_points=True, ratio=1.0)#
Plots the 3-dimensional frame.
- Parameters:
ax (
matplotlib.axes.Axes, optional) – The Axes on which the Point3D will be drawn. Default value is None, creating a new drawing figurecolor (str, optional) – not used
alpha (float, optional) – not used
plot_points (bool, optional) – not used
ratio (float, optional) – A ratio for controlling the size of the 3-dimensional frame. Default value is 1
- Returns:
A matplotlib Axes object on which the Point3D have been plotted
- Return type:
matplotlib.axes.Axes
- plot2d(x=Vector3D(1.0, 0.0, 0.0), y=Vector3D(0.0, 1.0, 0.0), ax=None, color='k')#
Plots the 3-dimensional frame on a 2-dimensional surface given by (x, y).
- Parameters:
x (
volmdlr.Vector3D, optional) – The first 3-dimensional vector of the 2-dimensional surface. Default value is X3D, the vector (1, 0, 0)y (
volmdlr.Vector3D, optional) – The second 3-dimensional vector of the 2-dimensional surface. Default value is Y3D, the vector (0, 1, 0)ax (
matplotlib.axes.Axes, optional) – The Axes on which the Frame3D will be drawn. Default value is None, creating a new drawing figurecolor (str, optional) – The color of the frame. Default value is ‘k’, for black
- Returns:
A matplotlib Axes object on which the 2-dimensional representation of the Frame3D have been plotted
- Return type:
matplotlib.axes.Axes
- rotation(center: Point3D, axis: Vector3D, angle: float)#
Rotates the center as a point and vectors as directions (calling Basis), and returns a new 3-dimensional frame.
- Parameters:
center (
volmdlr.Point3D) – The center of rotationaxis (
volmdlr.Vector3D) – The axis around which the rotation will be madeangle (float) – The rotation angle
- Returns:
New rotated frame
- Return type:
volmdlr.Frame3D
- to_dict(*args, **kwargs)#
Serializes a 3-dimensional frame into a dictionary.
- Returns:
A serialized version of the Frame3D
- Return type:
dict
See also
How serialization and deserialization works in dessia_common
- to_step(current_id)#
Writes a step primitive from a 3-dimensional frame.
- Parameters:
current_id (int) – The id of the last written primitive
- Returns:
A tuple containing the string representing the step primitive and the new current id
- Return type:
tuple
- volmdlr.core_compiled.LineSegment3DDistance(points_linesegment1, points_linesegment2)#
- class volmdlr.core_compiled.Matrix22(M11: float, M12: float, M21: float, M22: float)#
Bases:
objectClass representing a 2x2 matrix.
- Parameters:
M11 (float) – The first line, first column value
M12 (float) – The first line, second column value
M21 (float) – The second line, first column value
M22 (float) – The second line, second column value
- determinent()#
Computes the determinent of the matrix.
- Returns:
The determinent of the matrix
- Return type:
float
- inverse()#
Computes the invert matrix.
- Returns:
The inverse of the matrix
- Return type:
volmdlr.Matrix22
- vector_multiplication(vector)#
Multiplies the matrix by a 2-dimensional vector.
- Parameters:
vector (
volmdlr.Vector2D) – A Vector2D-like object- Returns:
A Vector2D-like object
- Return type:
volmdlr.Vector2D
- class volmdlr.core_compiled.Matrix33(M11: float, M12: float, M13: float, M21: float, M22: float, M23: float, M31: float, M32: float, M33: float)#
Bases:
objectClass representing a 3x3 matrix.
- Parameters:
M11 (float) – The first line, first column value
M12 (float) – The first line, second column value
M13 (float) – The first line, third column value
M21 (float) – The second line, first column value
M22 (float) – The second line, second column value
M23 (float) – The second line, third column value
M31 (float) – The third line, first column value
M32 (float) – The third line, second column value
M33 (float) – The third line, third column value
- determinent()#
Computes the determinent of the matrix.
- Returns:
The determinent of the matrix
- Return type:
float
- float_multiplication(float_value: float)#
Multiplies the whole matrix by a scalar value.
- Parameters:
float_value (float) – The value of the scalar
- Returns:
The new matrix after multiplication
- Return type:
volmdlr.Matrix33
- inverse()#
Computes the invert matrix.
- Returns:
The inverse of the matrix
- Return type:
volmdlr.Matrix33
- classmethod random_matrix(minimum: float = 0.0, maximum: float = 1.0, name: str = '')#
Creates a random matrix with values between bounds.
- Parameters:
minimum (float, optional) – Minimum possible value of matrix coefficients. Default value is 0
maximum (float, optional.) – Maximum possible value of matrix coefficients. Default value is 1
name – object’s name.
- Returns:
A random matrix
- Return type:
volmdlr.Matrix33
- to_numpy()#
Returns the numpy array corresponding to the matrix.
- Returns:
A numpy array of the matrix
- Return type:
numpy.array
- class volmdlr.core_compiled.Point2D#
Bases:
Vector2DClass representing a 2-dimensional point.
- Parameters:
x (float) – The vector’s abscissa
y (float) – The vector’s ordinate
name (str) – The vector’s name
- axial_symmetry(line: Line2D)#
Returns the symmetric two-dimensional point according to a line.
- Parameters:
line (
volmdlr.edges.Line2D) – the line used for axial symmetry- Returns:
the symmetrical point
- Return type:
volmdlr.Point2D
- coordinates()#
Gets x,y coordinates of a point2d.
- get_geo_lines(tag: int, point_mesh_size: float | None = None)#
Gets the lines that define a Point2D in a .geo file.
- Parameters:
tag (int) – The point index
mesh_size (float, optional) – The target mesh size close to the point, defaults to None
- Returns:
A line
- Return type:
str
- in_list(list_points, tol: float = 1e-06)#
Return True if point is in the list with a given tolerance. Returns False otherwise.
- classmethod line_intersection(line1: volmdlr.edges.Line2D, line2: volmdlr.edges.Line2D, curvilinear_abscissa: bool = False, name: str = '')#
Returns a Point2D based on the intersection between two infinite lines.
- Parameters:
line1 (
volmdlr.edges.Line2D) – The first lineline2 (
volmdlr.edges.Line2D) – The second linecurvilinear_abscissa (bool, optional) – True will return, in addition to the intersection point, the curvilinear abscissa of the point on the first line and on the second line. Otherwise, only the point will be returned
name – Object’s name.
- Returns:
The two-dimensional point at the intersection of the two lines
- Return type:
volmdlr.Point2D
- classmethod line_projection(point: Vector2D, line: volmdlr.edges.Line2D, name='')#
Computes the projection of a two-dimensional vector-like object on an infinite two-dimensional line
- Parameters:
point (
volmdlr.Vector2D) – the point to be projectedline (
volmdlr.edges.Line2D.) – the infinite linename – object’s name.
- Returns:
the projected point
- Return type:
volmdlr.Point2D
- classmethod middle_point(point1: Vector2D, point2: Vector2D, name='')#
Computes the middle point between two two-dimensional vector-like objects.
- Parameters:
point1 (
volmdlr.Vector2D) – the first pointpoint2 (
volmdlr.Vector2D.) – the second pointname – object’s name.
- Returns:
the middle point
- Return type:
volmdlr.Point2D
- nearest_point(points: List[Vector2D])#
Finds the nearest point out of a list of two-dimensional vector-like objects.
- Parameters:
points (List[
volmdlr.Vector2D]) – a list of points- Returns:
the nearest point out of the list
- Return type:
volmdlr.Vector2D
- plot(ax=None, color='k', alpha=1, plot_points=True)#
Plots the 2-dimensional point as a dot.
- Parameters:
ax (
matplotlib.axes.Axes, optional) – The Axes on which the Vector2D will be drawncolor (str, optional) – The color of the arrow
alpha (float, optional) – The transparency of the point from 0 to 1. 0 being fully transparent
plot_points (bool, optional) – # TODO: delete this attribute
- Returns:
A matplotlib Axes object on which the Point2D have been plotted
- Return type:
matplotlib.axes.Axes
- plot_data(marker=None, color='black', size=1, opacity=1, arrow=False, stroke_width=None)#
Transforms the two-dimensional point into a plot_data twe-dimensional point.
- Parameters:
marker (str, optional) – # TODO: unused parameter
color (str, optional) – # TODO: unused parameter
size (float, optional) – # TODO: unused parameter
opacity (float, optional) – # TODO: unused parameter
arrow (bool, optional) – # TODO: unused parameter
stroke_width (float, optional) – # TODO: unused parameter
- Returns:
a plot_data two-dimensional point
- Return type:
plot_data.Point2D
- point_distance(other_point: Point2D)#
Computes the euclidiean distance between two Point2D objects.
- Parameters:
other_point (
volmdlr.Point2D) – A Point2D object- Returns:
The euclidiean distance
- Return type:
float
- classmethod segment_intersection(segment1: LineSegment2D, segment2: LineSegment2D, curvilinear_abscissa: bool = False, name: str = '')#
Returns a Point2D based on the intersection between two finite lines.
- Parameters:
segment1 (
volmdlr.edges.LineSegment2D) – The first line segmentsegment2 (
volmdlr.edges.LineSegment2D) – The second line segmentcurvilinear_abscissa (bool, optional) – True will return, in addition to the intersection point, the curvilinear abscissa of the point on the first line segment and on the second line segment. Otherwise, only the point will be returned
name – object’s name.
- Returns:
The two-dimensional point at the intersection of the two lines segments
- Return type:
volmdlr.Point2D
- to_3d(plane_origin: Vector3D, vx: Vector3D, vy: Vector3D)#
Returns the 3-dimensional point corresponding to the 2-dimensional point placed on the 3-dimensional plane (XY) of the 3-dimensional frame (centered on plane_origin, having for basis (vx, vy, vz), vz being the cross product of vx and vy).
- Parameters:
plane_origin (
volmdlr.Vector3D) – The origin of the plane, on which lies the Vector2Dvx (
volmdlr.Vector3D) – The first direction of the planevy (
volmdlr.Vector3D) – The second direction of the plane
- Returns:
The Point3D from the Point2D set in the 3-dimensional space
- Return type:
volmdlr.Point3D
- to_dict(*args, **kwargs)#
Serializes a 2-dimensional point into a dictionary.
- Returns:
A serialized version of the Point2D
- Return type:
dict
See also
How serialization and deserialization works in dessia_common
- to_step(current_id, vertex=False)#
Write a step primitive from a 2-dimensional vector.
- Parameters:
current_id (int) – The id of the last written primitive
vector (bool, optional) – If ‘True’ creates a step VECTOR primitive. Otherwise, only a DIRECTION primitive will be created. Default value set to ‘False’
vertex (bool, optional) – If ‘True’ calls the to_step method of Point3D. Default value set to ‘False’
- Returns:
A tuple containing the string representing the step primitive and the new current id
- Return type:
tuple
- to_vector()#
Transforms a Point2D into a Vector2D and returns it.
- Returns:
A Vector2D
- Return type:
volmdlr.Vector2D
- class volmdlr.core_compiled.Point3D#
Bases:
Vector3DClass representing a 3-dimensional point.
- Parameters:
x (float) – The vector’s abscissa
y (float) – The vector’s ordinate
z – The vector’s applicate
name (str) – The vector’s name
- babylon_script()#
# TODO: to be deleted ? Returns the babylonjs script for 3D display in browser.
- Returns:
A babylonjs script
- Return type:
str
- coordinates()#
Returns the coordinates of a Point3D as a tuple of values.
- Returns:
A tuple containing the abscissan, the ordiante and the applicate of the Point3D
- Return type:
tuple
- classmethod from_step(arguments, object_dict, **kwargs)#
Converts a step primitive from a 3-dimensional point to a Point3D.
- 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 Point3D object
- Return type:
volmdlr.Point3D
- get_geo_lines(tag: int, point_mesh_size: float | None = None)#
Gets the lines that define a Point3D in a .geo file.
- Parameters:
tag (int) – The point index
mesh_size (float, optional) – The target mesh size close to the point, defaults to None
- Returns:
A line
- Return type:
str
- in_list(list_points, tol: float = 1e-06)#
Return True if point is in the list with a given tolerance. Returns False otherwise.
- classmethod middle_point(point1: Point3D, point2: Point3D, name='')#
Computes the middle point between two 3-dimensional points.
- Parameters:
point1 (
volmdlr.Point3D) – The first 3-dimensional pointpoint2 (
volmdlr.Point3D.) – The second 3-dimensional pointname – object’s name.
- Returns:
The middle point
- Return type:
volmdlr.Point3D
- nearest_point(points: List[Point3D])#
Returns the nearest 3-dimensional point out of the list.
- Parameters:
points (List[
volmdlr.Point3D]) – A list of 3-dimensional points- Returns:
The closest point
- Return type:
volmdlr.Point3D
- plot(ax=None, color='k', alpha=1, marker='o')#
Plots the 3-dimensional point.
- Parameters:
ax (
matplotlib.axes.Axes, optional) – The Axes on which the Point3D will be drawn. Default value is None, creating a new drawing figurecolor (str, optional) – The color of the point. Default value is ‘k’, for black
alpha (float, optional) – The transparency of the Point3D. Default value is 1, for full opacity
marker (str, optional) – The shape of the Point3D. Default value is ‘o’, for a round marker
- Returns:
A matplotlib Axes object on which the Point3D have been plotted
- Return type:
matplotlib.axes.Axes
- point_distance(point2: Point3D) float#
Computes the euclidean distance between two 3-dimensional points.
- Parameters:
point2 (
volmdlr.Point3D) – The other 3-dimensional point- Returns:
The euclidean distance
- Return type:
float
- to_dict(*args, **kwargs)#
Serializes a 3-dimensional point into a dictionary.
- Returns:
A serialized version of the Point3D
- Return type:
dict
See also
How serialization and deserialization works in dessia_common
- to_step(current_id, vertex=False)#
Writes a step primitive from a 3-dimensional point.
- Parameters:
current_id (int) – The id of the last written primitive
vertex (bool, optional) – If ‘True’, adds a VERTEX_POINT step primitive on top of the CARTESIAN_POINT step primitive. Default value set to ‘False’
- Returns:
A tuple containing the string representing the step primitive and the new current id
- Return type:
tuple
- to_vector()#
Converts a Point3D object to a Vector3D object.
- Returns:
A Vector3D
- Return type:
volmdlr.Vector3D
- class volmdlr.core_compiled.Vector#
Bases:
objectAbstract class of vector
- is_colinear_to(other_vector: Vector, abs_tol: float = 1e-06)#
Checks if two vectors are colinear. The two vectors should be of same dimension.
- Parameters:
other_vector (
volmdlr.Vector) – A vector-like objectabs_tol (float) – Absolute tolerance to consider colinear
- Returns:
True if the two vectors are colinear, False otherwise
- Return type:
bool
- is_perpendicular_to(other_vector: Vector, abs_tol: float = 1e-05)#
Checks if two vectors are perpendicular. The two vectors should be of same dimension.
- Parameters:
other_vector (
volmdlr.Vector) – A vector-like objectabs_tol (float) – Absolute tolerance to consider perpendicular
- Returns:
True if the two vectors are perpendicular, False otherwise
- Return type:
bool
- classmethod mean_point(points: List[Vector], name='')#
Find the mean point from a list of points. All the objects of this list should be of same dimension.
- Parameters:
points (List[
volmdlr.Vector]) – A list of vector-like objectsname – object’s name.
- Returns:
The mean point or vector
- Return type:
volmdlr.Vector
- name#
- classmethod remove_duplicate(points: List[Vector])#
An approximative method to remove duplicated points from a list. All the objects of this list should be of same dimension.
- Parameters:
points (List[
volmdlr.Vector]) – A list of vector-like objects with potential duplicates- Returns:
The new list of vector-like objects without duplicates&
- Return type:
List[
volmdlr.Vector]
- to_vector()#
- vector_projection(other_vector)#
Projects the vector onto other_vector.
- Parameters:
other_vector – Vector to project self.
- class volmdlr.core_compiled.Vector2D#
Bases:
VectorClass representing a 2-dimensional vector.
- Parameters:
x (float) – The vector’s abscissa
y (float) – The vector’s ordinate
- approx_hash()#
Computes an approximative hash value based on the coordinates.
- Returns:
An approximative hash value
- Return type:
int
- copy(deep=True, memo=None)#
Creates a copy of a 2-dimensional vector.
- Parameters:
deep – not used
memo – not used
- Returns:
A copy of the Vector2D-like object
- Return type:
volmdlr.Vector2D
- cross(other_vector: Vector2D)#
Computes the cross product of two 2-dimensional vectors.
- Parameters:
other_vector (
volmdlr.Vector2D) – A Vector2D-like object- Returns:
A scalar, result of the cross product
- Return type:
float
- deterministic_unit_normal_vector()#
# TODO: to be deleted ? # TODO: Or unit_normal_vector should be renamed deterministic_unit_normal_vector ?
- classmethod dict_to_object(dict_, *args, **kwargs)#
Deserializes a dictionary to a 3-dimensional point.
- Parameters:
dict (dict) – The dictionary of a serialized Point3D
- Returns:
- Return type:
volmdlr.Point3D
See also
How serialization and deserialization works in dessia_common
- dot(other_vector: Vector2D)#
Computes the dot product (scalar product) of two 2-dimensional vectors.
- Parameters:
other_vector (
volmdlr.Vector2D) – A Vector2D-like object- Returns:
A scalar, result of the dot product
- Return type:
float
- frame_mapping(frame: Frame2D, side: str)#
# TODO: Needs correction. Add an example ? Transforms a 2-dimensional vector from the current reference frame to a new one. Choose side equals to ‘old’ if the current reference frame is the old one ; choose side equals to ‘new’ if the input reference frame is the new one. This way, choosing ‘old’ will return the frame mapped vector of the input reference frame.
- Parameters:
frame (
volmdlr.Frame2D) – The input reference frameside (str) – Choose between ‘old’ and ‘new’
- Returns:
A frame mapped Vector2D-like object
- Return type:
volmdlr.Vector2D
- is_close(other_vector: Vector2D, tol: float = 1e-06)#
Checks if two vectors are close to each other considering the Euclidean distance. The tolerance can be modified. The two vectors should be of same dimension.
- Parameters:
other_vector (
volmdlr.Vector2D) – A Vector2D-like objecttol (float) – The tolerance under which the euclidean distance is considered equal to 0
- Returns:
True if the two Vector2D-like objects are close enough to each other, False otherwise
- Return type:
bool
- norm()#
Computes the euclidiean norm of a 2-dimensional vector.
- Returns:
Norm of the Vector2D-like object
- Return type:
float
- normal_vector()#
Returns the normal vector located pi/2 (counterclockwise) to the 2-dimensional vector.
- Returns:
A normal Vector2D
- Return type:
volmdlr.Vector2D
- plot(head_width: float = 3.0, origin: Vector2D = None, ax: matplotlib.axes.Axes = None, color: str = 'k', label: str = None)#
Plots the 2-dimensional vector. If the vector has a norm greater than 1e-9, it will be plotted with an arrow, else it will be plotted with a point.
- Parameters:
head_width (float, optional) – The width of the head of the arrow
origin (
volmdlr.Vector2D, optional) – The starting point of the tail of the arrowax (
matplotlib.axes.Axes, optional) – The Axes on which the Vector2D will be drawncolor (str, optional) – The color of the arrow
label (str, optional) – The text you want to display
- Returns:
A matplotlib Axes object on which the Vector2D have been plotted
- Return type:
matplotlib.axes.Axes
- point_distance(other_vector: Vector2D)#
Computes the euclidiean distance between two Vector2D objects.
- Parameters:
other_vector (
volmdlr.Vector2D) – A Vector2D object- Returns:
The euclidiean distance
- Return type:
float
- classmethod random(xmin: float, xmax: float, ymin: float, ymax: float, name: str = '')#
Returns a random 2-dimensional point.
- Parameters:
xmin (float) – The minimal abscissa
xmax (float) – The maximal abscissa
ymin (float) – The minimal ordinate
ymax (float) – The maximal ordinate
name – object’s name.
- Returns:
A random Vector2D
- Return type:
volmdlr.Vector2D
- rotation(center: Point2D, angle: float)#
Rotates the 2-dimensional vector and returns a new rotated vector
- Parameters:
center (
volmdlr.Point2D) – The center of rotationangle (float) – The angle of the rotation in radian
- Returns:
A rotated Vector2D-like object
- Return type:
volmdlr.Vector2D
- rotation_parameters(center: Point2D, angle: float)#
Calculates the parameters to be used in rotation methods
- Parameters:
center (
volmdlr.Point2D) – The center of rotationangle (float) – The angle of the rotation in radian
- Returns:
The abscissa and ordinate of the rotated vector
- Return type:
tuple
- to_3d(plane_origin: Point3D, vx: Vector3D, vy: Vector3D)#
Returns the 3-dimensional vector corresponding to the 2-dimensional vector placed on the 3-dimensional plane (XY) of the 3-dimensional frame (centered on plane_origin, having for basis (vx, vy, vz), vz being the cross product of vx and vy).
- Parameters:
plane_origin (
volmdlr.Vector3D) – The origin of the plane, on which lies the Vector2Dvx (
volmdlr.Vector3D) – The first direction of the planevy (
volmdlr.Vector3D) – The second direction of the plane
- Returns:
The Vector3D from the Vector2D set in the 3-dimensional space
- Return type:
volmdlr.Vector3D
- to_dict(*args, **kwargs)#
Serializes a 2-dimensional vector into a dictionary.
- Returns:
A serialized version of the Vector2D
- Return type:
dict
See also
How serialization and deserialization works in dessia_common
- to_point()#
Transforms a Vector2D into a Point2D and returns it.
- Returns:
A Point2D
- Return type:
volmdlr.Point2D
- to_step(current_id, vector=False, vertex=False)#
Write a step primitive from a 2-dimensional vector.
- Parameters:
current_id (int) – The id of the last written primitive
vector (bool, optional) – If ‘True’ creates a step VECTOR primitive. Otherwise, only a DIRECTION primitive will be created. Default value set to ‘False’
vertex (bool, optional) – If ‘True’ calls the to_step method of Point3D. Default value set to ‘False’
- Returns:
A tuple containing the string representing the step primitive and the new current id
- Return type:
tuple
- translation(offset: Vector2D, memo=None)#
Translates the 2-dimensional vector and returns a new translated vector
- Parameters:
offset (
volmdlr.Vector2D) – The offset vector of the translationmemo (dict) – (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 translated Vector2D-like object
- Return type:
volmdlr.Vector2D
- unit_normal_vector()#
Returns the unit normal vector located pi/2 (counterclockwise) to the 2-dimensional vector.
- Returns:
A unit normal Vector2D
- Return type:
volmdlr.Vector2D
- unit_vector()#
Calculates the unit vector.
- x#
- y#
- class volmdlr.core_compiled.Vector3D#
Bases:
VectorClass representing a 3-dimensional vector.
- Parameters:
x (float) – The vector’s abscissa
y (float) – The vector’s ordinate
Z – The vector’s applicate
name (str) – The vector’s name
- approx_hash()#
Computes an approximative hash value based on the coordinates.
- Returns:
An approximative hash value
- Return type:
int
- static axis_rotation_parameters(axis1_value, axis2_value, angle)#
# TODO: to be completed Calcules new axis1 and axis2 new values after vector rotation.
- Parameters:
axis1_value
axis2_value
angle
- Returns:
- Return type:
tuple
- copy(deep=True, memo=None)#
Creates a copy of a 2-dimensional vector.
- Parameters:
deep – not used
memo – not used
- Returns:
A copy of the Vector2D-like object
- Return type:
volmdlr.Vector2D
- cross(other_vector: Vector3D) Vector3D#
Computes the cross product between two 3-dimensional vectors.
- Parameters:
other_vector (
volmdlr.Vector3D) – A Vector3D-like object- Returns:
Value of the cross product
- Return type:
float
- deterministic_normal_vector()#
Returns a deterministic normal 3-dimensional vector.
- Returns:
A normal Vector3D
- Return type:
volmdlr.Vector3D
- deterministic_unit_normal_vector()#
Returns a deterministic unit normal 3-dimensional vector.
- Returns:
A normal Vector3D
- Return type:
volmdlr.Vector3D
- classmethod dict_to_object(dict_, *args, **kwargs)#
Deserializes a dictionary to a 3-dimensional vector.
- Parameters:
dict (dict) – The dictionary of a serialized Vector3D
global_dict (dict, optional) – The global dictionary. Default value is None
pointers_memo (dict, optional) – A dictionary from path to python object of already serialized values. Default value is None
path (str, optional) – The path in the global object. In most cases, append ‘/attribute_name’ to given path for your attributes. Default value is ‘#’
- Returns:
- Return type:
volmdlr.Vector3D
See also
How serialization and deserialization works in dessia_common
- dot(other_vector)#
Computes the dot product between two 3-dimensional vectors.
- Parameters:
other_vector (
volmdlr.Vector3D) – A Vector3D-like object- Returns:
Value of the dot product
- Return type:
float
- frame_mapping(frame: Frame3D, side: str)#
# TODO: Needs correction. Add an example ? Transforms a 3-dimensional vector from the current reference frame to a new one. Choose side equals to ‘old’ if the current reference frame is the old one ; choose side equals to ‘new’ if the input reference frame is the new one. This way, choosing ‘old’ will return the frame mapped vector of the input reference frame.
- Parameters:
frame (
volmdlr.Frame3D) – The input reference frameside (str) – Choose between ‘old’ and ‘new’
- Returns:
A frame mapped Vector3D-like object
- Return type:
volmdlr.Vector3D
- classmethod from_step(arguments, object_dict, **kwargs)#
Converts a step primitive from a 3-dimensional vector to a Vector3D.
- 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 Vector3D object
- Return type:
volmdlr.Vector3D
- get_topods()#
- is_close(other_vector, tol=1e-06)#
Checks if two vectors are close to each other considering the Euclidean distance. The tolerance can be modified. The two vectors should be of same dimension.
- Parameters:
other_vector (
volmdlr.Vector3D) – A Vector3D-like objecttol (float) – The tolerance under which the euclidean distance is considered equal to 0
- Returns:
True if the two Vector3D-like objects are close enough to each other, False otherwise
- Return type:
bool
- norm() float#
Computes the euclidiean norm of a 3-dimensional vector.
- Returns:
Norm of the Vector3D-like object
- Return type:
float
- plane_projection2d(plane_origin: Vector3D, x: Vector3D, y: Vector3D)#
Projects a Vector3D-like object on a 2D plane.
- Parameters:
plane_origin (
volmdlr.Vector3D) – The 3D origin of the 2D projection planex (
volmdlr.Vector3D) – The 3D X axis of the 2D planey (
volmdlr.Vector3D) – The 3D Y axis of the 2D plane
- Returns:
The projection on the 2D plane
- Return type:
volmdlr.Point2D
- plane_projection3d(plane_origin: Vector3D, x: Vector3D, y: Vector3D)#
Projects a Vector3D-like object on a 3D plane.
- Parameters:
plane_origin (
volmdlr.Vector3D) – The origin of the 3D projection planex (
volmdlr.Vector3D) – The X axis of the 3D planey (
volmdlr.Vector3D) – The Y axis of the 3D plane
- Returns:
The projection on the 3D plane
- Return type:
volmdlr.Vector3D
- plot(ax=None, starting_point=None, color='k')#
Plots the 3-dimensional vector.
- Parameters:
ax (
matplotlib.axes.Axes, optional) – The Axes on which the Vector2D will be drawnstarting_point (
volmdlr.Vector3D, optional) – The location of the origin of the vector. Default value is None, corresponding to (0, 0, 0)color (str, optional) – The color of the drawn vector. Default value is empty string for black
- Returns:
A matplotlib Axes object on which the Vector3D have been plotted
- Return type:
matplotlib.axes.Axes
- point_distance(other_vector: Vector3D) float#
Computes the euclidiean distance between two Vector3D objects.
- Parameters:
other_vector (
volmdlr.Vector3D) – A Vector3D object- Returns:
The euclidiean distance
- Return type:
float
- classmethod random(xmin: float, xmax: float, ymin: float, ymax: float, zmin: float, zmax: float, name: str = '')#
Returns a random 2-dimensional point.
- Parameters:
xmin (float) – The minimal abscissa
xmax (float) – The maximal abscissa
ymin (float) – The minimal ordinate
ymax (float) – The maximal ordinate
zmin (float) – The minimal applicate
zmax (float.) – The maximal applicate
name – object’s name.
- Returns:
A random Vector3D
- Return type:
volmdlr.Vector3D
- random_unit_normal_vector()#
Returns a random normal 3-dimensional vector.
- Returns:
A normal Vector3D
- Return type:
volmdlr.Vector3D
- rotation(center: Point3D, axis: Vector3D, angle: float)#
Rotates of angle around axis the 2-dimensional vector and returns a new rotated vector. Using Rodrigues Formula:
- Parameters:
center (
volmdlr.Point3D) – The center of rotationaxis (
volmdlr.Vector3D) – The axis of rotationangle (float) – The angle of the rotation in radian
- Returns:
A rotated Vector3D-like object
- Return type:
volmdlr.Vector3D
- to_2d(plane_origin: Point3D, x: Vector3D, y: Vector3D)#
# TODO: difference with plane_projection2d needs details Transforms a Vector3D-like object to a Point2D.
- Parameters:
plane_origin (
volmdlr.Vector3D) – The 3D origin of the 2D projection planex (
volmdlr.Vector3D) – The 3D X axis of the 2D planey (
volmdlr.Vector3D) – The 3D Y axis of the 2D plane
- Returns:
The transformed Point2D
- Return type:
volmdlr.Point2D
- to_dict(*args, **kwargs)#
Serializes a 3-dimensional vector into a dictionary.
- Returns:
A serialized version of the Vector3D
- Return type:
dict
See also
How serialization and deserialization works in dessia_common
- to_point()#
Converts a Vector3D object to a Point3D object.
- Returns:
A Point3D
- Return type:
volmdlr.Point3D
- to_step(current_id, vector=False, vertex=False)#
Write a step primitive from a 3-dimensional vector.
- Parameters:
current_id (int) – The id of the last written primitive
vector (bool, optional) – If ‘True’ creates a step VECTOR primitive. Otherwise, only a DIRECTION primitive will be created. Default value set to ‘False’
vertex (bool, optional) – If ‘True’ calls the to_step method of Point3D. Default value set to ‘False’
- Returns:
A tuple containing the string representing the step primitive and the new current id
- Return type:
tuple
- translation(offset: Vector3D, memo=None)#
Translates the vector and returns a new translated vector.
- Parameters:
offset (
volmdlr.Vector3D) – A Vector3D-like object used for offsettingmemo (dict) – (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 translated Vector3D-like object
- Return type:
volmdlr.Vector3D
- unit_vector()#
Calculates the unit vector.
- x#
- x_rotation(angle: float)#
Rotation of angle around X axis and returns a new vector as a result.
- Parameters:
angle (float) – Value of the angle
- Returns:
A 3-dimensional point
- Return type:
volmdlr.Point3D
- y#
- y_rotation(angle: float)#
Rotation of angle around Y axis and returns a new vector as result.
- Parameters:
angle (float) – Value of the angle
- Returns:
A 3-dimensional point
- Return type:
volmdlr.Point3D
- z#
- z_rotation(angle: float)#
rrotation of angle around Z axis and returns a new vector as result.
- Parameters:
angle (float) – Value of the angle
- Returns:
A 3-dimensional point
- Return type:
volmdlr.Point3D
- volmdlr.core_compiled.bbox_is_intersecting(bbox1, bbox2, tol)#
Verifies if the two bounding boxes are intersecting, or touching.
- volmdlr.core_compiled.get_minimum_distance_points_lines(linesegment1_start, linesegment1_end, linesegment2_start, linesegment2_end)#
Returns the points minimum distance points between two lines.
- volmdlr.core_compiled.linesegment2d_point_distance(start, end, point)#
- volmdlr.core_compiled.linesegment3d_point_distance(start, end, point)#
- volmdlr.core_compiled.points_in_polygon(polygon, points, include_edge_points=False, tol=1e-06)#
- volmdlr.core_compiled.polygon_point_belongs(polygon, point, include_edge_points=False, tol=1e-06)#
Core#
Base classes.
- class volmdlr.core.Assembly(components: list[Primitive3D], positions: list[Frame3D], frame: Frame3D = Frame3D(origin=Point3D(0.0, 0.0, 0.0), u=Vector3D(1.0, 0.0, 0.0), v=Vector3D(0.0, 1.0, 0.0), w=Vector3D(0.0, 0.0, 1.0)), name: str = '')#
Bases:
objectAssembly is deprecated, please, use volmdlr.composite_shapes.Assembly instead.
- class volmdlr.core.BoundingBox(xmin: float, xmax: float, ymin: float, ymax: float, zmin: float, zmax: float, name: str = '')#
Bases:
DessiaObjectAn axis aligned boundary box.
- property center#
Compute the center of the bounding box.
- property diagonal_length#
Compute the diagonal length of the bounding box.
- distance_to_bbox(bbox2: BoundingBox) float#
Calculate the distance between the bounding box and another bounding box.
If the bounding boxes intersect, the distance is 0. Otherwise, the distance is the minimum Euclidean distance between their closest faces.
- Parameters:
bbox2 (BoundingBox) – Another bounding box to compare with.
- Returns:
The distance between the bounding boxes.
- Return type:
float
- distance_to_point(point: Point3D) float#
Calculate the minimum Euclidean distance between the bounding box and a point.
- Parameters:
point (volmdlr.Point3D) – The point to compare with.
- Returns:
The minimum distance between the point and the bounding box.
- Return type:
float
- classmethod from_bounding_boxes(bounding_boxes: list[BoundingBox], name: str = '') BoundingBox#
Create a bounding box that contains multiple bounding boxes.
- Parameters:
bounding_boxes (list[BoundingBox]) – A list of bounding boxes that need to be contained.
name (str) – A name for the bounding box, optional.
- Returns:
A new bounding box that contains all the input bounding boxes.
- Return type:
- classmethod from_points(points: list[Point3D] | ndarray[Any, dtype[_ScalarType_co]], name: str = '') BoundingBox#
Initialize a bounding box from a list of points.
- Parameters:
points (list[volmdlr.Point3D].) – The list of points to create the bounding box from.
name – object’s name.
- Returns:
The bounding box initialized from the list of points.
- Return type:
- get_points_inside_bbox(points_x, points_y, points_z)#
Getspoints inside the BoudingBox.
- Parameters:
points_x – Number of points in x direction.
points_y – Number of points in y direction.
points_z – Number of points in z direction.
- Returns:
list of points inside bounding box.
- intersection_volume(bbox2: BoundingBox) float#
Calculate the volume of the intersection of two bounding boxes.
- Parameters:
bbox2 (BoundingBox) – The second bounding box to intersect with the first one.
- Returns:
The volume of the intersection of two bounding boxes.
- Return type:
float
- is_close(other_bounding_box: BoundingBox, tol: float = 1e-06) bool#
Check if two bounding boxes are close to each other considering the Euclidean distance of their corners points.
The tolerance can be modified.
- Parameters:
other_bounding_box (BoundingBox) – the other bounding box.
tol (float) – The tolerance under which the Euclidean distance is considered equal to 0.
- Returns:
True if the bounding boxes are equal at the given tolerance, False otherwise.
- Return type:
bool
- is_inside_bbox(bbox2: BoundingBox) bool#
Check if a bounding box is contained inside another bounding box.
- Parameters:
bbox2 (BoundingBox) – The bounding box to check against.
- Returns:
True if the bounding box is contained inside bbox2, False otherwise.
- Return type:
bool
- is_intersecting(bbox2, tol: float = 1e-06)#
Check if two bounding boxes are intersecting or touching.
- Parameters:
self – BoundingBox object representing the first bounding box.
bbox2 – BoundingBox object representing the second bounding box.
tol – tolerance to be considered.
- Returns:
True if the bounding boxes are intersecting or touching, False otherwise.
- is_intersecting_triangle(triangle: Triangle3D) bool#
Check if the bounding box and a triangle are intersecting or touching.
- Parameters:
triangle (Triangle3D) – the triangle to check if there is an intersection with.
- Returns:
True if the bounding box and the triangle are intersecting or touching, False otherwise.
- Return type:
bool
- is_linesegment_intersecting(linesegment)#
Check if linesegment is intersecting bounding box.
- octree()#
Create a simple octree structure for a bounding box.
- plot(ax=None, color='gray')#
Plot the bounding box on 3D axes.
- Parameters:
ax (Matplotlib.axes._subplots.Axes3DSubplot, optional) – The 3D axes to plot on. If not provided, a new figure will be created.
color (str, optional) – The color of the lines used to plot the bounding box.
- Returns:
The 3D axes with the plotted bounding box.
- Return type:
Matplotlib.axes._subplots.Axes3DSubplot
- point_inside(point: Point3D, tol=1e-06) bool#
Determine if a point belongs to the bounding box.
- Parameters:
point (volmdlr.Point3D) – The point to check for inclusion.
tol – tolerance.
- Returns:
True if the point belongs to the bounding box, False otherwise.
- Return type:
bool
- property points: list[Point3D]#
Returns the eight corner points of the bounding box.
- Returns:
A list of eight 3D points representing the corners of the bounding box.
- Return type:
list of volmdlr.Point3D
- scale(factor: float) BoundingBox#
Scales the bounding box by a given factor and returns a new BoundingBox.
- Parameters:
factor (float) – The scaling factor.
- Returns:
A new scaled BoundingBox.
- Return type:
- property size#
Gets the Size of the Bounding Box.
- to_dict(*args, **kwargs) dict#
Convert the bounding box to a dictionary representation.
- Parameters:
use_pointers (bool, optional) – DESCRIPTION, defaults to True
memo (TYPE, optional) – DESCRIPTION, defaults to None
path (str, optional) – A string representing the current position of the object in the serialized data structure.
- Returns:
The dictionary representation of the bounding box.
- Return type:
dict
- to_frame() Frame3D#
Convert the bounding box to a 3D frame.
- Returns:
A 3D frame with origin at the center and axes aligned with the x, y, and z dimensions of the bounding box.
- Return type:
volmdlr.Frame3D
- volume() float#
Calculate the volume of a bounding box.
- Returns:
The volume of the bounding box.
- Return type:
float
- property x_length#
Return the length of the bounding box in x direction.
- property y_length#
Return the length of the bounding box in y direction.
- property z_length#
Return the length of the bounding box in z direction.
- class volmdlr.core.BoundingRectangle(xmin: float, xmax: float, ymin: float, ymax: float, name: str = '')#
Bases:
DessiaObjectBounding rectangle.
- Parameters:
xmin (float) – minimal x coordinate
xmax (float) – maximal x coordinate
ymin (float) – minimal y coordinate
ymax (float) – maximal y coordinate
- area()#
Calculate the area of the bounding rectangle.
- b_rectangle_intersection(b_rectangle2)#
Return True if there is an intersection with another specified bounding rectangle or False otherwise.
- Parameters:
b_rectangle2 (
BoundingRectangle) – bounding rectangle to verify intersection
- bounding_points()#
Return the bounds of the BoundingRectangle.
- bounds()#
Return the bounds of the BoundingRectangle.
- center()#
Calculate the bounding rectangle center.
- property diagonal_length#
Compute the diagonal length of the bounding rectangle.
- distance_to_b_rectangle(b_rectangle2)#
Calculate the minimal distance between two bounding rectangles.
- Parameters:
b_rectangle2 (
BoundingRectangle) – A bounding rectangle
- distance_to_point(point: Point2D)#
Calculate the minimal distance between the bounding rectangle and a specified point.
- Parameters:
point (
volmdlr.Point2D) – A 2D point
- classmethod from_bounding_rectangles(bounding_rectangles: list[BoundingRectangle], name: str = '') BoundingRectangle#
Create a bounding rectangle that contains multiple bounding rectangles.
- Parameters:
bounding_rectangles – A list of bounding rectangles that need to be contained.
name – A name for the bounding rectangles, optional.
- Returns:
A new bounding rectanglesthat contains all the input bounding rectangles.
- classmethod from_points(points: list[Point2D], name: str = '') BoundingRectangle#
Initialize a bounding rectangle from a list of points.
- Parameters:
points (list[volmdlr.Point2D].) – The list of points to create the bounding rectangle from.
name – object’s name.
- Returns:
The bounding rectangle initialized from the list of points.
- Return type:
- intersection_area(b_rectangle2)#
Calculate the intersection area between two bounding rectangle.
- Parameters:
b_rectangle2 (
BoundingRectangle) – A bounding rectangle
- is_inside_b_rectangle(b_rectangle2, tol: float = 1e-06)#
Return True if the bounding rectangle is totally inside specified bounding rectangle and False otherwise.
- Parameters:
b_rectangle2 (
BoundingRectangle) – A bounding rectangletol (float) – A tolerance for considering inside
- is_intersecting(b_rectangle2)#
Return True if there is an intersection with another specified bounding rectangle or False otherwise.
- Parameters:
b_rectangle2 (
BoundingRectangle) – bounding rectangle to verify intersection
- plot(ax=None, color='k', linestyle='dotted')#
Plot of the bounding rectangle and its vertex.
- plot_data(edge_style: EdgeStyle | None = None, surface_style: SurfaceStyle | None = None)#
Return the plot_data representation of the bounding rectangle.
- point_inside(point: Point2D)#
Return True if a specified point is inside the bounding rectangle and False otherwise.
- Parameters:
point (
volmdlr.Point2D) – A 2 dimensional point
- property x_length#
Return the length of the bounding rectangle in x direction.
- property y_length#
Return the length of the bounding rectangle in y direction.
- class volmdlr.core.CompositePrimitive3D(primitives: list[Primitive3D], color: tuple[float, float, float] | None = None, alpha: float = 1, reference_path: str = '#', name: str = '')#
Bases:
Primitive3DA collection of simple primitives3D.
- plot(ax=None, edge_style: EdgeStyle | None = None)#
Plot the 3D primitives onto the given Axes3D object.
- Parameters:
ax (Matplotlib plot) – optional The Axes3D object onto which to plot the primitives. If None, a new figure and Axes3D object will be created.
- edge_styleoptional
The EdgeStyle to use when plotting the primitives.
- Returns:
The Axes3D object onto which the primitives were plotted.
- Return type:
Matplotlib plot
- to_dict(*args, **kwargs)#
Avoids storing points in memo that makes serialization slow.
- class volmdlr.core.EdgeStyle(color: str = 'k', alpha: float = 1, edge_ends: bool = False, edge_direction: bool = False, width: float | None = None, arrow: bool = False, plot_points: bool = False, dashed: bool = True, linestyle: str = '-', linewidth: float = 1, equal_aspect: bool = False)#
Bases:
objectData class for styling edges Matplotlib plots.
- alpha: float = 1#
- arrow: bool = False#
- color: str = 'k'#
- dashed: bool = True#
- edge_direction: bool = False#
- edge_ends: bool = False#
- equal_aspect: bool = False#
- linestyle: str = '-'#
- linewidth: float = 1#
- plot_points: bool = False#
- width: float = None#
- class volmdlr.core.OrientedBoundingBox(frame: Frame3D, half_sizes: list[float], name: str = '')#
Bases:
DessiaObjectDefine an Oriented bounding box.
- center() Point3D#
Get the center point of the OBB in world coordinates.
- Returns:
The center point of the oriented bounding box.
- Return type:
volmdlr.Point3D
- get_axes()#
Return the local axes of the OBB in world coordinates.
- Returns:
A list of 3 axes, each represented as an array of length 3.
- is_intersecting(other)#
Check if this OBB intersects with another OBB. It uses the Separating Axis Theorem.
- Parameters:
other – The other OrientedBoundingBox to check for intersection.
- Returns:
True if the OBBs intersect, False otherwise.
- is_linesegment_intersecting(linesegment)#
Check if a line segment intersects with the OBB.
- Parameters:
linesegment – The line segment to verify intersection with OBB.
- Returns:
True if the line segment intersects the OBB, False otherwise.
- plot(ax=None, color='gray')#
Plot the orientend bounding box on 3D axes.
- Parameters:
ax (Matplotlib.axes._subplots.Axes3DSubplot, optional) – The 3D axes to plot on. If not provided, a new figure will be created.
color (str, optional) – The color of the lines used to plot the bounding box.
- Returns:
The 3D axes with the plotted bounding box.
- Return type:
Matplotlib.axes._subplots.Axes3DSubplot
- point_inside(point)#
Check if a point is inside the OBB.
- Parameters:
point – point to verified if inside OBB.
- Returns:
True if point is inside. False otherwise.
- property points#
Returns the 8 corners of the OBB in world coordinates.
- project_onto_axis(axis)#
Projects the OBB onto the given axis and returns the minimum and maximum projection values.
- Parameters:
axis – The axis onto which to project the OBB as a list or array of length 3.
- Returns:
A tuple containing the minimum and maximum projection values as floats.
- volume() float#
Calculate and return the volume of the OBB.
- Returns:
The volume of the oriented bounding box.
- Return type:
float
- class volmdlr.core.Primitive3D(color: tuple[float, float, float] | None = None, alpha: float = 1.0, reference_path: str = '#', name: str = '')#
Bases:
DessiaObject,Displayable3DDefines a Primitive3D.
- babylon_data(*args, **kwargs)#
Return the babylonjs data for display.
- babylon_meshes(*args, **kwargs)#
Return the babylonjs mesh.
- babylon_param()#
Return babylonjs parameters.
- Returns:
babylonjs parameters (alpha, name, color)
- Return type:
dict
- cad_view#
Implementation of a tag for displays.
- property display_color: tuple[float, float, float]#
Get the color for display purposes.
Returns the custom color if set, otherwise returns DEFAULT_COLOR.
- Returns:
RGB color tuple with values in range [0.0, 1.0]
- property has_custom_color: bool#
Check if this object has a custom color set.
- Returns:
True if color is not None, False otherwise.
- property has_transparency: bool#
Check if this object has transparency (alpha < 1.0).
- Returns:
True if alpha differs from DEFAULT_ALPHA, False otherwise.
- triangulation(*args, **kwargs)#
Get object triangulation.
- volmdlr_primitives()#
Return a list of volmdlr primitives to build up volume model.
- class volmdlr.core.ShapeMetadata(name: str = '', color: tuple = (0.8, 0.8, 0.8), alpha: float = 1.0, reference_path: str = '#')#
Bases:
DessiaObjectData class for sorting data related to a shape.
- Parameters:
name – The name of the shape.
color – The color to be set.
alpha – Transparency of the shape.
reference_path
- class volmdlr.core.VolumeModel(primitives: list[Primitive3D], name: str = '')#
Bases:
objectVolumeModel is deprecated, please, use volmdlr.model.VolumeModel instead.
- volmdlr.core.delete_double_point(list_point)#
Delete duplicate points from a list of points.
- Parameters:
list_point (Union[list[
volmdlr.Point2D], list[volmdlr.Point3D]]) – The initial list of points- Returns:
The final list of points containing no duplicates
- Return type:
Union[list[
volmdlr.Point2D], list[volmdlr.Point3D]]
- volmdlr.core.edge_in_list(edge, list_edges, tol: float = 1e-06)#
VeriFY if an edge is inside a list of edges, considering a certain tolerance.
- Parameters:
edge – Edge to be verified inside list.
list_edges – List of edges to be used.
tol – Tolerance to consider if two points are the same.
- Returns:
True if there is an edge inside the list close to the edge to given tolerance.
- volmdlr.core.element_in_list(element, list_elements, tol: float = 1e-06)#
VerifY if a volmdlr element is inside a list of elements, considering a certain tolerance.
- Parameters:
element – Element to be verified inside list.
list_elements – List of elements to be used.
tol – Tolerance to consider if two points are the same.
- Returns:
True if there is an element inside the list close to the element to given tolerance.
- volmdlr.core.get_babylon_data(shape, merge_meshes=True, show_curves: bool = False, ocaf=None)#
Get babylonjs data.
- Returns:
Dictionary with babylon data.
- volmdlr.core.get_edge_index_in_list(edge, list_edges, tol: float = 1e-06)#
Get the index a edge inside a list of edges, considering a certain tolerance.
- Parameters:
edge – Edge to be verified inside list.
list_edges – List of edges to be used.
tol – Tolerance to consider if two edges are the same.
- Returns:
The edge index.
- volmdlr.core.get_element_index_in_list(element, list_elements, tol: float = 1e-06)#
Get the index an element inside a list of elements, considering a certain tolerance.
- Parameters:
element – Element to be verified inside list.
list_elements – List of elements to be used.
tol – Tolerance to consider if two elements are the same.
- Returns:
The element index.
- volmdlr.core.get_point_index_in_list(point, list_points, tol: float = 1e-06)#
Get the index a point inside a list of points, considering a certain tolerance.
- Parameters:
point – Point to be verified inside list.
list_points – List of points to be used.
tol – Tolerance to consider if two points are the same.
- Returns:
The point index.
- volmdlr.core.helper_babylon_data(babylon_data, display_points)#
Helper function to babylon_data.
- volmdlr.core.map_primitive_with_initial_and_final_frames(primitive, initial_frame, final_frame)#
Frame maps a primitive in an assembly to its good position.
- Parameters:
primitive (Primitive3D) – primitive to map
initial_frame (volmdlr.Frame3D) – Initial frame
final_frame (volmdlr.Frame3D) – The frame resulted after applying a transformation to the initial frame
- Returns:
A new positioned primitive
- Return type: