Spline Curve Fitting

Posted 2014.12.30 11:27

Let's assume that you are interested in finding a smooth curvature that follows certain prefixed points in two (or more) dimensional space. The easiest way to formulate this problem is to use spline functions to fit the given data. As far as I understand, cubic spline functions refer to polynomial function of time (or index) whose outputs are locations. 


Note that the simplest requirement (?) for fitting one cubic spline function is two locations and two velocities (location derivatives wrt time). In this case, four parameters of a cubic spline function can be precisely computed using elementary algebra. 



1. Generating paths using spline fitting 

 - As mentioned above, once points to follow are fixed, the curve passing through those points are fixed. Thus, in order to generate diverse paths, we must sample such points! In other words, in order to sample differing trajectories with fixed start and goal points, it is required to sample midpoints between start and goal points. 

 Each path is attained using spline fitting 5 points with varying 2 points. 


Source Code

main.m

더보기


splinepath.m

더보기


splinefit.m

더보기



2. Sample cubic spline function 

- In this case, we assume cubic spline function 

f(t) = a*t^3 + b*t^2 + c*t + d 

f(0) = p0

f'(0) = p0p

f(1) = p1

f'(1) = p1p

=> 

coef.a = 2*p0 - 2*p1 + p0p + p1p; 

coef.b = -3*p0 + 3*p1 - 2*p0p - p1p; 

coef.c = p0p; 

coef.d = p0;

 We sample two points and two point derivatives to fit cubic spline functions. 



Source Code

main.m

더보기


sample_splinepath.m

더보기





신고
« PREV : 1 : ··· : 127 : 128 : 129 : 130 : 131 : 132 : 133 : 134 : 135 : ··· : 588 : NEXT »