Circle

⚙️ Spec sheet →  —  visual schematic and metrics measured from a real rendered STL.

Circles, ellipses, arcs, keyholes and rings.

pybosl2.shapes2d.circle.circle(radius=None, diameter=None, points=None, corner=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]

Return a circle, built with the builtin circle(), by radius/diameter, or fit to points.

If corner is given three 2-D points, the circle is centered to be tangent to both segments of that path, on the inside corner. If points is given three 2-D points, the circle is centered and sized to pass through all three points. Anchor/spin are ignored for the corner/points forms, matching BOSL2.

Parameters:
radius : float | None

radius of the circle

diameter : float | None

diameter of the circle

points : Sequence[Sequence[float]] | None

three 2-D points the circle should pass through

corner : Sequence[Sequence[float]] | None

three 2-D points defining a path the circle should be tangent to

anchor : Anchor | Sequence[float]

anchor point (default CENTER)

spin : float

Z-axis rotation in degrees after anchor (default 0)

fn : int | None

arc smoothness overrides

fa : float | None

arc smoothness overrides

fs : float | None

arc smoothness overrides

Return type:

Bosl2Shape2D

Examples

from pybosl2 import shapes2d as s2

s2.circle(radius=15).linear_extrude(height=5).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.shapes2d.circle.arc(count=None, radius=None, angle=None, diameter=None, center=None, points=None, corner=None, width=None, thickness=None, start=None, wedge=False, long=False, clockwise=False, counterclockwise=False, endpoint=True, fn=None, fa=None, fs=None)[source]

Return a 2-D arc, returned as a Path2D of points (BOSL2’s arc()).

All of BOSL2’s 2-D arc specifications are supported (3-D arcs, which project onto a plane, are not):

  • arc(radius=, angle=, [start=], [center=]) – radius about center, sweeping angle degrees from start (or angle=[start, end] for an explicit range).

  • arc(width=, thickness=) – a circular segment starting and ending on the X axis.

  • arc(center=, points=[P0, P1]) – around center from P0 toward the direction of P1; the short way by default, or the long/clockwise/counterclockwise way.

  • arc(points=[P0, P1, P2]) – through three points, from P0 via P1 to P2.

  • arc(corner=[P0, P1, P2], radius=) – the fillet arc of radius tangent to both legs of the corner P0-P1-P2.

Set wedge=True to prepend the centre point, giving a closed pie/sector path. When count is omitted the point count follows OpenSCAD’s $fn/$fa/$fs rules, matching BOSL2.

Parameters:
count : int | None

number of points (default: from $fn/$fa/$fs)

radius : float | None

radius of the arc

diameter : float | None

diameter of the arc

angle : float | Sequence[float] | None

degrees to sweep from start, or [start, end]

center : Sequence[float] | None

centre point (default [0, 0])

points : Sequence[Sequence[float]] | None

two points (with center) or three points the arc passes through

corner : Sequence[Sequence[float]] | None

three points; the arc is the radius fillet tangent to both legs

width : float | None

chord width for the width/thickness form

thickness : float | None

height of the circular segment for the width/thickness form

start : float | None

starting angle in degrees (default 0)

wedge : bool

prepend the centre point, producing a closed sector (default False)

long : bool

for the two-point form, take the long way / a given handedness

clockwise : bool

for the two-point form, take the long way / a given handedness

counterclockwise : bool

for the two-point form, take the long way / a given handedness

endpoint : bool

include the final point (default True)

fn : int | None

number of fragments for circle resolution.

fa : float | None

minimum fragment angle for circle resolution.

fs : float | None

minimum fragment size for circle resolution.

Returns:

A Path2D (closed when wedge is set).

Return type:

Path2D

pybosl2.shapes2d.circle.ellipse(radius=None, diameter=None, realign=False, circumscribe=False, uniform=False, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]

Return an ellipse (approximated as a polygon), built directly with polygon().

Note: uniform (equal-length approximating segments) is not implemented; segments are evenly spaced by angle instead.

Parameters:
radius : float | Sequence[float] | None

radius of the circle, or pair of semi-axes of the ellipse

diameter : float | Sequence[float] | None

diameter of the circle, or pair giving the full X/Y axis lengths

realign : bool

shift the first polygon point off the X+ axis (default False)

circumscribe : bool

circumscribe rather than inscribe the ideal ellipse (default False)

uniform : bool

use equal-length approximating segments (not implemented; evenly spaced by angle)

anchor : Anchor | Sequence[float]

anchor point (default CENTER)

spin : float

Z-axis rotation in degrees after anchor (default 0)

fn : int | None

arc smoothness overrides

fa : float | None

arc smoothness overrides

fs : float | None

arc smoothness overrides

Return type:

Bosl2Shape2D

Examples

from pybosl2 import shapes2d as s2

s2.ellipse(diameter=[30, 20]).linear_extrude(height=5).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.shapes2d.circle.keyhole(length=None, radius1=None, radius2=None, shoulder_radius=0, diameter1=None, diameter2=None, _length=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]

Return a keyhole slot – a small circle joined to a larger one by tangent shoulders (BOSL2 keyhole()).

Parameters:
length : float | None

overall length between the two circle centers (default 15)

radius1 : float | None

radius/diameter of the small (bottom) circle (default 5)

diameter1 : float | None

radius/diameter of the small (bottom) circle (default 5)

radius2 : float | None

radius/diameter of the large (top) circle (default 10)

diameter2 : float | None

radius/diameter of the large (top) circle (default 10)

shoulder_radius : float

fillet radius where the shoulders meet the circles (default 0)

anchor : Anchor | Sequence[float]

standard BOSL2 2-D anchor / spin

spin : float

standard BOSL2 2-D anchor / spin

fn : int | None

number of fragments for circle resolution.

fa : float | None

minimum fragment angle for circle resolution.

fs : float | None

minimum fragment size for circle resolution.

_length : float | None

Return type:

Bosl2Shape2D

Examples

from pybosl2 import shapes2d as s2

s2.keyhole(length=25, radius1=4, radius2=9, shoulder_radius=2).linear_extrude(height=4).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.shapes2d.circle.ring(sides=None, ring_width=None, radius=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, angle=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]

Return a 2-D ring (annulus) between two concentric radii (BOSL2 ring(), full-annulus form).

Give either both radii (radius1/radius2 or diameter1/diameter2) or one radius plus ring_width. The arc / 3-point / corner / width+thickness forms of BOSL2 ring() are not ported.

Parameters:
radius1 : float | None

the two radii/diameters

radius2 : float | None

the two radii/diameters

diameter1 : float | None

the two radii/diameters

diameter2 : float | None

the two radii/diameters

radius : float | None

one radius plus the wall width

diameter : float | None

one radius plus the wall width

ring_width : float | None

one radius plus the wall width

sides : int | None

number of sides (overrides the smoothness overrides)

angle : float | None

sweep angle in degrees (only the full-annulus form is ported; angle must be None)

anchor : Anchor | Sequence[float]

standard BOSL2 2-D anchor / spin

spin : float

standard BOSL2 2-D anchor / spin

fn : int | None

number of fragments for circle resolution.

fa : float | None

minimum fragment angle for circle resolution.

fs : float | None

minimum fragment size for circle resolution.

Return type:

Bosl2Shape2D

Examples

from pybosl2 import shapes2d as s2

s2.ring(radius=20, ring_width=4).linear_extrude(height=5).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.shapes2d.circle.glued_circles(radius=None, spread=10, tangent=30, diameter=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]

Two circles joined by a curved waist, like a dumbbell, built directly with polygon().

Parameters:
radius : float | None

radius of the end circles

spread : float

distance between the centers of the end circles (default 10)

tangent : float

angle in degrees of the tangent point of the joining arcs, from the Y axis (default 30)

diameter : float | None

diameter of the end circles (alternative to radius)

anchor : Anchor | Sequence[float]

anchor point (default CENTER)

spin : float

Z-axis rotation in degrees after anchor (default 0)

fn : int | None

arc smoothness overrides

fa : float | None

arc smoothness overrides

fs : float | None

arc smoothness overrides

Return type:

Bosl2Shape2D

Examples

from pybosl2 import shapes2d as s2

s2.glued_circles(radius=10, spread=25, tangent=30).linear_extrude(height=5).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.shapes2d.circle.reuleaux_polygon(sides=3, radius=None, diameter=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]

Return a Reuleaux polygon (constant-width curved-side shape), built directly with polygon().

Parameters:
sides : int

number of “sides”; must be an odd positive number (default 3)

radius : float | None

scale the shape to fit in a circle of this radius

diameter : float | None

scale the shape to fit in a circle of this diameter

anchor : Anchor | Sequence[float]

anchor point (default CENTER)

spin : float

Z-axis rotation in degrees after anchor (default 0)

fn : int | None

arc smoothness overrides

fa : float | None

arc smoothness overrides

fs : float | None

arc smoothness overrides

Return type:

Bosl2Shape2D

Examples

from pybosl2 import shapes2d as s2

s2.reuleaux_polygon(sides=3, radius=15).linear_extrude(height=5).show()
Loading 3-D preview…

⬇ Download STL mesh