- 积分
- 0
- 注册时间
- 2010-10-3
- 仿真币
-
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2011-5-4 21:12:58
|
显示全部楼层
来自 大连理工大学
8# nwcwww
x=[-1;1;1;-1;0;0;1;-1];
y=[1; 1; -1; -1;1;-1;0;0];
points=[x;y];
[m,n]=size(y);
x0=mean(x);y0=mean(y); % the center point
r=sqrt((x-x0).^2+(y-y0).^2); % the radius
theta=acos((x-x0)./r); %the angle
index=(y-y0)<0;
theta(index)=2*pi-theta(index); %计算各个点的角度
[theta,i1]=sort(theta);
r1=r(i1);
i=0;s=0;
area = 1/2*abs(sum(x.*y([2:end,1])-y.*x([2:end,1])));
xi=x0+r1.*cos(theta);
yi=y0+r1.*sin(theta);
points=[[xi;xi(1)],[yi;yi(1)]]';
curve=cscvn(points);
fnplt(curve);
hold on;
plot(points(1,:),points(2,:),'o')
area(points(1,:),points(2,:))
hold off
精度不够啊 这是一个长方形 面积应该是4 算出来的是3.5 |
|