高手帮个啊忙啊
<P>本人第一次编的程序,出现了连接错误,想了几天得不到答案,高手帮忙啊,谢了,急!!!!!!!!!!!!</P><P>#include "math.h"<BR>//#include"gept2dar.h"<BR>#include"geline2d.h"<BR>//#include"acarray.h"<BR>#include"gepnt2d.h"<BR>#include"gelnsg2d.h"</P>
<P><BR>//以下为计算凸多边形面积方法 <BR>double areaofchimb(AcGePoint2dArray&ptarr)<BR>{<BR>AcGePoint2d *p=&ptarr.at(0);<BR> int i;<BR> int n;//点的个数<BR> <BR> n=ptarr.length();<BR> AcGePoint2d startpoint=ptarr.first();<BR> AcGePoint2d endpoint=ptarr.last();</P>
<P>//求顶点到其余点的对角线长<BR> double*arry=new double;</P>
<P> for(i=0;i<n-3;i++)<BR>// arry=(ptarr.at(0)).distanceTo(ptarr.at(i+2));<BR>arry=ptarr.distanceTo(ptarr);<BR>//求面积 <BR> double area=0;<BR> int j=0;<BR> for(j=0;j<n-2;j++)<BR> { double a;<BR> a=startpoint.distanceTo(ptarr);<BR> // a=ads_distance(ptarr,ptarr);<BR> double b;<BR> b=(ptarr).distanceTo(ptarr);<BR>// b=ads_distance(ptarr,ptarr);<BR> double d;<BR> if (j<n-3)<BR> d=arry;<BR> else<BR> d=startpoint.distanceTo(endpoint);<BR>// d=ads_distance(ptarr,ptarr);<BR> double c=(a+b+d)/2;<BR> double s=sqrt(c*(c-a)*(c-b)*(c-d));<BR> area+=s;<BR> }<BR> return area; <BR>}</P>
<P><BR>//计算多边形面积 !!需要修改,补凸的时候可能使临近两点变凹 <BR>double area(AcGePoint2dArray &ptarr)<BR>{ <BR> bool PointInPolygon(AcGePoint2d& pt,AcGePoint2dArray &ptarr);<BR> double areaoftriangle(AcGePoint2d ,AcGePoint2d,AcGePoint2d );<BR> int n;//点的个数<BR> n=4;<BR> ptarr.at(0).set(10,10);<BR> ptarr.at(1).set(10,20);<BR> ptarr.at(2).set(20,20);<BR> ptarr.at(3).set(20,10);</P>
<P><BR> double area=0;<BR> double s=0;<BR> int i;<BR> for(i=0;i<n;i++)<BR> {double s=0;<BR> AcGePoint2d*ppt=new AcGePoint2d(ptarr.at(i));<BR> ptarr.removeAt(i);<BR> bool flag;<BR> flag=PointInPolygon(*ppt,ptarr);<BR> if(flag==true) ptarr.insertAt(i,*ppt);<BR> else<BR> {AcGeLine2d*line=new AcGeLine2d(ptarr.at((i-1+n-1)%(n-1)),ptarr.at((i+n-1)%(n-1)));<BR> <BR> AcGePoint2d newpoint=(*ppt).mirror(*line);<BR> ptarr.insertAt(i,newpoint);<BR> s=s-2*(areaoftriangle(ptarr.at((n+i-1)%n),ptarr.at(i),ptarr.at((n+i+1)%n)));<BR> }<BR> }<BR> area=areaofchimb(ptarr);<BR> area=area-s;<BR> return area;</P>
<P>}</P>
<P><BR>//以下判断点是否在多边形中,在返回false ,不在返回true <BR>bool PointInPolygon(AcGePoint2d& pt,AcGePoint2dArray &ptarr)<BR>{<BR> int n = ptarr.length();<BR> int i, count=0; <BR> double yup, xup, ydown, xdown;<BR>// double y0, x0;<BR> double t;<BR> for( i=0; i< n; i++ )<BR> {<BR> if((pt.x ==(ptarr.at(i).x)&&(pt.y==ptarr.at(i).y) //!!检查括号匹配不??<BR> || (pt.x==(ptarr.at((i+1)%n).x))&&(pt.y==(ptarr.at((i+1)%n).y))))<BR> return true;<BR> xup=(ptarr.at(i)).x>(ptarr.at((i+1)%n).x)?(ptarr.at(i)).x:(ptarr.at((i+1)%n).x);<BR> yup=(ptarr.at(i)).y>(ptarr.at((i+1)%n).y)?(ptarr.at(i)).y:(ptarr.at((i+1)%n).y);<BR> xdown=(ptarr.at(i)).x<(ptarr.at((i+1)%n).x)?(ptarr.at(i)).x:(ptarr.at((i+1)%n).x);<BR> ydown=yup=(ptarr.at(i)).y<(ptarr.at((i+1)%n).y)?(ptarr.at(i)).y:(ptarr.at((i+1)%n).y);<BR> if(pt.y>yup)<BR> continue;<BR> if(pt.y<ydown)<BR> continue;<BR> if(pt.y==ydown)<BR> if(pt.y<yup&&pt.x<xdown) count++;<BR> else continue;<BR> if(pt.y<yup&&pt.y>ydown)<BR> double t=xdown+(pt.y-ydown)*(xup-xdown)/(yup-ydown);<BR> if(t>pt.x) count++;<BR> if(t=pt.x) return true;<BR> }<BR> if(count%2==0) return false;<BR> else <BR> return true;<BR>}</P>
<P>//计算三角形面积 <BR> double areaoftriangle(AcGePoint2d pt1,AcGePoint2d pt2,AcGePoint2d pt3)<BR> {<BR> double a,b,c,l,s;<BR> a=pt1.distanceTo(pt2);<BR> b=pt2.distanceTo(pt3);<BR> c=pt3.distanceTo(pt1);<BR> l=(a+b+c)/2;<BR> s=sqrt(l*(l-a)*(l-b)*(l-c));<BR> return s;<BR> }<BR></P>
<P>--------------------Configuration: Lab5Command - Win32 Debug--------------------<BR>Linking...<BR> Creating library Debug/Lab5Command.lib and object Debug/Lab5Command.exp<BR>Lab5CommandMain.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: double __thiscall AcGePoint2d::distanceTo(class AcGePoint2d const &)const " (<A href="mailto:__imp_?distanceTo@AcGePoint2d@@QBENABV1@@Z" target="_blank" >__imp_?distanceTo@AcGePoint2d@@QBENABV1@@Z</A>)<BR>Lab5CommandMain.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall AcGePoint2d::AcGePoint2d(class AcGePoint2d const &)" (<A href="mailto:__imp_??0AcGePoint2d@@QAE@ABV0@@Z" target="_blank" >__imp_??0AcGePoint2d@@QAE@ABV0@@Z</A>)<BR>Lab5CommandMain.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class AcGePoint2d & __thiscall AcGePoint2d::mirror(class AcGeLine2d const &)" (<A href="mailto:__imp_?mirror@AcGePoint2d@@QAEAAV1@ABVAcGeLine2d@@@Z" target="_blank" >__imp_?mirror@AcGePoint2d@@QAEAAV1@ABVAcGeLine2d@@@Z</A>)<BR>Lab5CommandMain.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall AcGeLine2d::AcGeLine2d(class AcGePoint2d const &,class AcGePoint2d const &)" (<A href="mailto:__imp_??0AcGeLine2d@@QAE@ABVAcGePoint2d@@0@Z" target="_blank" >__imp_??0AcGeLine2d@@QAE@ABVAcGePoint2d@@0@Z</A>)<BR>Lab5CommandMain.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class AcGePoint2d & __thiscall AcGePoint2d::set(double,double)" (<A href="mailto:__imp_?set@AcGePoint2d@@QAEAAV1@NN@Z" target="_blank" >__imp_?set@AcGePoint2d@@QAEAAV1@NN@Z</A>)<BR>Lab5CommandMain.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall AcGePoint2d::AcGePoint2d(void)" (<A href="mailto:__imp_??0AcGePoint2d@@QAE@XZ" target="_blank" >__imp_??0AcGePoint2d@@QAE@XZ</A>)<BR>.\..\Lab5Command.arx : fatal error LNK1120: 6 unresolved externals<BR>Error executing link.exe.</P>
<P>Lab5Command.arx - 7 error(s), 0 warning(s)<BR></P> 要包含库文件:acge15.lib(视ARX的版本而定,以acge开头的)<br> <P> if( (pt.x == (ptarr.at(i).x) && (pt.y==ptarr.at(i).y) ) //!!检查括号匹配</P>
页:
[1]