function contour = formBspline(controlPoints, h) % Subfunction of the Simulated Annealing program. % Renders the given coefficients into a set of contour sections. persistent BP; % Check for construction of BP array if (length(BP) ~= h) BP = zeros(4,h); for i = 1:h val = (i-1)/h; BP(1,i) = bSplineFunc(val+1); BP(2,i) = bSplineFunc(val); BP(3,i) = bSplineFunc(val-1); BP(4,i) = bSplineFunc(val-2); end end nControlPoints = length(controlPoints); nSections = nControlPoints - 3; contour = zeros(nSections * h, 1); conBegin = 1; conEnd = h; cpBegin = 1; cpEnd = 4; for i = 1:nSections, contour(conBegin:conEnd) = controlPoints(cpBegin:cpEnd)' * BP; conBegin = conBegin + h; conEnd = conEnd + h; cpBegin = cpBegin + 1; cpEnd = cpEnd + 1; end