B = bernsteinMatrix(n1,t);
s(t) = int(norm(diff(bezierCurve)),0,t);
snum = linspace(0,s(1),T);
tnum(i) = vpasolve(snum(i)==s(t),t);
px = double(subs(bezierCurve(:,1),t,tnum)).';
pz = double(subs(bezierCurve(:,2),t,tnum)).';
normalToCurve = diff(bezierCurve)*[0 1;-1 0];
normalToCurve = normalToCurve/norm(normalToCurve);
newNormalToCurve = [double(subs(normalToCurve(1),t,tnum))' double(subs(normalToCurve(2),t,tnum))'];
newNormalToCurvex = newNormalToCurve(:,1);
newNormalToCurvez = newNormalToCurve(:,2);
S = double(s((i-1)/(T-1)));
d = R*(1-S/double(s(1)))+(H/2)*S/double(s(1));
pxnew1 = px+newNormalToCurvex.*delta;
pznew1 = pz+newNormalToCurvez.*delta;
S = double(s((i-1)/(T-1)));
rhilfe = (h/2)*S/double(s(1));
pxnew2 = px+newNormalToCurvex.*delta;
pznew2 = pz+newNormalToCurvez.*delta;
S = double(s((i-1)/(T-1)));
chilfe = R*(1-S/double(s(1)))+(h/2)*S/double(s(1));
S = double(s((i-1)/(T-1)));
lhilfe = H/2*S/double(s(1));
pxnew3a = px-newNormalToCurvex.*l;
pxnew3b = px+newNormalToCurvex.*l;
pznew3a = pz-newNormalToCurvez.*l;
pznew3b = pz+newNormalToCurvez.*l;
S = double(s((i-1)/(T-1)));
jhilfe = Rnewx*(1-S/double(s(1)))+(H/2)*S/double(s(1));
S = double(s((i-1)/(T-1)));
ehilfe = Rnewy*(1-S/double(s(1)))+(h/2)*S/double(s(1));
pxnew4 = px+newNormalToCurvex.*j;
pznew4 = pz+newNormalToCurvez.*j;
pxnew5 = px-newNormalToCurvex.*j;
pznew5 = pz-newNormalToCurvez.*j;
plot3(pxnew1,pynew1a,pznew1,'r-')
plot3(pxnew1,pynew1b,pznew1,'r-')
plot3(pxnew2,pynew1a,pznew2,'r-')
plot3(pxnew2,pynew1b,pznew2,'r-')
plot3(pxnew3a,pynew3a,pznew3a,'k-')
plot3(pxnew3b,pynew3a,pznew3b,'k-')
plot3(pxnew3a,pynew3b,pznew3a,'k-')
plot3(pxnew3b,pynew3b,pznew3b,'k-')
plot3(pxnew4,pynew4a,pznew4,'m-')
plot3(pxnew4,pynew4b,pznew4,'m-')
plot3(pxnew5,pynew5a,pznew5,'g-')
plot3(pxnew5,pynew5b,pznew5,'g-')
pxgesamt = [px;pxnew1; pxnew1; pxnew2; pxnew2; pxnew3a;pxnew3b;pxnew3a;pxnew3b;pxnew4; pxnew4; pxnew5; pxnew5];
pygesamt = [py;pynew1a;pynew1b;pynew2a;pynew2b;pynew3a;pynew3a;pynew3b;pynew3b;pynew4a;pynew4b;pynew5a;pynew5b];
pzgesamt = [pz;pznew1; pznew1; pznew2; pznew2; pznew3a;pznew3b;pznew3a;pznew3b;pznew4; pznew4; pznew5; pznew5];
pgesamt = [pxgesamt pygesamt pzgesamt];
surf([pxgesamt pygesamt pzgesamt])