电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

基于狄洛尼三角网生成算法的源代码VIP免费

基于狄洛尼三角网生成算法的源代码_第1页
1/17
基于狄洛尼三角网生成算法的源代码_第2页
2/17
基于狄洛尼三角网生成算法的源代码_第3页
3/17
importjava.util.*;importjava.awt.*;publicclassMyEdge{publicstaticintcount=0;publicintid;privateintbegin;privateintend;privateintuseCount;publicMyEdge(intbegin,intend){this.id=++count;this.begin=begin;this.end=end;this.useCount=0;}publicMyEdge(MyPointbegin,MyPointend){this.id=++count;this.begin=begin.id;this.end=end.id;this.useCount=0;}publicintgetUseCount(){returnthis.useCount;}publicvoidaddUseCount(){this.useCount++;}/**下面这两个方法是得到边的来个顶点*若集合中没有指定的对象则返回空值*/publicMyPointgetBeginPoint(MappointSet){MyPointtemp=pointSet.get(this.begin);returntemp;}publicMyPointgetEndPoint(MappointSet){MyPointtemp=pointSet.get(this.end);returntemp;}/**下面是根据两个点的ID,在边集中找寻两点组成的边*返回的是边对象*若没找到,则返回空*/publicstaticMyEdgegetEdge(intbegin,intend,MapedgeSet){MyEdgetemp=null;for(inti=1;i<=edgeSet.size();i++){temp=edgeSet.get(i);if(temp.begin==begin&&temp.end==end)break;}returntemp;}/**下面是根据两个点对象,在边集中找寻两点组成的边*返回的是边对象*若没找到,则返回空*/publicstaticMyEdgegetEdge(MyPointbegin,MyPointend,MapedgeSet){MyEdgetemp=null;for(inti=1;i<=edgeSet.size();i++){temp=edgeSet.get(i);if(temp.begin==begin.id&&temp.end==end.id)break;}returntemp;}publicvoiddraw(Graphicsg,MappointSet){MyPointbegin=pointSet.get(this.begin);MyPointend=pointSet.get(this.end);Colorc=g.getColor();g.setColor(Color.blue);g.drawLine(begin.x,begin.y,end.x,end.y);g.setColor(c);}/**下面这个方法是用来判断点在当前直线的左边还是右边*当然当前直线是有方向的*若点在直线的右边,则返回false*否则返回true*/publicbooleanisOnLeft(MyPointp,MappointSet){booleanflag=false;MyPointbegin=pointSet.get(this.begin);MyPointend=pointSet.get(this.end);intLine=(begin.y-end.y)*p.x+(end.x-begin.x)*p.y-end.x*begin.y+end.y*begin.x;if(Line<0)flag=true;returnflag;}/**比较两个边是否相等*这个方法排除了边的方向性*只要空间上是一条边*就是同一条边即相等*/publicbooleanequals(Objectedge){booleanflag=false;if(this.end==((MyEdge)edge).begin&&this.begin==((MyEdge)edge).end||this.begin==((MyEdge)edge).begin&&this.end==((MyEdge)edge).end)flag=true;returnflag;}/**下面这个方法是将边的方向翻转*/publicvoidturnBeginAndEnd(){inttemp=this.begin;this.begin=this.end;this.end=temp;}/**下面这个方法是找到当前边的左边最优点*采用外接圆的方法*如果该边有左边最优点则返回之*否则返回空*/publicMyPointfindGoodPointByCircle(MappointSet,MapedgeSet,MaptriangleSet){MyPointgoodPoint=null;for(inti=1;i<=pointSet.size();i++){MyPointactivePoint=pointSet.get(i);if(this.isOnLeft(activePoint,pointSet))//判断当前活动点是不是在直线的左边{//在直线左边MyTriangleactiveTriangle=newMyTriangle(this.begin,i,this.end);intgood=i;for(intj=i+1;j<=pointSet.size();j++){//对当前活动边的左边点进行空圆准则检验if(this.isOnLeft(pointSet.get(j),pointSet))//判断当前活动点是不是在直线的左边{if(activeTriangle.isInCircle(pointSet.get(j),pointSet)){activeTriangle=newMyTriangle(this.begin,j,this.end);good=j;}}}goodPoint=pointSet.get(good);/**下面是生成边后的后期处理*///生成的第一边MyEdgenewEdge1=newMyEdge(this.getBeginPoint(pointSet),goodPoint);newEdge1.addUseCount();if(edgeSet.containsValue(newEdge1)){MyEdge.count--;for(intk=1;k<=edgeSet.size();k++){if(edgeSet.get(k).equals(newEdge1)){edgeSet.get(k).addUseCo...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

基于狄洛尼三角网生成算法的源代码

您可能关注的文档

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部