function [x,y,xa,ya] = spectrum(n_r,n_v,Xbasis,X2basis,Yle,aufloes)


 Xbasis=ones(aufloes,1).*Xbasis;
 X2basis=ones(aufloes,1).*X2basis;
 Yle=ones(aufloes,1).*Yle;

 if n_v == n_r,n=ones(aufloes,1)*n_r;
 else  n=[n_v:((n_r-n_v)/(aufloes-1)):n_r]';
 end
 for j = 1:aufloes,
 beta1(j)= asin( (sin( (pi/2)- winkel((Xbasis(j)/2),1,-6,Yle(j),...
           Xbasis(j),0,0,2 ))) ./n(j) );

 if beta1(j) < 0, beta1(j)=2*pi-beta1(j);end
 

  Pxy(j,:) = [2,Xbasis(j)] / sqrt(4+(Xbasis(j))^2)...
      +[(Xbasis(j)/2),1]+...
      (tan(beta1(j))./sqrt((Xbasis(j))^2+4))...
      .*[(-Xbasis(j)),(2)];
  
  
  px(j)=Pxy(j,1)-Xbasis(j)/2;
  py(j)=Pxy(j,2)-1;
  
  
  if py(j)<0 & Xbasis(j)/2-px(j)/py(j)<X2basis(j),   
    Xli1(j)=  Xbasis(j)/2-px(j)/py(j);
    Yli1(j)=0;
    oneline(j)=0;
    ap(j,:)=([Xli1(j),Yli1(j)]+...
     ( (2*X2basis(j)-2*Xli1(j)-X2basis(j)*Yli1(j) ) / (2*px(j)-X2basis(j)...
	  *py(j)) )*[px(j),-py(j)]);
  else Xli1(j)=0;Yli1(j)=1-(Xbasis(j)*py(j))/(2*px(j));
    ap(j,:)=[Xbasis(j)/2,1]+((X2basis(j)-Xbasis(j))/(2*px(j)+py(j)...
	    *X2basis(j)))*[px(j),py(j)];
    oneline(j)=1;
  end
 
  beta2(j)=pi/2-winkel(Xli1(j),Yli1(j),ap(j,1),ap(j,2),X2basis(j),0,0,2);
          alpha2(j)=asin(n(j)*sin(beta2(j)));
  if ((Xli1(j)>(ap(j,1)-ap(j,2)*2/X2basis(j)))& oneline(j)==0) |...
	((Yli1(j) < (ap(j,2) - ap(j,1)*X2basis(j)/2)) & oneline(j)==1),
    k(j)=-1;
  else k(j)=1; 
  end
  LA(j,:)=(ap(j,:)+[2,X2basis(j)]+tan(alpha2(j))*[X2basis(j),-2]*k(j));
  rLA(j,:)=LA(j,:)-ap(j,:);
  
  Xla(j)=6;
  Yla(j)=ap(j,2)+((6-ap(j,1))/rLA(j,1))*rLA(j,2); 

  if beta2(j)>=asin(1/n(j)), 
  Xla(j)=NaN;
  Yla(j)=nan;
  end
end




x=[[Xbasis(1:1:(aufloes-1))./2]';Xli1(1:1:(aufloes-1)) ;[ap(1:1:(aufloes-1),1)]';...
   [ap(2:1:aufloes,1)]';Xli1(2:1:aufloes);[Xbasis(1:1:(aufloes-1))./2]'];
 y1=ones(1,(aufloes-1));
y=[y1; Yli1(1:1:(aufloes-1)) ;[ap(1:1:(aufloes-1),2)]';...
   [ap(2:1:aufloes,2)]';Yli1(2:1:aufloes);y1];

xa=[[ap(1:1:(aufloes-1),1)]';Xla(1:1:(aufloes-1));Xla(2:1:aufloes);[ap(2:1:aufloes,1)]'];
ya=[[ap(1:1:(aufloes-1),2)]';Yla(1:1:(aufloes-1));Yla(2:1:aufloes);[ap(2:1:aufloes,2)]'];




