SPLINES.DLL Copyright (c) 1993 by Andrew S. Dean - All rights reserved. SPLINES.DLL is a Windows DLL distributed as shareware. SPLINES.DLL can be used from any Windows language or environment which supports DLL calls. See the file REGISTER.TXT for information on registration. SPLINES.DLL is a function library for creating spline curves. Several types of splines are supported (Bezier splines, B splines, Beta splines and Tau splines). Curves can be defined in 2D or 3D. All splines in the library are cubic splines. Splines are defined by interpolating between a set of distinct control points. Both control points and the resulting curves are stored in arrays of xyzTD structures. To create a curve, an xyzTD array of control points is passed to a spline function. The function returns another xyzTD array filled with the interpolated points which define the curve. Parameters can be used to control how many interpolating points are computed, and to fine-tune the shape of a curve. The spline points can be used to draw a curve, as a path for an animation object, as a contour for creating more complex 3D objects, and for many other applications that require smooth interpolations or transitions. The spline functions use the following parameters: Resolution The number of interpolating points to use for each curve segment. The curves are composed of a number of segments, each segment being associated with 4 adjacent control points. The resolution parameter specifies the number of line intervals that will be used to approximate a curve segment. The resolution parameter affects the number of curve points as follows: # points on entire curve = Resolution * ( # of control points - 1 ) + 1 = Resolution * ( # of control segments ) + 1 For example, A B spline with 4 control points and resolution of 5 will have 3 segments, for a total of 15 points on the curve. Bias Spline segments are controlled by a window of 4 control points. Bias affects which control points exert the most influence on the curve. Different types of splines use the bias parameters in different ways. The SplinApp.EXE program can be used to demonstrate the effect of the bias parameter on different curves. Tension The tension parameter affects how close the spline curve is to its control polygon. Increasing the tension parameter will pull the curve closer to the control polygon. Curve[] The array of spline points filled in by the spline function. This is passed as a buffer to the spline function, so it is up to the programmer to make sure the array is big enough. Control[] The array of control points used by the spline function to compute the interpolating spline points. This is referred to as the control polygon. NumControl The integer number of control points in the control polygon. All the spline functions return the number of spline points computed. Splines can be defined in both 2D and 3D. If you just need to work with 2D points, simply set the the Z component of each point to zero. Support for using SPLINES.DLL with Visual Basic is distributed as the file SPLINES.BAS, which contains the necessary Type definitions and Declare statements. Support for using SPLINES.DLL with C/C++ is provided through the files SPLINES.H and SPLINES.LIB. SPLINES.DLL was compiled with Microsoft Visual C++. The following examples, in C and Visual Basic, create a control polygon of 4 points, and then create an interpolating B spline curve with 16 points. C Example xyz_td Control[4]; xyz_td Curve[16]; long lNumControls; long lNumPoints; Control[0].x = 0.0; Control[0].y = 0.0; Control[0].z = 0.0; Control[0].x = 10.0; Control[0].y = 10.0; Control[0].z = 0.0; Control[0].x = 20.0; Control[0].y = 10.0; Control[0].z = 0.0; Control[0].x = 30.0; Control[0].y = 0.0; Control[0].z = 0.0; /* Create a normal Bspline (tension = 1.0) */ lNumPoints = Bspline(5, 1.0, 4, Control, Curve ); /* The Curve is now been filled with the points: i Curve[i].x Curve[i].y Curve[i].z 0 0 0 0 1 2 1.98 0 2 4 3.89 0 3 6 5.64 0 4 8 7.15 0 5 10 8.33 0 6 12 9.13 0 7 14 9.53 0 8 16 9.53 0 9 18 9.13 0 10 20 8.33 0 11 22 7.15 0 12 24 5.64 0 13 26 3.89 0 14 28 1.99 0 15 30 0 0 */ VB Example ---------- Dim xyzTD As Control[4] Dim xyzTD As Curve[16] Dim lNumControls As Long Dim lNumPoints As Long Control(0).fX = 0.0 Control(0).fY = 0.0 Control(0).fZ = 0.0 Control(0).fX = 10.0 Control(0).fY = 10.0 Control(0).fZ = 0.0 Control(0).fX = 20.0 Control(0).fY = 10.0 Control(0).fZ = 0.0 Control(0).fX = 30.0 Control(0).fY = 0.0 Control(0).fZ = 0.0 ' Create a normal Bspline (tension = 1.0) lNumPoints = Bspline(5, 1.0, 4, Control(0), Curve(0)) ' The Curve is now been filled with the points: ' i Curve(i).x Curve(i).y Curve(i).z ' ' 0 0 0 0 ' 1 2 1.98 0 ' 2 4 3.89 0 ' 3 6 5.64 0 ' 4 8 7.15 0 ' 5 10 8.33 0 ' 6 12 9.13 0 ' 7 14 9.53 0 ' 8 16 9.53 0 ' 9 18 9.13 0 ' 10 20 8.33 0 ' 11 22 7.15 0 ' 12 24 5.64 0 ' 13 26 3.89 0 ' 14 28 1.99 0 ' 15 30 0 0 ' '