Skip to content

Latest commit

 

History

History
326 lines (217 loc) · 8.73 KB

curve.md

File metadata and controls

326 lines (217 loc) · 8.73 KB

cqmore.curve

Provide parametric equations of curves.

2D Functions

Signature Description
circle(t,radius) The parametric equation of a circle.
logarithmicSpiral(t[,a,k]) The parametric equation of a logarithmic spiral.
archimedeanSpiral(t,a,b) The parametric equation of a archimedean spiral.
squircle(t,radius,s) (Preview) The parametric equation of a squircle.
egg(t,a[,c]) (Preview) The parametric equation of a Egg Shaped Curve III.
superellipse(t,n[,a,b]) The parametric equation of a superellipse.
superformula(t,m,n1,n2,n3[,a,b]) The parametric equation of a superformula.

3D Functions

Signature Description
helix(t,radius,slope) The parametric equation of a helix.
sphericalSpiral(t,radius[,c]) The parametric equation of a spherical spiral.
torusKnot(t,p,q) The parametric equation of a (p,q)-torus knot.
lemniscateGerono(t[,a,b,c]) (Preview) The parametric equation of a Lemniscate of Gerono.
parametricEquation(func[,*args,**kwargs]) Convert func into a function f(t) used by Workplane.parametricCurve.

circle

The parametric equation of a circle.

Parameters

  • t : a parametric variable in the range 0 to 1.
  • radius : circle radius.

Examples

from cqmore import Workplane
from cqmore.curve import circle

radius = 1

c = (Workplane()
        .parametricCurve(lambda t: circle(t, radius))
        .center(radius * 3, 0)
        .polyline([circle(t / 10, radius) for t in range(6)]).close()
        .extrude(1)
    )

circle

logarithmicSpiral

The parametric equation of a logarithmic spiral. Default to a golden spiral.

Parameters

  • t: as it increases, the point traces a right-handed spiral about the z-axis, in a right-handed coordinate system.
  • a = 1: the a parameter of the logarithmic spiral.
  • k = 0.306349: the k parameter of the logarithmic spiral.

Examples

from cqmore import Workplane
from cqmore.curve import logarithmicSpiral

spiral = (Workplane()
            .polyline([logarithmicSpiral(t / 360) for t in range(360 * 5)])
         )

logarithmicSpiral

archimedeanSpiral

The parametric equation of a archimedean spiral.

Parameters

  • t: as it increases, the point traces a right-handed spiral about the z-axis, in a right-handed coordinate system.
  • a: move the centerpoint of the spiral outward from the origin.
  • b: control the distance between loops.

Examples

from cqmore import Workplane
from cqmore.curve import archimedeanSpiral

spiral = (Workplane()
            .polyline([archimedeanSpiral(t / 360, 1, 1) for t in range(360 * 5)])
         )

archimedeanSpiral

squircle

The parametric equation of a squircle.

Parameters

  • t: a parametric variable in the range 0 to 1.
  • s: the squareness parameter in the range 0 to 1.

Examples

from cqmore import Workplane
from cqmore.curve import squircle

r = 10
r1 = Workplane()
for i in range(0, 6):
    r1 = (r1.center(r * 3, 0)
            .parametricCurve(lambda t: squircle(t, r, i / 5))
            .extrude(1)
        )

squircle

egg

The parametric equation of a Egg Shaped Curve III.

Parameters

  • t: a parametric variable in the range 0 to 1.
  • a: roughly the radius at the big end.
  • c = 2: a * c is the length between ends.

Examples

from cqmore import Workplane
from cqmore.curve import egg

radius = 1

c1 = (Workplane()
        .parametricCurve(lambda t: egg(t, radius, c = 2))
        .center(radius * 2.5, 0)
        .parametricCurve(lambda t: egg(t, radius, c = 2.5))
        .center(radius * 3, 0)
        .parametricCurve(lambda t: egg(t, radius, c = 3))
        .extrude(1)
    )

egg

superellipse

The parametric equation of a superellipse.

Parameters

  • t: a parametric variable in the range 0 to 1.
  • n: the n parameter of the superellipse.
  • a = 1: the a parameter of the superellipse.
  • b = 1: the b parameter of the superellipse.

Examples

from cqmore import Workplane
from cqmore.curve import superellipse

r1 = Workplane()
for i in range(3, 10):
    r1 = (r1.center(3, 0)
            .parametricCurve(lambda t: superellipse(t, i / 5), N = 20)
            .extrude(1)
         )

superellipse

superformula

The parametric equation of a superformula.

Parameters

  • t: a parametric variable in the range 0 to 1.
  • m: the m parameter of the superformula.
  • n1: the n1 parameter of the superformula.
  • n2: the n2 parameter of the superformula.
  • n3: the n3 parameter of the superformula.
  • a = 1: the a parameter of the superformula.
  • b = 1: the b parameter of the superformula.

Examples

from cqmore import Workplane
from cqmore.curve import superformula

params = [
    [3, 4.5, 10, 10],
    [4, 12, 15, 15],
    [7, 10, 6, 6],
    [5, 4, 4, 4],
    [5, 2, 7, 7]
]

r1 = Workplane()
for i in range(5):
    r1 = (r1.center(4, 0)
            .parametricCurve(lambda t: superformula(t, *params[i]))
            .extrude(1)
         )

superformula

helix

The parametric equation of a helix.

Parameters

  • t : as it increases, the point traces a right-handed helix about the z-axis, in a right-handed coordinate system.
  • radius: the helix radius.
  • slope : the helix slope.

Examples

from cqmore import Workplane
from cqmore.curve import helix

radius = 1
slope = 1

c = (Workplane()
        .parametricCurve(lambda t: helix(t, radius, slope), stop = 3)
    )

helix

sphericalSpiral

The parametric equation of a spherical spiral.

Parameters

  • t: a parametric variable in the range 0 to 1.
  • radius: the sphere radius.
  • c = 2: equal to twice the number of turns.

Examples

from cqmore import Workplane
from cqmore.curve import sphericalSpiral

radius = 10
c = 10

spiral = (Workplane()
            .parametricCurve(lambda t: sphericalSpiral(t, radius, c))
         )

sphericalSpiral

torusKnot

The parametric equation of a torus knot.

Parameters

  • t : a parametric variable in the range 0 to 1.
  • p: the p parameter of the (p,q)-torus knot.
  • q : the q parameter of the (p,q)-torus knot.

Examples

from cqmore import Workplane
from cqmore.curve import torusKnot

p = 11
q = 13

c = (Workplane()
        .polyline([torusKnot(t / 360, p, q) for t in range(360)])
        .close()
    )

torusKnot

lemniscateGerono

The parametric equation (a * sin(φ), b * sin(φ) * cos(φ) , c * cos(φ)) of a Lemniscate of Gerono.

Parameters

  • t: a parametric variable in the range 0 to 1.
  • a: the a parameter of the Lemniscate of Gerono.
  • b: the b parameter of the Lemniscate of Gerono.
  • c: the c parameter of the Lemniscate of Gerono.

Examples

from cqmore import Workplane
from cqmore.curve import lemniscateGerono

r = (Workplane()
    .parametricCurve(lambda t: lemniscateGerono(t)))

lemniscateGerono

parametricEquation

Convert func into a function f(t) used by Workplane.parametricCurve.

Parameters

  • func: the parametric equation of a curve.
  • *args: the positional arguments.
  • **kwargs: the keyword arguments.

Examples

from cqmore import Workplane
from cqmore.curve import torusKnot, parametricEquation

p = 4
q = 9

c = (Workplane()
        .parametricCurve(parametricEquation(torusKnot, p = p, q = q))
    )

parametricEquation