Occasionally someone asks in one of the POV-Ray or other 3D graphics forums: "How do I make a shape or path like a baseball seam?" This page answers the question, with explanations.
The equations come out fairly simple, if not obvious. The curve that the seam follows is a closed loop, a topological circle, so I parametrize the points along it with an angle α with no direct geometric meaning, running from 0 to 360 degrees. (If you didn't see a lower case alpha, then your browser isn't understanding HTML entities for Greek letters -- α and the like, or it's not using the Symbol font.)
We create the basic formula in two steps, with some further steps that may be useful depending on what you're using the formula for.
With xyz axes defined and a sketch of a baseball,
I derived formula by visualizing the baseball seam's curve in
my mind, sketching it on paper, considering its symmetries, inflection points and such,
then sketching crude plots of x(α), y(α), and z(α).
Z(α) came out as a roughly cosine shape
with a frequency of two cycles.
The other two coordinates were sine and cosine but needed some dimples to reverse their
peaks. This can be done by adding a harmonic of frequency of 3.
With a little more thought and refinement, and defining a couple constants, B and F,
i wrote down this formula for the unnormalized x,y,z coordinates:
The other constant F doesn't have as much effect on the curve, but after my first attempt where i omitted it (assuming F=1) i discovered it's better to allow for it. The image shown at the top of this page, made during that first attempt, used B=0.6 and F=1.0 which certainly looks baseballseamesque.
Of course, you may use any crazy values for B and F you like for making wild shapes.
|click for larger image|
Step Two is basic 3D math. A seam point S(α) should be on a sphere of radius R, but we have
are given the unnormalized point <xu, yu, zu>.
Note that the distance of the point, before we normalize it, varies with α in a way involving
sin2(2α) and cos2(2α); if we choose B and F so that
I used color dispersion with glassy baseballs to make the image interesting, and show the seam from many angles. The script should work fine with any POV-Ray from 3.5 on, and Mega-POV. I think i used version 3.1g once upon a time. (This script has been revised since the original posting of these pages in 1999. Back then, I had hacked a bizarre 9-component color space to implement color dispersion with metamerism effects.)
As the seam-tracing parameter α increases, do we get points evenly spaced along the seam? By differentiating the coordinates <x,y,z> w.r.t. α, and now taking α as measured in radians, we define a velocity vector V:
Hmmm, if we choose F=3B, we get constant speed for free. Earlier, we had found a constant
unnormalized radius by setting F2 = 4B. If we insist on both, we find
B=4/9= 0.444… which is somewhat short of the artistic ideal of B near 0.6 found earlier.
But then, we're now setting F=4/3 instead of F=1 like we had before - we might as well
render an image to see what these "magic" numbers lead to:
Hey, looks great! Except for the even spacing of the beads along the seam path, it looks quite similar the B=0.6, F=1.0 case. Well let us officially adopt the values:
So far all we've done is find points along a seam. In a real projects, we would probably want to position complex objects in proper orientation along the seam, for example, a element of a stitch, to be repeated along the entire path. To do this we need a way of defining directions relative to the curve at any point along it. A set of mutuallly perpendicular, unit-lengths vectors, known as a triad, can be set up at each point along the seam with a little easy differential calculus.
One direction easily defined - the "V" vector we just defined above. This points straight along the curve.
Another direction easily defined is simply radially away from the center of the baseball - normal to the baseball's surface at any point along the seam. Call this N If for some given α our point S(α) is at <x, y, z> then N is simply <x, y, z> normalized to unit length.
The third unit vector in the travelling triad, call it W for sideWays, is just the cross product of V and N. If you were an ant walking along the seam in the direction of increasing α, W would always point to your right.
It is not worth the bother to write out an mathematical expression for W in terms of trig functions. V and N are easy enough to calculate, and all we need to do for W is figure a cross product, and be careful about normalizing.
Paul Bourke at Swinburne has a page describing a baseball seam curve using trig functions phase modulated by more trig functions. Not as analytically tractable as our truncated harmonic series. But he has pages describing many other interesting curves, the websurfing of which could kill for you a whole day of precious time.
Auto-CAD users may like this tutorial that
creates a baseball seam with stitching using four circular arcs and Auto-CAD's ability to replicate objects