curves_functions¶
shortfx.fxNumeric.curves_functions
¶
Parametric curves, curvature, and arc-length formulas.
Classical plane curves and curvature analysis from Murray R. Spiegel's Mathematical Handbook of Formulas and Tables: cycloid, epicycloid, hypocycloid, cardioid, lemniscate, spirals, and curvature computations.
Functions¶
arc_length_function(f: Callable[[float], float], a: float, b: float, n: int = 10000) -> float
¶
Computes the arc length of y = f(x) over [a, b].
Integrates sqrt(1 + f'(x)^2) dx.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable[[float], float]
|
Function y = f(x). |
required |
a
|
float
|
Start of interval. |
required |
b
|
float
|
End of interval. |
required |
n
|
int
|
Number of integration steps (default 10000). |
10000
|
Returns:
| Type | Description |
|---|---|
float
|
Approximate arc length. |
Example
y = x from 0 to 1, length = sqrt(2)¶
round(arc_length_function(lambda x: x, 0, 1), 6) 1.414214
Complexity: O(n)
Source code in shortfx/fxNumeric/curves_functions.py
arc_length_parametric(x_func: Callable[[float], float], y_func: Callable[[float], float], t_start: float, t_end: float, n: int = 10000) -> float
¶
Computes the arc length of a parametric curve (x(t), y(t)) over [t_start, t_end].
Uses the trapezoidal rule to integrate sqrt(x'^2 + y'^2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_func
|
Callable[[float], float]
|
x(t) component function. |
required |
y_func
|
Callable[[float], float]
|
y(t) component function. |
required |
t_start
|
float
|
Start parameter. |
required |
t_end
|
float
|
End parameter. |
required |
n
|
int
|
Number of integration steps (default 10000). |
10000
|
Returns:
| Type | Description |
|---|---|
float
|
Approximate arc length. |
Example
Semicircle: x=cos(t), y=sin(t) from 0 to pi → length = pi¶
round(arc_length_parametric(math.cos, math.sin, 0, math.pi, 100000), 4) 3.1416
Complexity: O(n)
Source code in shortfx/fxNumeric/curves_functions.py
arc_length_polar(r_func: Callable[[float], float], theta_start: float, theta_end: float, n: int = 10000) -> float
¶
Computes the arc length of a polar curve r = f(θ) over [θ_start, θ_end].
Integrates sqrt(r^2 + (dr/dθ)^2) dθ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r_func
|
Callable[[float], float]
|
Polar function r(θ). |
required |
theta_start
|
float
|
Start angle. |
required |
theta_end
|
float
|
End angle. |
required |
n
|
int
|
Number of integration steps (default 10000). |
10000
|
Returns:
| Type | Description |
|---|---|
float
|
Approximate arc length. |
Example
Circle r = 1, full circle length = 2*pi¶
round(arc_length_polar(lambda t: 1.0, 0, 2 * math.pi, 100000), 4) 6.2832
Complexity: O(n)
Source code in shortfx/fxNumeric/curves_functions.py
archimedean_spiral(t: float, a: float = 0.0, b: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of an Archimedean spiral at parameter t.
Polar equation r = a + b*θ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians (>= 0). |
required |
a
|
float
|
Initial radius offset (default 0.0). |
0.0
|
b
|
float
|
Growth rate per radian (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = archimedean_spiral(math.pi, 0, 1) round(x, 4) -3.1416
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
astroid(t: float, a: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of an astroid at parameter t.
Special case of a hypocycloid with R = 4r. Parametric: x = a cos^3(t), y = a sin^3(t).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians. |
required |
a
|
float
|
Scale factor (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = astroid(0, 1) (round(x, 6), round(y, 6)) (1.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
bezier_cubic(p0: tuple, p1: tuple, p2: tuple, p3: tuple, t: float) -> tuple[float, float]
¶
Evaluate a cubic Bézier curve at parameter t.
B(t) = (1-t)³P0 + 3(1-t)²tP1 + 3(1-t)t²P2 + t³P3
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p0
|
tuple
|
Start point (x, y). |
required |
p1
|
tuple
|
First control point (x, y). |
required |
p2
|
tuple
|
Second control point (x, y). |
required |
p3
|
tuple
|
End point (x, y). |
required |
t
|
float
|
Parameter in [0, 1]. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
(x, y) point on the curve. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If t is not numeric. |
ValueError
|
If t not in [0, 1]. |
Usage Example
bezier_cubic((0, 0), (1, 3), (2, 3), (3, 0), 0.5) (1.5, 2.25)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
bezier_quadratic(p0: tuple, p1: tuple, p2: tuple, t: float) -> tuple[float, float]
¶
Evaluate a quadratic Bézier curve at parameter t.
B(t) = (1-t)²·P0 + 2(1-t)t·P1 + t²·P2
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p0
|
tuple
|
Start point (x, y). |
required |
p1
|
tuple
|
Control point (x, y). |
required |
p2
|
tuple
|
End point (x, y). |
required |
t
|
float
|
Parameter in [0, 1]. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
(x, y) point on the curve. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If t is not numeric. |
ValueError
|
If t not in [0, 1]. |
Usage Example
bezier_quadratic((0, 0), (1, 2), (2, 0), 0.5) (1.0, 1.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
brachistochrone_time(x_end: float, y_end: float, g: float = 9.80665) -> float
¶
Approximate the brachistochrone (fastest descent) time.
Uses the cycloid solution: T ≈ θ·√(R/g) where R and θ satisfy the cycloid parametric equations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_end
|
float
|
Horizontal distance to endpoint (> 0). |
required |
y_end
|
float
|
Vertical drop to endpoint (> 0, downward positive). |
required |
g
|
float
|
Gravitational acceleration (default 9.80665 m/s²). |
9.80665
|
Returns:
| Type | Description |
|---|---|
float
|
Approximate descent time in seconds. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If x_end ≤ 0, y_end ≤ 0, or g ≤ 0. |
Usage Example
round(brachistochrone_time(1.0, 1.0), 4) 0.493
Complexity: O(1) (uses analytical approximation)
Source code in shortfx/fxNumeric/curves_functions.py
butterfly_curve(t: float) -> tuple[float, float]
¶
Evaluate a point on the butterfly curve.
x = sin(t)(e^cos(t) - 2cos(4t) - sin⁵(t/12)) y = cos(t)(e^cos(t) - 2cos(4t) - sin⁵(t/12))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
(x, y) point on the butterfly curve. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If t is not numeric. |
Usage Example
x, y = butterfly_curve(0.0) round(y, 4) 0.7183
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
cardioid(t: float, a: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of a cardioid at parameter t.
Polar equation r = a(1 + cos θ), converted to Cartesian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians. |
required |
a
|
float
|
Scale factor (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = cardioid(0, 1.0) (round(x, 6), round(y, 6)) (2.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
cassini_oval(t: float, a: float = 1.0, c: float = 1.2) -> Tuple[float, float]
¶
Cassini oval in polar form: r² = a² cos(2t) ± √(a⁴cos²(2t) - a⁴ + c⁴).
Returns the outer branch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Angle in radians. |
required |
a
|
float
|
Focus half-distance. |
1.0
|
c
|
float
|
Product constant (c > 0). |
1.2
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
(x, y) coordinates (outer branch), or (0, 0) if r² < 0. |
Example
x, y = cassini_oval(0, 1.0, 1.5) round(x, 4) > 0 True
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
catenary(x: float, a: float = 1.0) -> float
¶
Evaluates the catenary curve y = a * cosh(x / a) at point x.
The catenary describes the shape of a flexible chain hanging under gravity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Horizontal coordinate. |
required |
a
|
float
|
Catenary parameter (sag constant, default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
float
|
y coordinate. |
Example
catenary(0, 1.0) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
catmull_rom(p0: float, p1: float, p2: float, p3: float, t: float) -> float
¶
Catmull-Rom spline interpolation between p1 and p2.
Uses p0/p3 as neighboring points for tangent computation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p0
|
float
|
Previous point value. |
required |
p1
|
float
|
Start point value. |
required |
p2
|
float
|
End point value. |
required |
p3
|
float
|
Next point value. |
required |
t
|
float
|
Parameter in [0, 1]. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Interpolated value between p1 and p2. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If t not in [0, 1]. |
Usage Example
catmull_rom(0.0, 1.0, 2.0, 3.0, 0.5) 1.5
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
cissoid(t: float, a: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of the cissoid of Diocles at parameter t.
Parametric: x = 2asin^2(t), y = 2asin^2(t)*tan(t).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians, t ≠ ±π/2. |
required |
a
|
float
|
Scale factor (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = cissoid(0, 1.0) (round(x, 6), round(y, 6)) (0.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
cochleoid(a: float, theta: float) -> float
¶
Compute r for the cochleoid curve: r = a·sin(θ)/θ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Scale parameter. |
required |
theta
|
float
|
Angle in radians (≠ 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Radial distance r. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If a ≤ 0 or theta = 0. |
Usage Example
round(cochleoid(1.0, 1.0), 4) 0.8415
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
conchoid_of_nicomedes(t: float, a: float = 1.0, b: float = 2.0) -> Tuple[float, float]
¶
Conchoid of Nicomedes: r = a/cos(t) + b, returned as (x, y).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Angle in radians (avoid t = ±π/2). |
required |
a
|
float
|
Distance to directrix. |
1.0
|
b
|
float
|
Offset distance. |
2.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
(x, y) coordinates. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If cos(t) ≈ 0. |
Example
x, y = conchoid_of_nicomedes(0, 1, 2) round(x, 6) 3.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
cornu_spiral(t: float, n: int = 50) -> tuple[float, float]
¶
Evaluate the Cornu (Euler) spiral at parameter t.
C(t) = (∫₀ᵗ cos(πu²/2) du, ∫₀ᵗ sin(πu²/2) du)
Uses trapezoidal rule with n steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Curve parameter. |
required |
n
|
int
|
Number of integration steps (default 50). |
50
|
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
(x, y) point on the Cornu spiral. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If t is not numeric. |
Usage Example
x, y = cornu_spiral(1.0) round(x, 4) 0.7798
Complexity: O(n)
Source code in shortfx/fxNumeric/curves_functions.py
curvature_explicit(f: Callable[[float], float], x: float, h: float = 1e-05) -> float
¶
Computes the curvature κ of y = f(x) at point x using numerical derivatives.
κ = |f''(x)| / (1 + f'(x)^2)^(3/2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable[[float], float]
|
Function y = f(x). |
required |
x
|
float
|
Point of evaluation. |
required |
h
|
float
|
Step size for numerical derivatives (default 1e-5). |
1e-05
|
Returns:
| Type | Description |
|---|---|
float
|
Curvature κ at x. |
Example
round(curvature_explicit(lambda x: x**2, 0), 6) 2.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
curvature_parametric(x_func: Callable[[float], float], y_func: Callable[[float], float], t: float, h: float = 1e-05) -> float
¶
Computes the curvature κ of a parametric curve (x(t), y(t)) at parameter t.
κ = |x'y'' - y'x''| / (x'^2 + y'^2)^(3/2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_func
|
Callable[[float], float]
|
x(t) component function. |
required |
y_func
|
Callable[[float], float]
|
y(t) component function. |
required |
t
|
float
|
Parameter value. |
required |
h
|
float
|
Step size for numerical derivatives (default 1e-5). |
1e-05
|
Returns:
| Type | Description |
|---|---|
float
|
Curvature κ at t. |
Example
Circle of radius 1: x=cos(t), y=sin(t), curvature = 1¶
round(curvature_parametric(math.cos, math.sin, 0), 4) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
curvature_polar(r_func: Callable[[float], float], theta: float, h: float = 1e-05) -> float
¶
Computes the curvature κ of a polar curve r = f(θ) at angle θ.
κ = |r^2 + 2r'^2 - r*r''| / (r^2 + r'^2)^(3/2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r_func
|
Callable[[float], float]
|
Polar function r(θ). |
required |
theta
|
float
|
Angle of evaluation. |
required |
h
|
float
|
Step size for numerical derivatives (default 1e-5). |
1e-05
|
Returns:
| Type | Description |
|---|---|
float
|
Curvature κ at θ. |
Example
Circle r = 1, curvature = 1¶
round(curvature_polar(lambda t: 1.0, 0), 4) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
cycloid(t: float, r: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of a cycloid at parameter t.
A cycloid is the curve traced by a point on the rim of a circle of radius r rolling along a straight line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter (angle of rotation in radians). |
required |
r
|
float
|
Radius of the generating circle (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
cycloid(math.pi, 1.0) (3.141592653589793, 2.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
cycloid_arc_length(r: float) -> float
¶
Computes the arc length of one arch of a cycloid with radius r.
One full arch (0 to 2π) has length 8r.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
float
|
Radius of the generating circle. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Arc length of one complete arch. |
Example
cycloid_arc_length(1.0) 8.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
deltoid(t: float, a: float = 1.0) -> Tuple[float, float]
¶
Deltoid (3-cusped hypocycloid): x = a(2cos(t) + cos(2t)), y = a(2sin(t) - sin(2t)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter (radians). |
required |
a
|
float
|
Scale factor. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
(x, y) coordinates. |
Example
deltoid(0, 1.0) (3.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
epicycloid(t: float, R: float, r: float) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of an epicycloid at parameter t.
Traced by a point on a circle of radius r rolling outside a circle of radius R.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians. |
required |
R
|
float
|
Radius of the fixed circle. |
required |
r
|
float
|
Radius of the rolling circle. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = epicycloid(0, 3, 1) (round(x, 6), round(y, 6)) (4.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
epitrochoid(R: float, r: float, d: float, t: float) -> tuple[float, float]
¶
Evaluate an epitrochoid curve point.
x = (R+r)cos(t) - d·cos((R+r)t/r) y = (R+r)sin(t) - d·sin((R+r)t/r)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
R
|
float
|
Fixed circle radius. |
required |
r
|
float
|
Rolling circle radius. |
required |
d
|
float
|
Distance from center of rolling circle. |
required |
t
|
float
|
Parameter angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
(x, y) point. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If R or r ≤ 0. |
Usage Example
x, y = epitrochoid(3.0, 1.0, 0.5, 0.0) (round(x, 4), round(y, 4)) (3.5, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
evolute_ellipse(a: float, b: float, t: float) -> tuple[float, float]
¶
Compute a point on the evolute of an ellipse.
x = (a² - b²)/a · cos³(t) y = (b² - a²)/b · sin³(t)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Semi-major axis. |
required |
b
|
float
|
Semi-minor axis. |
required |
t
|
float
|
Parameter angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
(x, y) coordinates on the evolute. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If a or b ≤ 0. |
Usage Example
tuple(round(v, 4) for v in evolute_ellipse(5.0, 3.0, 0.0)) (3.2, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
fermat_spiral(a: float, theta: float) -> float
¶
Compute r for Fermat's spiral: r = a·√θ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Scale parameter. |
required |
theta
|
float
|
Angle in radians (≥ 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Radial distance r. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If a ≤ 0 or theta < 0. |
Usage Example
round(fermat_spiral(1.0, 4.0), 4) 2.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
folium_of_descartes(t: float, a: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of the folium of Descartes at parameter t.
Parametric: x = 3at/(1 + t^3), y = 3at^2/(1 + t^3).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter (t ≠ -1). |
required |
a
|
float
|
Scale factor (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = folium_of_descartes(1, 1.0) (round(x, 6), round(y, 6)) (1.5, 1.5)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
gaussian_curvature_cylinder(r: float) -> float
¶
Returns the Gaussian curvature of a circular cylinder of radius r.
K = 0 (cylinders are developable surfaces).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
float
|
Radius (positive). |
required |
Returns:
| Type | Description |
|---|---|
float
|
0.0. |
Example
gaussian_curvature_cylinder(5) 0.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
gaussian_curvature_sphere(r: float) -> float
¶
Returns the Gaussian curvature of a sphere of radius r.
K = 1/r².
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
float
|
Radius (positive). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Gaussian curvature. |
Example
gaussian_curvature_sphere(2) 0.25
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
gaussian_curvature_torus(R: float, r: float, theta: float) -> float
¶
Returns the Gaussian curvature of a torus at angle theta.
K = cos(θ) / (r(R + r cos(θ))).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
R
|
float
|
Major radius (distance from center of tube to center of torus). |
required |
r
|
float
|
Minor radius (radius of tube). |
required |
theta
|
float
|
Poloidal angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Gaussian curvature at theta. |
Example
round(gaussian_curvature_torus(3, 1, 0), 6) 0.25
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
hermite_interpolation(p0: float, p1: float, m0: float, m1: float, t: float) -> float
¶
Cubic Hermite interpolation between two points.
H(t) = (2t³-3t²+1)p0 + (t³-2t²+t)m0 + (-2t³+3t²)p1 + (t³-t²)m1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p0
|
float
|
Value at start. |
required |
p1
|
float
|
Value at end. |
required |
m0
|
float
|
Tangent at start. |
required |
m1
|
float
|
Tangent at end. |
required |
t
|
float
|
Parameter in [0, 1]. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Interpolated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If t not in [0, 1]. |
Usage Example
hermite_interpolation(0.0, 1.0, 0.0, 0.0, 0.5) 0.5
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
hypocycloid(t: float, R: float, r: float) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of a hypocycloid at parameter t.
Traced by a point on a circle of radius r rolling inside a circle of radius R.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians. |
required |
R
|
float
|
Radius of the fixed circle. |
required |
r
|
float
|
Radius of the rolling circle (r < R). |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = hypocycloid(0, 4, 1) (round(x, 6), round(y, 6)) (4.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
hypotrochoid(R: float, r: float, d: float, t: float) -> tuple[float, float]
¶
Evaluate a hypotrochoid curve point.
x = (R-r)cos(t) + d·cos((R-r)t/r) y = (R-r)sin(t) - d·sin((R-r)t/r)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
R
|
float
|
Outer circle radius. |
required |
r
|
float
|
Inner circle radius. |
required |
d
|
float
|
Distance from center of inner circle. |
required |
t
|
float
|
Parameter angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
(x, y) point. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If R or r ≤ 0. |
Usage Example
x, y = hypotrochoid(5.0, 3.0, 5.0, 0.0) (round(x, 4), round(y, 4)) (7.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
involute_of_circle(t: float, r: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of the involute of a circle at parameter t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians (>= 0). |
required |
r
|
float
|
Radius of the base circle (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = involute_of_circle(0, 1) (round(x, 6), round(y, 6)) (1.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
lemniscate(t: float, a: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of the lemniscate of Bernoulli at parameter t.
Polar equation r^2 = a^2 cos(2θ). Only defined where cos(2t) >= 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians. |
required |
a
|
float
|
Scale factor (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If cos(2t) < 0 (curve undefined at this angle). |
Example
x, y = lemniscate(0, 1.0) (round(x, 6), round(y, 6)) (1.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
limacon(t: float, a: float = 1.0, b: float = 0.5) -> Tuple[float, float]
¶
Limaçon of Pascal: r = a + b·cos(t), returned as (x, y).
When b < a → dimpled; b = a → cardioid; b > a → inner loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Angle in radians. |
required |
a
|
float
|
Offset parameter. |
1.0
|
b
|
float
|
Cosine coefficient. |
0.5
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
(x, y) coordinates. |
Example
x, y = limacon(0, 1, 0.5) round(x, 6) 1.5
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
lissajous(t: float, a: float = 1.0, b: float = 1.0, omega_x: float = 3.0, omega_y: float = 2.0, delta: float = 0.0) -> Tuple[float, float]
¶
Lissajous figure: x = a·sin(ωₓt + δ), y = b·sin(ωᵧt).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter. |
required |
a
|
float
|
X-amplitude. |
1.0
|
b
|
float
|
Y-amplitude. |
1.0
|
omega_x
|
float
|
X-frequency. |
3.0
|
omega_y
|
float
|
Y-frequency. |
2.0
|
delta
|
float
|
Phase difference. |
0.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
(x, y) coordinates. |
Example
lissajous(0, 1, 1, 3, 2, 0) (0.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
lituus(a: float, theta: float) -> float
¶
Compute r for the lituus curve: r = a / √θ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Scale parameter. |
required |
theta
|
float
|
Angle in radians (> 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Radial distance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If a ≤ 0 or theta ≤ 0. |
Usage Example
round(lituus(1.0, 1.0), 4) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
logarithmic_spiral(t: float, a: float = 1.0, b: float = 0.2) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of a logarithmic spiral at parameter t.
Polar equation r = a * e^(b*θ).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians. |
required |
a
|
float
|
Scale factor (default 1.0). |
1.0
|
b
|
float
|
Growth factor (default 0.2). |
0.2
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = logarithmic_spiral(0, 1, 0.2) (round(x, 6), round(y, 6)) (1.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
mean_curvature_sphere(r: float) -> float
¶
Returns the mean curvature of a sphere of radius r.
H = 1/r.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
float
|
Radius (positive). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Mean curvature. |
Example
mean_curvature_sphere(4) 0.25
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
nephroid(t: float, a: float = 1.0) -> Tuple[float, float]
¶
Nephroid curve: x = a(3cos(t) - cos(3t)), y = a(3sin(t) - sin(3t)).
A 2-cusped epicycloid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter (radians). |
required |
a
|
float
|
Scale factor. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
(x, y) coordinates. |
Example
nephroid(0, 1.0) (2.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
piriform(t: float, a: float = 1.0, b: float = 1.0) -> Tuple[float, float]
¶
Piriform (pear-shaped) curve: x = a(1 + sin(t)), y = b·cos(t)(1 + sin(t)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter (radians). |
required |
a
|
float
|
X-scale. |
1.0
|
b
|
float
|
Y-scale. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
(x, y) coordinates. |
Example
piriform(0, 1, 1) (1.0, 1.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
principal_curvatures_ellipsoid(a: float, b: float, c: float, u: float, v: float) -> Tuple[float, float]
¶
Computes the principal curvatures of an ellipsoid at surface point (u, v).
Uses the parametrization x = a sin(u) cos(v), y = b sin(u) sin(v), z = c cos(u). Evaluated at the specific poles for simplicity (general case is complex).
For the north pole (u=0): kappa1 = c/a², kappa2 = c/b².
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Semi-axis along x. |
required |
b
|
float
|
Semi-axis along y. |
required |
c
|
float
|
Semi-axis along z. |
required |
u
|
float
|
Polar angle in [0, π]. |
required |
v
|
float
|
Azimuthal angle in [0, 2π]. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (kappa1, kappa2) principal curvatures. |
Example
k1, k2 = principal_curvatures_ellipsoid(2, 3, 1, 0, 0) (round(k1, 4), round(k2, 4)) (0.25, 0.1111)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | |
radius_of_curvature(f: Callable[[float], float], x: float, h: float = 1e-05) -> float
¶
Computes the radius of curvature R = 1/κ of y = f(x) at point x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable[[float], float]
|
Function y = f(x). |
required |
x
|
float
|
Point of evaluation. |
required |
h
|
float
|
Step size for numerical derivatives (default 1e-5). |
1e-05
|
Returns:
| Type | Description |
|---|---|
float
|
Radius of curvature. Returns inf if curvature is zero. |
Example
round(radius_of_curvature(lambda x: x**2, 0), 6) 0.5
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
rose_curve(t: float, a: float = 1.0, k: int = 3) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of a rose (rhodonea) curve at parameter t.
Polar equation r = a * cos(k*θ).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians. |
required |
a
|
float
|
Petal length (default 1.0). |
1.0
|
k
|
int
|
Number of petals parameter (default 3). k petals if odd, 2k if even. |
3
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = rose_curve(0, 1, 3) (round(x, 6), round(y, 6)) (1.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
strophoid(t: float, a: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of a right strophoid at parameter t.
Polar equation r = -a * cos(2θ) / cos(θ), converted to Cartesian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter angle in radians, t ≠ ±π/2. |
required |
a
|
float
|
Scale factor (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Example
x, y = strophoid(0, 1.0) (round(x, 6), round(y, 6)) (-1.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
superellipse(a: float, b: float, n_exp: float, t: float) -> tuple[float, float]
¶
Evaluate a point on a superellipse.
|x/a|^n + |y/b|^n = 1, parametrized as: x = a·|cos(t)|^(2/n)·sign(cos(t)), y = b·|sin(t)|^(2/n)·sign(sin(t))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Semi-axis x. |
required |
b
|
float
|
Semi-axis y. |
required |
n_exp
|
float
|
Exponent (> 0). |
required |
t
|
float
|
Parameter angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
(x, y) point on the superellipse. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If a, b ≤ 0 or n_exp ≤ 0. |
Usage Example
x, y = superellipse(1.0, 1.0, 2.0, 0.0) (round(x, 4), round(y, 4)) (1.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
surface_area_revolution(f: Callable[[float], float], a: float, b: float, n: int = 1000) -> float
¶
Computes the surface area of revolution of y = f(x) around the x-axis.
Uses the trapezoidal rule: S = 2π ∫_a^b f(x) sqrt(1 + f'(x)²) dx.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable[[float], float]
|
Function y = f(x) (must be non-negative on [a, b]). |
required |
a
|
float
|
Lower integration limit. |
required |
b
|
float
|
Upper integration limit. |
required |
n
|
int
|
Number of subdivisions. |
1000
|
Returns:
| Type | Description |
|---|---|
float
|
Surface area. |
Example
import math round(surface_area_revolution(lambda x: 1.0, 0, 1, 1000), 4) 6.2832
Complexity: O(n)
Source code in shortfx/fxNumeric/curves_functions.py
tautochrone_period(radius: float, g: float = 9.80665) -> float
¶
Compute the period of a tautochrone (cycloid) pendulum.
T = 2π√(r/g) — same as a simple pendulum of length r.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius of the generating circle. |
required |
g
|
float
|
Gravitational acceleration (default 9.80665 m/s²). |
9.80665
|
Returns:
| Type | Description |
|---|---|
float
|
Period in seconds. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If radius ≤ 0 or g ≤ 0. |
Usage Example
round(tautochrone_period(1.0), 4) 2.0064
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
tractrix(t: float, a: float = 1.0) -> Tuple[float, float]
¶
Returns the (x, y) coordinates of a tractrix at parameter t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Parameter in (0, pi) (angle from vertical). |
required |
a
|
float
|
Scale factor (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If t is not in (0, pi). |
Example
x, y = tractrix(math.pi / 2, 1.0) round(y, 6) 0.0
Complexity: O(1)
Source code in shortfx/fxNumeric/curves_functions.py
witch_of_agnesi(x: float, a: float = 1.0) -> float
¶
Evaluates the Witch of Agnesi curve y = 8a^3 / (x^2 + 4a^2) at point x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Horizontal coordinate. |
required |
a
|
float
|
Scale factor (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
float
|
y coordinate. |
Example
witch_of_agnesi(0, 1.0) 2.0
Complexity: O(1)