.
Curve Fitting 03.april.1999 GFX

by Hin Jang

Curve fitting describes the process of finding a function (or set of functions) that fit a set of data points. Given a set of points X and a corresponding set of values Y, the goal of curve fitting is to find the function(s) F such that

   f(x0) = y0
   f(x1) = y1
   f(x2) = y2

      .
      .
      .

   f(xn) = yn

In applications such as image processing and pattern recognition, curve fitting is an approximation technique. Converting a bitmapped image into its outlined representation, for example, requires an algorithm to find the minimum set of curve segments to approximate the image's outline with minimum distortion [2]. Cubic Bézier curves are most commonly used in this instance. Shao and Zhou developed a curve fitting algorithm that can automatically fit a set of data points with a set of cubic Bézier curves that are geometrically continuous. This continuity stipulates that the if two curve segments are smoothly connected at their joint, the two tangent vectors at the joint have the same direction. The algorithm described herein consists of two steps. First, critical points are identified from the set of data points and are classified as either corners or joints. The second phase consists of a weighted least-squares technique to find the optimal cubic curves that pass through some points and close to others.

step one: critical point detection
The curvature k at point P(x, y) of the curve y = f(x) is

               y''
   k  =  ----------------
         (1 + (y')2)2)1/3

Critical points are those points that have either maximum curvature values or sharp changes in curvature values. Given the finite resolution of display systems, the above equation cannot be used with any measure of confidence. Instead, the area values between a series of fixed-length chords and curve pieces along a quantised curve are calculated [2]. These areas are used to represent the average curvature at given points. The process of calculating these chord-curve areas can be summaried as such
   let P = curve with n points, represented as P0, P1, ... , Pn-1
   start index = 0

   for (each point in P) {

      s = start index
      m = s + 1

      for (every other point in P) {

         len = length of chord PsPms
         if (len >= L) break
         m++

      }
      
      Asm = area between chord PsPms and associated curve piece

      s++

   }

The threshold value for chord lengths is
   L  = c p A (ab)1/2

where c is a constant, p is the degree of noise level, A is the resolution of the image; a and b are the width and length of the image. The formula to compute the chord-curves area values is
           | x0  x1  x2  ...  xm  xs  |
   Asm  =  |                          |
           | y0  y1  y2  ...  ym  ys  |

              m
            ----
        =   \       (xpyp+1 - xp+1yp) + xpym - x0ym  
            /
            ----
            p = 0

The speed at which the areas are computed is greatly increased with incremental techniques [2]. Once the above process is complete, there will be n chord-curve area values that correspond to chords
   P0Pm0, P1Pm1, P2Pm2, ... , PnPmn

With these area values, the corner and joints points can be found. A corner point exists along the curve segment Ck if the area value reaches a local maximum at chord PkPmk and that area if greater than some threshold Vc. Suppose the area deviation di of a chord PiPmi is the difference between the area values that correspond to
   Pi-1Pmi-1 and Pi+1Pmi+1

A joint point exists along curve segement Ci if di is greater than some threshold Vj. Both Vc and Vj are functions of L.

step two: weighted least-square curve fitting
Suppose P0 and Pn are corner points, Pi are joints and Qi are the Bézier curves pieces that will fit the image. To minimise

          n-1     mi
         ----   ----
   S  =  \      \      [ Qi(tij) - Ci(j) ]2
         /      /
         ----   ----
          i=1    j=1

is the objective of this second step, where mi represents the number of points to be fitted by the ith piece of curve, Ci(j) is the jth data point to be fitted in the ith piece of the Bézier curve section [2]. The ith piece of the cubic Bézier curve is
   Qi(tij)  =  PiB0,2(tij)  +  Pi0B1,2(tij)  +  Pi1B2,2(tij)  +  Pi+1B3,2(tij)

where B are the Berstein polynomials for a the cubic curve and tij is in the range [0, 1].

Shao and Zhou provide an extensive derivation of a method that solves the non-linear problem to find the Qi's that minimisies S via a global optimsation curve fitting algorithm.



[1] Schneider, P.J., "An Algorithm for Automatically Fitting Digitised Curves," Graphics Gems, Andrew S. Glassner, ed., 612-625, 1990

[2] Shao, L., and H. Zhou, "Curve Fitting with Bézier Cubics," Graphical Models and Image Processing, 58(3):223-232, May 1996

[3] Vaishnav, H., and A. Rockwood, "Calculating Offsets of a Bézier Curve," ACM Proceedings on the Second Symposium on Solid Modeling, 491-492, 1993


.
Inverse Kinematics --.----.2000 GFX

by Hin Jang

[ -- incomplete first draft -- ]

An articulated figure consists of a set of rigid segments connected with joints. Varying the angles of the joints yields an indefinite number of configurations. The solution to the forward kinematics problem, given these angles, is the desired posture of the figure. The more difficult solution to the inverse kinematics problem is to find the joint angles given the desired configuration of the figure (i.e., end-effector). For animators, the inverse kinematics problem is of great importance. These artists find it far simplier to express spatial appearance rather than joint angles. Applications of inverse kinematic algorithms include interactive manipulation, animation control and collision avoidance. Some of these solutions approach the problem via nonlinear programming techniques [4].



[1] Baraff, D., "Linear-Time Dynamics using Lagrange Multipliers," Computer Graphics, SIGGRAPH 1996 Proceedings, 30(4):137-146

[2] Koga, Y., K. Kondo, J. Kuffner, J. Latombe, "Planning Motions with Intentions," Computer Graphics, SIGGRAPH 1994 Proceedings, 28(4):395-408

[3] Kondo, K., Inverse Kinematics of a Human Arm, CS-TR-94-1508, Robotics Laboratory Department of Computer Science, Stanford University, 1994

[4] Zhoa, J., and N.I. Badler, "Inverse Kinematics Positioning Using Nonlinear Programming for Highly Articulated Figures," ACM Transactions on Graphics, 13(4):313-336, October 1994