function gedrehteParabel

% http://geometrie.hs-nb.de/MATLAB-Programme/gedrehteParabel.m   Bearbeitungsstand: 21.9.2004
% (C) Martin Nitschke, nitschke@hs-nb.de

global ax
ax=[inf -inf inf -inf]; 
close('all')
deg=pi/180;
h=1;
alpha=285*deg;
D=[-1.15 1.15]*abs(tan(alpha));
[x,y]=fplot('x^2',D);
P=[cos(alpha) -sin(alpha);sin(alpha) cos(alpha)]*[x';y'];
drawPolygon(@plot,P,'k','linewidth',2.0);
hold('on')
r=2;
Kreisbogen([0;r],[0;0],r*[-sin(alpha);cos(alpha)],0,'k')
Spitze(r*[-sin(alpha);cos(alpha)],[-cos(alpha);-sin(alpha)],0.5*h,60*deg,0.0*[1 1 1]);
Schrift([0;0],sprintf('{  }%0.f^o',alpha/deg),'Rotation',alpha/deg,'FontSize',26,...
  'HorizontalAlignment','center','VerticalAlignment','top')
Schrift([sqrt(ax(4));ax(4)],'{\ity}={\itx}^2','color',0.5*[1 1 1],'HorizontalAlignment','left','VerticalAlignment','top')
plot([0 P(1,end)],[0 (P(2,1)+P(2,end))/2],'--k')
plot(x,y,'color',0.5*[1 1 1])
drawPolygon(@plot,[0 0 ax(2);ax(4) 0 0],'k');
plot(-sin(alpha)*(1+tan(alpha)^2),0,'+k')
Spitze([ax(2);0],[1;0],h,30*deg,0.0*[1 1 1]);
Spitze([0;ax(4)],[0;1],h,30*deg,0.0*[1 1 1]);
xS=-sin(alpha)*(1+tan(alpha)^2)
Schrift([xS;0],'\itx*','HorizontalAlignment','center','VerticalAlignment','top')
Schrift([ax(2);0],'\itx','HorizontalAlignment','right','VerticalAlignment','top')
Schrift([0;ax(4)+h/2],'\ity ','HorizontalAlignment','right','VerticalAlignment','top')
hold('off')
axis('off')
axis('equal');
axis([-sqrt(ax(4)) ax(2:4)]);
print('-depsc','gedrehteParabel')

function drawPolygon(draw,P,varargin);
global ax
feval(draw,P(1,:),P(2,:),varargin{:})
if min(P(1,:))<ax(1)
  ax(1)=min(P(1,:));
end
if max(P(1,:))>ax(2)
  ax(2)=max(P(1,:));
end
if min(P(2,:))<ax(3)
  ax(3)=min(P(2,:));
end
if max(P(2,:))>ax(4)
  ax(4)=max(P(2,:));
end

function Schrift(P,txt,varargin)
text(P(1),P(2),txt,'FontName','TimesNewRoman','FontSize',40,varargin{:});

function Spitze(P,v,L,phi,varargin);
if nargin<=2
  L=1;
end
if nargin<=3
  phi=7.5*pi/180;
end
ta=tan(phi/2);
v=L*v./repmat(sqrt(dot(v,v)),size(P,1),1);
n=[-v(2,:);v(1,:)];
Q=P-v+ta*n;
R=P-v-ta*n;
for k=1:size(P,2);
  fill([P(1,k) Q(1,k) R(1,k)],[P(2,k) Q(2,k) R(2,k)],varargin{:})
end

function Kreisbogen(A,M,B,offset,varargin)
deg=pi/180;
[t1,r1]=cart2pol(A(1)-M(1),A(2)-M(2));
[t2,r2]=cart2pol(B(1)-M(1),B(2)-M(2));
if abs(r1-r2)>sqrt(eps)
  error('Kreisbogen: A und B liegen nicht auf einem Kreis mit Mittelpunkt M')
end
r=(r1+r2)/2;
t1=t1-offset;
t2=t2+offset;
if t2<t1
  t2=t2+2*pi;
end
t=linspace(t1,t2,round((t2-t1)/deg));
drawPolygon(@plot,repmat(M,size(t))+r*[cos(t);sin(t)],varargin{:});
