Shared
Curves
DigitalArt.Curves — Module
CurvesParametric curve definitions and differential geometry utilities.
Provides standard curve definitions (circle, figure-eight, heart, etc.) and the mathematical tools needed to work with them: derivatives, curvature, arc-length tables, and arc-length resampling.
All curves are functions t -> SVector{2} mapping a real parameter to a 2D point.
DigitalArt.Curves.arclength_reparam — Method
arclength_reparam(f, t_start, t_end; resolution=1000) -> FunctionReturn a closure t(s) mapping arc length s to the curve parameter t reaching that arc length. Built once from a sampled arc-length table; reuse it instead of rebuilding the table per query. Extrapolates linearly.
DigitalArt.Curves.circle — Method
circle(t) -> SVector{2}Unit circle. Parameter range: [0, 2π].
DigitalArt.Curves.compute_arc_length_table — Method
compute_arc_length_table(f, ts) -> (points, lengths)Build a cumulative arc-length table for curve f sampled at parameter values ts.
Returns:
points: vector ofSVector{2}curve pointslengths: cumulative arc lengths (same length asts, starts at 0)
DigitalArt.Curves.compute_curve_normal_direction — Method
compute_curve_normal_direction(f, t) -> SVector{2}Unit normal vector (rotated 90° CCW from tangent) to curve f at parameter t.
At a cusp or stationary point the tangent vanishes and the normal is undefined. Rather than returning NaN — which silently propagates into any position computed from it — this probes a short distance either side of t for a non-degenerate tangent, so the normal stays continuous with the surrounding curve. Falls back to (0, 1) only if the curve is degenerate throughout.
DigitalArt.Curves.curvature — Method
curvature(f, t) -> Float64Signed curvature magnitude κ of curve f at parameter t.
Uses the 2D formula κ = |v × a| / |v|³ where v = f'(t), a = f''(t). Returns 0 at inflection points where the denominator vanishes.
DigitalArt.Curves.figure_eight — Method
figure_eight(t) -> SVector{2}Lemniscate-like figure-eight curve. Parameter range: [0, 2π].
DigitalArt.Curves.first_derivative — Method
first_derivative(f, t)Compute the first derivative of curve f at parameter t using automatic differentiation (ForwardDiff).
DigitalArt.Curves.heart — Method
heart(t) -> SVector{2}Heart curve. Parameter range: [0, 2π]. Scale by a small factor (e.g. 0.1) when composing with other curves to normalise size.
DigitalArt.Curves.normalize_angle — Method
normalize_angle(θ) -> Float64Normalise an angle to the interval [-π, π].
DigitalArt.Curves.oval — Method
oval(t; a=2, b=1) -> SVector{2}Axis-aligned ellipse with semi-axes a (horizontal) and b (vertical). Parameter range: [0, 2π].
DigitalArt.Curves.resample_by_arclength — Method
resample_by_arclength(f, t_start, t_end, n_samples; resolution=1000)
-> (points, ts_sampled, total_length)Return n_samples points equally spaced by arc length along curve f over [t_start, t_end].
Returns:
points: equally arc-length-spaced curve pointsts_sampled: corresponding parameter valuestotal_length: total arc length of the curve
DigitalArt.Curves.second_derivative — Method
second_derivative(f, t)Compute the second derivative of curve f at parameter t.
DigitalArt.Curves.spiral — Method
spiral(t) -> SVector{2}Archimedean spiral. Parameter range determines number of turns.
DigitalArt.Curves.tangent_angle — Method
tangent_angle(f, t) -> Float64Angle (radians) of the tangent vector to curve f at parameter t, measured from the positive x-axis.
DigitalArt.Curves.total_arc_length — Method
total_arc_length(f, t_start, t_end; resolution=1000) -> Float64Compute the total arc length of curve f over [t_start, t_end].