Currently trying to neaten up some code, i want to add the curves into a single array and then simply use that array to plot rather than separate calls, this will also help me fill at a later date. I've got my array but for some reason i'm getting a strange output which is different to what i expect with a random line cutting down the middle.
Tried to change the order the array is populated with curves to no effect
% Outer Spade
% Lower Curve Control Points
p1 = [0, 0, 0.5, 0.6;
-1, 0, 0.1, 0];
p2 = refy(p1);
% Higher Curve Control Points
p3 = [0.6, 0.75, 0.75 , 0;
0, 0.15, 0.4 , 1];
p4 = refy(p3);
outer = [];
t = linspace(0,1,100);
C1 = cubic_bezier(p1,t);
C2 = cubic_bezier(p2,t);
C3 = cubic_bezier(p3,t);
C4 = cubic_bezier(p4,t);
outer =[outer C1,C3,C2,C4];
plot(outer(1,:),outer(2,:),'-b')
axis([-2 2 -1 3])
function C = cubic_bezier(P,t)
M = [-1,3,-3,1;
3,-6,3,0;
-3,3,0,0;
1,0,0,0];
T = [t.^3;t.^2;t;t.^0];
C = P * M * T;
end
function r = refy(m)
r = [-1,0;0,1] * m;
end
If i replace the outer and plot outer instead with the following code
hold on
plot(C1(1,:),C1(2,:))
plot(C2(1,:),C2(2,:))
plot(C3(1,:),C3(2,:))
plot(C4(1,:),C4(2,:))
Then i get what i expected, hope this helps. Thank you in advance