fibomat.shapes.arc_spline module#
Provides the ArcSpline and ArcSplineCompatible classes.
- class fibomat.shapes.arc_spline.ArcSplineCompatible(*args, **kwargs)[source]#
Bases:
ProtocolAbstract class can be used to mark ArcSpline compatible shapes.
- __init__(*args, **kwargs)#
- class fibomat.shapes.arc_spline.ArcSpline(arc_spline: ArcSpline | ndarray, is_closed: bool | None = None, description: str | None = None)[source]#
Bases:
Shape,ArcSplineCompatibleClass represents a spline containing circular arcs and straight line segments. The spline is C^0, hence, continuous but not differentiable.
- __init__(arc_spline: ArcSpline | ndarray, is_closed: bool | None = None, description: str | None = None)[source]#
- Args:
- arc_spline (_libfibomat.ArcSpline, np.ndarray):
np.ndarray must have shape = (-1, 3) where each point is given by (x, y, bulge).
- is_closed (bool, optional):
if True, the last and first point are connected (potentially with an arc, if the bulge value of the last vertex is nonzero). if False, the bulge value of the last point is ignored. The argumetn must be given if arc_spline is np.ndarray and is ignored if arc_spline is _libfibomat.ArcSpline.
description (str, optional): description
- Raises:
ValueError: Raised if arc_spline is np.ndarray but is_closed not given.
- classmethod from_segments(segments: Iterable[ArcSplineCompatible], description: str | None = None)[source]#
Build an ArcSpline from connected segments.
- Args:
- segments (Iterable[ArcSplineCompatible]):
segments. the start and end point of to consecutive segments must be equal. If this also holds for the last and first segment, the curve ist closed.
description (str, optional): description.
- Returns:
ArcSpline
- Raises:
RuntimeError: Raised if segments are not connected.
- classmethod from_shape(segment: ArcSplineCompatible)[source]#
Converts a single segment to an ArcSpline.
- Args:
segment (ArcSplineCompatible): segment.
- Returns:
ArcSpline
- property is_closed: bool#
bool: True if shape is closes. This property should not be defined for 0-dim shapes
- Access:
get
- clone_with_new_description(description: str | None = None)[source]#
Similar to
ArcSpline.clone()but set the description the passed description.- Args:
description (str, optional): description.
- Returns:
ArcSpline
- property bounding_box: BoundingBox#
BoundingBox: bounding box of transformable- Access:
get
- property segments: Sequence[ArcSplineCompatible]#
Return a list of Line and Arc elements representing the curve.
Note
This method is not bijective with regard to the added shapes. E.g. if the curve was constructed from a Circle, this method will not return a Circle element but two Arcs.
- Access:
get
- Returns:
List[shape.Shape]
- property arc_spline_impl: ArcSpline#
- property orientation: bool#
Orientation of curve. True if curve is counterclockwise.
Note
This property is only defined for closed curves.
- Access:
get
- Returns:
bool
- unit_tangents(i_vertex: int) Tuple[Vector | None, Vector | None][source]#
Unit tangents at vertex i_vertex.
- Args:
i_vertex (int): vertex index
- Returns:
- Tuple[Optional[Vector], Optional[Vector]]:
left tangent, right tangent. If any of the two tangents does not exist, the tuple entry will be None.
- Raises:
ValueError: Raised if i_vertex > #segmens.
- kinks() List[int][source]#
Return kinks (non differentiable points) of the spline.
- Returns:
List[int]: vertex indices of kinks.
- segments_at_vertex(i_vertex: int) Tuple[Shape | None, Shape | None][source]#
Return the segments around the vertex with index i_vertex.
- Args:
i_vertex: vertex index
- Returns:
- Tuple[Optional[Shape], Optional[Shape]]:
left and right segments. If any of the segments is not defined, the tuple entry will be None.
- Raises:
ValueError: Raised if i_vertex > #segmens.
- mirrored(mirror_plane: VectorT) SelfT#
Return a mirrored object mirrored about mirror_plane.
- Args:
mirror_plane (VectorLike): mirror plane to be used.
- Returns:
TransformableBase
- property pivot: VectorT#
Origin of the (geometric) object. If origin is set to None,
Transformable.centerwill be returned.Pivot must be set to a callable function without parameters.
transformable_obj = ... transformable_obj.pivot = lambda: return Vector(1, 2) print(transformable_obj.pivot) # will print Vector(1, 2)
- Access:
get/set
- Returns:
Vector
- rotated(theta: float, origin: VectorT | str | None = None) SelfT#
Return a rotated copy around origin with angle theta in math. positive direction (counterclockwise).
- Args:
theta (float): rotation angle in rad origin (Optional[Union[linalg.VectorLike, str]], optional):
origin of rotation. If not set, (0,0) is used as origin. If origin == ‘center’, the
Transformable.centerof the object will be used. The same applies for the case that origin == ‘origin’ with theTransformable.originproperty. Default to None.- Returns:
TransformableBase
- scaled(fac: float, origin: VectorT | str | None = None) SelfT#
Return a scale object homogeneously about origin with factor s.
- Args:
fac (float): rotation angle in rad origin (Optional[Union[linalg.VectorLike, str]], optional):
origin of rotation. If not set, (0,0) is used as origin. If origin == ‘center’, the
Transformable.centerof the object will be used. The same applies for the case that origin == ‘origin’ with theTransformable.originproperty. Default to None.- Returns:
TransformableBase
- transformed(transformations: _TransformationBuilder[VectorT]) SelfT#
- Return a transformed object. the transformation can be build by the following functions:
translate()rotate()scale()mirror()
E.g.
transformable_obj.transform(translate([1, 2]) | rotate(np.pi/3) | mirror([3,4])
- Args:
transformations (_TransformationBuilder): transformation
- Returns:
TransformableBase
- translated(trans_vec: VectorT) SelfT#
Return a translated copy of the object by trans_vec.
- Args:
trans_vec (VectorLike): translation vector
- Returns:
TransformableBase
- translated_to(pos: VectorT) SelfT#
Return a translated copy of the object so that self.pivot == pos
- Args:
pos: new position of object
- Returns:
TransformableBase