function [x, y, xNums, yNums] = Bezier(point0, point1, control0, control1) % %This function returns a function handle to the hermite polynomial for the points given %[x, y, xNums, yNums] = Hermite(point0, point1, control0, control1) %All of the parameters are [x, y] coordinates %x is a function handle for the polynomial for x. x(t) %y is a function handle for the polynomial for y. y(t) %xNums is an array with the numbers for the x polynomial, starting a t^3 and working down %yNums is an array with the numbers for the y polynomial, starting a t^3 and working down % xNums = [0, 0, 0, 0]; yNums = [0, 0, 0, 0]; a = [(control0(1) - point0(1)), (point1(1) - control1(1))]; b = [(control0(2) - point0(2)), (point1(2) - control1(2))]; %t^3 number xNums(1) = (2 * (point0(1) - point1(1))) + (3 * (a(1) + a(2))); %t^2 number xNums(2) = (3 * (point1(1) - point0(1))) - (3 * (a(2) + (2 * a(1)))); %t number xNums(3) = (3 * a(1)); %constant xNums(4) = point0(1); %Function handle x = @(t) (xNums(1) * t.^3) + (xNums(2) * t.^2) + (xNums(3) * t) + xNums(4); %The t^3 number yNums(1) = (2 * (point0(2) - point1(2))) + (3 * (b(1) + b(2))); %The t^2 number yNums(2) = (3 * (point1(2) - point0(2))) - (3 * (b(2) + (2 * b(1)))); %The t number yNums(3) = (3 * b(1)); %The constant yNums(4) = point0(2); %Function handle y = @(t) (yNums(1) * t.^3) + (yNums(2) * t.^2) + (yNums(3) * t) + yNums(4); end