www.pudn.com > 3.rar > compute_vertex.m, change:2008-03-06,size:1105b


function [V]=compute_vertex(rs,rc,A,symb) 
%A = x1,y1 
%    x2,y2 
%    . , . 
%    xn,yn 
global b_max b_min k; 
 
%initial the y label 
min_y=min(A); 
V(1:2,2)=min_y(2); 
%V(4,2)=min_y(2); 
max_y=max(A); 
V(3:4,2)=max_y(2); 
 
%compute the k 
k=2*(rs+sqrt(rs*rs-rc*rc/4))/rc; 
 
%compute b   b=y-kx 
b=A(:,2)-k*A(:,1); 
b_max=max(b); 
b_min=min(b); 
 
%compute the x label 
V(1,1)=(V(1,2)-b_max)/k; 
V(2,1)=(V(2,2)-b_min)/k; 
V(3,1)=(V(3,2)-b_min)/k; 
V(4,1)=(V(4,2)-b_max)/k; 
 
 
%judge whether draw figure 
if symb 
         
    colordef none,  whitebg 
    figure(1); 
    axis equal 
    hold on; 
    box on; 
    plot([V(1,1) V(2,1)],[V(1,2) V(2,2)],'-k'); 
    hold on; 
    plot([V(2,1) V(3,1)],[V(2,2) V(3,2)],'-k'); 
    hold on; 
    plot([V(3,1) V(4,1)],[V(3,2) V(4,2)],'-k'); 
    hold on; 
    plot([V(4,1) V(1,1)],[V(4,2) V(1,2)],'-k'); 
    hold on; 
     
    title('Parallelogram'); 
    xlabel('X'); 
    ylabel('Y'); 
    x_lable=max(V); 
    axis([0,x_lable(1)+10, 0, max_y+10]);    
    set(gca, 'XTick', [0; x_label(1)+10]); 
    set(gca, 'YTick', [max_y+10]); 
 end