After a rectangle, an oval sounds like a return to simplicity. No straight sections, no abrupt corners, just one smooth trip around the track. Surely that should make the mathematics easier?
A circle is remarkably cooperative. An ellipse, despite its innocent appearance, is considerably less so.
A circle with unequal radii
A circle has one radius and constant curvature. For an axis-aligned ellipse, we use two semi-axes: a is half its width, and b half its height.
When a = b, we have a circle. Otherwise we have an ellipse. The parameter t describes the corresponding angle on an auxiliary circle; it is not generally the polar angle of the point seen from the ellipse's center.
Finding points is easy. Finding the distance between them along the track is another matter—and a rolling gear needs that distance.
Open the full-size diagram
The problem with distance
On a circle, an angle θ in radians corresponds to arc length s = Rθ. Double the angle and you double the distance.
On an ellipse, the rate changes with position:
To get the accumulated distance, we add up that changing rate continuously:
This is an elliptic integral. In the general case it has no expression using only a finite combination of elementary functions. That does not make it unknowable: numerical integration can evaluate it to a chosen practical accuracy.
TRIV calculates and caches the length around a quarter ellipse, then reuses that information around the track. The pen's rolling phase follows accumulated arc length, not uniform increments of t.
The curvature won't sit still, either
A rolling circle must stay tangent to its track. For a horizontally elongated ellipse, the ends of the long axis are tightly curved; the top and bottom are gentler. Its curvature is:
When the semi-axes are equal, this reduces to 1/a, the constant curvature of a circle. Otherwise the direction and rate of turning vary along the path.
The generator follows the local tangent and normal while rotating the pen by the distance rolled. For inside rolling, a gear that is too large for the tightest curvature would invalidate the intended regular offset construction. TRIV requires its radius to stay below the smallest local radius of curvature, with a numerical safety margin.
Stretching is not rolling
We can stretch a circular trochoid into an oval, and the result may be attractive. But stretching changes distances and angles. A circular rolling gear would itself become elliptical under that transformation.
A stretched circular trochoid is not generally the same curve as a circle rolling along an elliptical track. TRIV's elliptical construction follows the actual track first. The separate final fit can then change the proportions of that completed ornament, just as it does in circular-corner mode.
Bringing the oval home
For a noncentered pen, closure still requires the position and rotational phase to repeat. With perimeter P, rolling radius r, and q circuits, the same contact-phase condition applies:
The perimeter now comes from numerical arc-length calculation. TRIV chooses a compatible gear radius and coprime circuit/frequency pair using that same calculated track length.
Elliptical mode currently uses Free corner matching. The extra corner-matching rules available for circular arcs are not imposed here. That is a choice in the present implementation, not a claim that symmetry on elliptical tracks is mathematically impossible.
From rounded corners to a complete oval
Elliptical geometry need not occupy the whole track. Quarter-ellipse corners can join straight sections into a rounded rectangle.
In TRIV's percentage mode, a fraction f sets the corner semi-axes to fW and fH. At 25%, the sides still contain straight sections. At 50%, those straight sections disappear and the four quarters form a complete ellipse.
Open the full-size diagram
The straight sections meet the elliptical arcs with a common tangent. That preserves the track's direction at each join, although curvature generally changes there. The interpolation handles these piece boundaries explicitly.
Changing curvature gives the ornament a different rhythm: loops gather, open out, and sweep around the ends. The geometry now reaches beyond circles and circular corners, while retaining a deliberate closure construction.
There is one final step between these calculations and something another design application can use. Our equations describe a curve; CAD and CAM need a practical vector representation.
A little further into the mathematics
NIST's Digital Library of Mathematical Functions: ellipse arc length gives the connection to elliptic integrals.
