Channels ▼
RSS

JVM Languages

Ellipse Specification Using Vectors

Source Code Accompanies This Article. Download It Now.


Trigonometric Splines

For the purpose of the application I present here, think of splines as a means used to mathematically "connect the dots" with a smooth curve in some application where you are interested in defining a curve of arbitrary shape using movable points to control the shape of the curve. An interpolating uniform spline such as the Catmull-Rom spline, or the interpolating TSpline used in this algorithm, is controlled by a set of control points (commonly known as "knots"). Splines are defined piecewise, each piece being determined by four control points—the two preceding and two following the curve segment in sequence. Figure 3 shows a sample spline curve segment along with its control points.

The interpolating TSpline used in this algorithm is defined by a set of parametric equations (which form a basis curve) and control points, each arranged in vertical/horizontal vectors that are combined by means of matrix multiplication. They are arranged in vectors and given by the equations in Figure 4.

The TSpline basis is formed from a single trigonometric function with a period equal to four units. Each unit segment is then shifted to [0,1] to form the four basis spline function curves (Figure 5). Note in the upper graph that all of the zero crossings occur on unit intervals, except for the central part of the graph, which has a value of 1.0. The result can be seen in the lower graph where F2 and F3 have values of 1.0, which when multiplied by P2 and P3 yield the coordinates of P2 and P3 exactly, ensuring that the resulting curve segment interpolates P2 and P3. (Multiply the x and y components of P2 and P3 by 1.0, and you will get P2 and P3, respectively. The other curve segments, multiplied by 0.0, will contribute exactly 0.0 to the calculation.)

Figure 3: Sample spline curve segment along with its control points.

Figure 4: Equations that define the interpolating TSpline.

Figure 5: Four basis spline function curves.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video