fibomat.shapes.arc module

Provides the Arc class.

class fibomat.shapes.arc.Arc(radius: float, start_angle: float, end_angle: float, sweep_dir: bool, center: Optional[Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]]] = None, description: Optional[str] = None)[source]

Bases: fibomat.linalg.transformables.transformable_base.TransformableBase[fibomat.linalg.vectors.vector.Vector, float, fibomat.linalg.boundingboxes.boundingbox.BoundingBox], abc.ABC

Circular arc shape.

Some formulas take from here.

TODO: from_points((-1, 0), (0, 1), (-1, 0)) does not work. Should it!?

__init__(radius: float, start_angle: float, end_angle: float, sweep_dir: bool, center: Optional[Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]]] = None, description: Optional[str] = None)[source]
Args:

radius (float): radius start_angle (float): starting angle (measured from pos. x-axis) end_angle (float): end angle (measured from pos. x-axis) sweep_dir (bool): if True, arc direction is in mathematical positive direction and in math. negative

direction if False

center (VectorLike, optional): center of completed arc, default to (0, 0) description (str, optional): description

Warning

center is the center of the circle (aka. the completed arc), not centroid!

classmethod from_bulge(start: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], end: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], bulge: float)[source]

Construct a curve from start and end points and bulge value. See here and there for details concerning the bulge value.

Args:

start (VectorLike): start point end (VectorLike): end point bulge (float): bulge value

Returns:

Arc

classmethod from_points(p1: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], p2: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], p3: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]])[source]

Creates an arc connecting p1 with p3 via p2.

Args:

p1 (VectorLike): start point p2 (VectorLike): intermediate point p3 (VectorLike): end point

Returns:

Arc

classmethod from_points_center(start: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], end: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], center: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], sweep_dir: bool)[source]

Create Arc from start, end, center and sweep_dir

Args:

start (VectorLike): start point end (VectorLike): end point center (VectorLike): center sweep_dir (bool): sweep_dir

Returns:

Arc

classmethod from_points_center_tangent(start: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], end: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], center: Union[fibomat.linalg.vectors.vector.Vector, Iterable[float]], *, unit_tangent_start=None, unit_tangent_end=None)[source]

Create Arc from start, end, center and tangent at start or end. The sweep_dir is calculated automatically.

Args:

start (VectorLike): start point end (VectorLike): end point center (VectorLike): center unit_tangent_start (VectorLike, optional): unit tangent at start unit_tangent_end (VectorLike, optional): unit tangent at end

Returns:

Arc

Raises:

ValueError: Raised of none or both of unit_tangent_start and unit_tangent_end are defined.

to_arc_spline() fibomat.shapes.arc_spline.ArcSpline[source]

Transform shape to ArcSpline.

Returns:

ArcSpline

property start: fibomat.linalg.vectors.vector.Vector

Start point of arc

Access:

get

Returns:

Vector

property end: fibomat.linalg.vectors.vector.Vector

End point of arc

Access:

get

Returns:

Vector

property start_angle: float

Start angle of arc (measured from pos. x. axis).

Access:

get

Returns:

float

property end_angle

End angle of arc (measured from pos. x. axis).

Access:

get

Returns:

float

property sweep_dir: bool

If True, arc direction is in mathematical positive direction and in math. negative direction if False

Access:

get

Returns:

bool

property radius: float

Arc radius

Access:

get

Returns:

float

property theta: float

Absolute value of enclosed angle

Access:

get

Returns:

float

property bulge: float

Bulge value = tan(theta/4). bulge > 0 arc goes in math. positve direction and for bulge < 0 in math. neg. direction

Access:

get

Returns:

float

property center: fibomat.linalg.vectors.vector.Vector

Center of enclosing circle.

Access:

get

Returns:

Vector

property midpoint: fibomat.linalg.vectors.vector.Vector

Midpoint of arc.

Access:

get

Returns:

Vector

property unit_tangent_start: fibomat.linalg.vectors.vector.Vector

Unit tangent at start.

Access:

get

Returns:

Vector

property unit_tangent_end: fibomat.linalg.vectors.vector.Vector

Unit tangent at end.

Access:

get

Returns:

Vector

unit_tangent_at(angle)[source]

Unit tangent at specific angle.

Args:

angle (float): 0 < angle < self.theta

Returns:

Vector

property length

Length of arc.

Access:

get

Returns:

float

split() List[fibomat.shapes.arc.Arc][source]

Return two arcs if theta > np.pi (hence the abs(bulge) value of new arcs will be smaller than 1).

Returns:

List[Arc]: if theta > np.pi list contains two elements and one otherwise.

split_at(angle: float) List[fibomat.shapes.arc.Arc][source]

Split the arc in two halves ([0, angle], [angle, theta]).

Args:

angle (float): split angle.

Returns:

List[Arc]

Raises:

ValueError: Raised if angle < 0 or angle > self.theta

reversed() fibomat.shapes.arc.Arc[source]

Return a reversed version of the arc

Returns:

Arc

property bounding_box: fibomat.linalg.boundingboxes.boundingbox.BoundingBox

BoundingBox: bounding box of transformable

Access:

get

property is_closed: bool

bool: True if shape is closes. This property should not be defined for 0-dim shapes

Access:

get

clone() fibomat.describable.T

Create a deepcopy of the object.

Returns:

Describable

property description: Optional[str]

Description str.

Access:

get

Returns:

Optional[str]

mirrored(mirror_plane: fibomat.linalg.transformables.transformable_base.VectorT) fibomat.linalg.transformables.transformable_base.SelfT

Return a mirrored object mirrored about mirror_plane.

Args:

mirror_plane (VectorLike): mirror plane to be used.

Returns:

TransformableBase

property pivot: fibomat.linalg.transformables.transformable_base.VectorT

Origin of the (geometric) object. If origin is set to None, Transformable.center will 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: Optional[Union[fibomat.linalg.transformables.transformable_base.VectorT, str]] = None) fibomat.linalg.transformables.transformable_base.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.center of the object will be used. The same applies for the case that origin == ‘origin’ with the Transformable.origin property. Default to None.

Returns:

TransformableBase

scaled(fac: float, origin: Optional[Union[fibomat.linalg.transformables.transformable_base.VectorT, str]] = None) fibomat.linalg.transformables.transformable_base.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.center of the object will be used. The same applies for the case that origin == ‘origin’ with the Transformable.origin property. Default to None.

Returns:

TransformableBase

transformed(transformations: fibomat.linalg.transformables.transformation_builder._TransformationBuilder[fibomat.linalg.transformables.transformable_base.VectorT]) fibomat.linalg.transformables.transformable_base.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: fibomat.linalg.transformables.transformable_base.VectorT) fibomat.linalg.transformables.transformable_base.SelfT

Return a translated copy of the object by trans_vec.

Args:

trans_vec (VectorLike): translation vector

Returns:

TransformableBase

translated_to(pos: fibomat.linalg.transformables.transformable_base.VectorT) fibomat.linalg.transformables.transformable_base.SelfT

Return a translated copy of the object so that self.pivot == pos

Args:

pos: new position of object

Returns:

TransformableBase

with_changed_description(new_descr: str) fibomat.describable.T

Clones the object and set the description to new_descr.

Args:

new_descr: new description

Returns:

Describable