PHD Project - Driver energy prediction
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

234 lines
6.4 KiB

3 years ago
%% Skript zum Plot Interpolieren
close all
clear all
%Skript f<EFBFBD>r Plotbasics
basics_plot
%Kontrollpunkte definieren:
fig_Res = figure(1); % figure handle erzeugen
clf(fig_Res)
strNurbBasic = struct('p',[],'pj',[],'u',[]);
nurbs = strNurbBasic;
nurbs.u = [0,0,0,1,1,1];
nurbs.p = [2];
bsplinehyper = nurbs;
for i = 4:4
switch i
case 1
wi = 0.2;
lineStyle = myLineTwo;
case 2
wi = 0.6;
lineStyle = myLineThree;
lineStyle2 = myGray75;
case 3
wi = 1;
lineStyle = myLineOne;
case 4
wi = 2;
lineStyle = myLineFour;
lineStyle2 = myGray25;
case 5
wi = 4;
lineStyle = myLineFive;
end
nurbs.pj = [0 wi*1 1;0 wi*0 1;1 wi 1];
bsplinehyper.pj = nurbs.pj;
ui = 0:0.01:1;
vek = zeros(2,numel(ui));
vekbspline = zeros(3,numel(ui));
%% Plot NURBS
for j = 1:numel(ui)
vek(:,j) = berechneAbleitungenAnPunkt(ui(j),nurbs.p,nurbs.u,nurbs.pj,0);
end
plot3(vek(1,:),vek(2,:),ones(size(vek(1,:))),'Color',lineStyle)
hold on
%% Plot BSpline
for j = 1:numel(ui)
vekbspline(:,j) = berechneAbleitungBSplineAnPunkt(ui(j),bsplinehyper.p,bsplinehyper.u,bsplinehyper.pj,0);
end
plot3(vekbspline(1,:),vekbspline(2,:),vekbspline(3,:),'Color',myLineSix)
end
plot3(nurbs.pj(1,1:end)./nurbs.pj(end,1:end),nurbs.pj(2,1:end)./nurbs.pj(end,1:end),ones(size(nurbs.pj(2,1:end))),'LineStyle','none','Marker','x','MarkerSize',8,'Color',myLineOne,'LineWidth',1.1)
plot3(bsplinehyper.pj(1,1:end),bsplinehyper.pj(2,1:end),bsplinehyper.pj(3,1:end),'LineStyle','none','Marker','x','MarkerSize',5,'Color',myLineSix,'LineWidth',0.9)
for k = 1:numel(nurbs.pj(1,1:end))
text(bsplinehyper.pj(1,k)-0.2,bsplinehyper.pj(2,k)+0.05,bsplinehyper.pj(3,k)+0.00,['$\tilde{\mv{p}}_' num2str(k-1) '$'],'Interpreter','none')
text(nurbs.pj(1,k)./nurbs.pj(end,k)-0.05,nurbs.pj(2,k)./nurbs.pj(end,k)-0.05,1+0.02,['$\cp{' num2str(k-1) '}$'],'Interpreter','none')
end
for n = 1:2:11
plot3([0 vek(1,10*(n-1)+1),vekbspline(1,10*(n-1)+1)],[0 vek(2,10*(n-1)+1),vekbspline(2,10*(n-1)+1)],[0 1,vekbspline(3,10*(n-1)+1)],'Color',lineStyle2,'LineStyle','--','Marker','.','MarkerSize',4)
end
plot3([0 vek(1,end),vekbspline(1,end)],[0 vek(2,end),vekbspline(2,end)],[0 1,vekbspline(3,end)],'Color',lineStyle2,'LineStyle','--','Marker','.','MarkerSize',4)
plot3([0, nurbs.pj(1,2)./nurbs.pj(end,2),bsplinehyper.pj(1,2)],[0, nurbs.pj(2,2)./nurbs.pj(end,2),bsplinehyper.pj(2,2)],[0, nurbs.pj(3,2)./nurbs.pj(end,2),bsplinehyper.pj(3,2)],'Color',lineStyle2,'LineStyle','--','Marker','.','MarkerSize',4)
pat = fill3([1 1 0 0],[0 1 1 0],[1 1 1 1],myGray50,'LineStyle','none');
alpha(pat,0.2);
text(0.1,0.95,1,'$w=1$')
grid on
xlabel('\figureXLabel')
ylabel('\figureYLabel')
zlabel('\figureZLabel')
%
% set(gca,'XLim',[0,1])
% set(gca,'YLim',[0,1])
%
% % scatter(P(1,:),P(2,:),'x','MarkerEdgeColor','black','LineWidth',1.5,'SizeData',400)
%
% % axis off
%
% axis equal
% hold on
%
% text(P(1,1)+0.2,P(2,1)+0.1,'$\mv{p}_{i-1}$','Interpreter','none')
% text(P(1,2)+0.1,P(2,2)+0.4,'$\mv{p}_i$','Interpreter','none')
% text(P(1,3)+0.1,P(2,3)-0.3,'$\mv{p}_{i+1}$','Interpreter','none')
% text(P(1,4)-0.9,P(2,4)+0.3,'$\mv{p}_{i+2}$','Interpreter','none')
%
%
%
% %% Polynomfit
% %
% % a = polyfit(P(1,:),P(2,:),3);
% % y = polyval(a,[-5:0.01:5]);
% % plot([-5:0.01:5],y,'LineStyle','--','Color',myLineThree)
%
%
% %% Lineare Interpolation mit zirkularer Blende
%
% % Winkelhalbierende berechnen
%
%
% delta = [0,1.2,0.7,0];
%
% for i = 2:size(P,2)-1
%
% n1 = (P(:,i-1)-P(:,i))/norm(P(:,i-1)-P(:,i));
% n2 = (P(:,i+1)-P(:,i))/norm(P(:,i+1)-P(:,i));
%
% nWH = (n1+n2)/norm(n1+n2); %Richtungsvektor der Winkelhalbierenden
%
% % WH plotten
%
% WH = P(:,i)+[-1:0.01:4].*nWH;
% plot(WH(1,:),WH(2,:),'LineStyle','-.','Color',myGray50)
%
%
% % Kreimittelpunkt berechnen
%
%
% SP1 = P(:,i)+delta(i).*n1;
% SP2 = P(:,i)+delta(i).*n2;
%
% nSenk1 = [0 1;-1 0]*n1;
% nSenk2 = [0 1;-1 0]*n2;
%
% lambda = [-nSenk1 nSenk2]\(SP1-SP2);
%
% MP = SP1+lambda(1).*nSenk1;
% MP2 = SP2+lambda(2).*nSenk2;
%
% % plot(SP1(1),SP1(2),'Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black')
% % plot(SP2(1),SP2(2),'Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black')
%
% %Kreis Plotten
% plot(MP(1),MP(2),'Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black')
%
% xval = SP1(1);
% yval = SP1(2);
% x = xval;
% y = yval;
% while xval < SP2(1)
% xval = xval + 0.01;
% if yval > MP(1)
% yval = +sqrt(lambda(1)^2-(xval-MP(1))^2)+MP(2);
% else
% yval = -sqrt(lambda(1)^2-(xval-MP(1))^2)+MP(2);
% end
%
% if imag(yval) == 0
% x = [x, xval];
% y = [y, yval];
% end
% end
% x = [x,SP2(1)];
% y = [y,SP2(2)];
%
% plot(x,y,'LineStyle','-','Color',myLineTwo)
%
%
%
%
% % plot(MP2(1),MP2(2),'Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black')
%
% end
%
% text(P(1,2)-0.7,P(2,2)-0.2,'$\delta_i$','Interpreter','none')
% text(P(1,3)-1.1,P(2,3)+0.3,'$\delta_{i+1}$','Interpreter','none')
%
% plot(P(1,:),P(2,:),'LineStyle','-','Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black','LineWidth',1,'MarkerSize',5)
%
% xlabel('\figureXLabel')
% ylabel('\figureYLabel')
%
% %%
% % a2 = polyfit(P(1,:),P(2,:),4);
% % y2 = polyval(a2,[-5:0.01:5]);
% % plot([-5:0.01:5],y2,'LineStyle','--','Color','red')
%
% box on
matlab2tikz('filename','plot_nurbshyperebene.tex',...
'height', '\figureheight', 'width', '\figurewidth', 'encoding', 'UTF8', 'showInfo', false, 'checkForUpdates', false, ...
'parseStrings', false, ... % switch off LaTeX parsing by matlab2tikz for titles, axes labels etc. ("greater flexibility", "use straight LaTeX for your labels")
'floatFormat', '%.4g', ... % limit precision to get smaller .tikz files
'noSize', false);
hold off
% box off % Box um die figure herum ausblenden