面向对象的分析方法在工程系统分析中的应用及魔方源代码-Java-Applet小程序_第1页
面向对象的分析方法在工程系统分析中的应用及魔方源代码-Java-Applet小程序_第2页
面向对象的分析方法在工程系统分析中的应用及魔方源代码-Java-Applet小程序_第3页
面向对象的分析方法在工程系统分析中的应用及魔方源代码-Java-Applet小程序_第4页
面向对象的分析方法在工程系统分析中的应用及魔方源代码-Java-Applet小程序_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

附录A面向对象的分析方法在工程系统分析中的应用本文介绍了面向对象的分析方法,并给出了一种面向对象的分析模型的表达方法。以液压系统设计为工程应用背景,探讨了面向对象的分析方法在工程系统分析中的应用。按照类-对象层、结构层、主题层、属性层和服务层五个层次分析了液压系统的类层次构成及其连接与通信。一、面向对象的分析简介:在大型软件开发项目中,无论是实时控制系统、数据库系统、人工智能系统,还是具体到自动代码生成,或扩展到一个工厂的计算机集成制造系统,都存在着一个共同的需求,就是在系统分析阶段建立系统的信息模型。在众多的系统分析方法中,面向对象的分析(OOA)方法更接近于人类的思维方式,正在被越来越多的系统分析人员使用。持面向对象观点的人认为,计算机程序的结构应该与所需解决的问题一致,而不是与某种分析方法保持一致。经验表明,对任何软件系统而言,其中最稳定的成份是相应问题论域(PROBLEMDOMAIN)的成份。而系统出问题通常也是由于问题论域的某些成份。因此,对问题论域进行充分分析及准确理解是保证系统稳定的重要基础。面向对象分析方法是建立在对象及其属性、类属及其成员、整体及其部分这些基本概念的基础上。大英百科全书指出:“人类在认识和理解现实世界的过程中普遍运用着三个构造法则:1.区分对象及其属性。例如,区分一棵树和树的大小或空间位置关系。2.区分整体对象及其组成部分。例如,区分一棵树和树枝。3.不同对象类的形成及区分。例如,所有树的类和所有石头的类的形成和区分。”OOA就是建立在以上三个常用法则的基础上。OOA模型描述了表示某个特定论域中的对象,以及各种各样的结构关系和通信关系。OOA模型有两个用途。首先,每个软件都建立在特定的现实世界中,OOA模型就是用来形式化该现实世界的“视图”。它建立起各种对象,分别表示软件系统主要的组织结构以及现实世界强加给软件系统的各种规则和约束条件。其次,给定一组对象,OOA模型规定了它们如何协同才能完成软件系统所指定的工作。这种协同在模型中是以表明对象之间通信方式的一组消息连接来表示的。以上简单介绍了面向对象的分析及在本文中的表示方法,下面将研究面向对象的分析在液压系统设计中的应用:第一层,对象-类层表示待开发系统的基本构造块。对象都是现实世界中应用论域概念的抽象。这一层是整个模型的基础。图符的外层边界表示实例边界,实际上它表明对象是非空的。而图符的内层边界则表示类边界。有时可以定义一些不当作程序块来实现的对象,即只有类边界而没有实例边界。在某些情形下,定义这种对象是很有用的。我们将它们称为模板类或抽象类。模板类可以为结成较高级的聚合体提供一条方便的途径。第二层,属性层,对象的属性和实例连接共同组成了OOA模型的属性层。我们把对象所存储的数据称为对象的属性。类的实例之间互相约束,它们必须遵从应用论域的某些限制条件或事务规则。例如,当定金取消后,相应的订户也应该被取消,这可能是一项事务规则。我们称这些约束为实例连接。第三层,服务层,对象的服务和消息通信组成了OOA模型的服务层。我们把对象所做的工作称为服务或方法。系统的不同对象都分别执行一定的工作或功能,它们之间通过消息通信,即所谓的协同,如图中的箭头所示。对象的服务及对象实例之间的消息通信共同组成了OOA模型的服务层。第四层,结构层,该层负责捕捉特定应用论域中的结构关系。泛化---特化结构获得类及成员组织,有助于刻画问题空间的类-成员层次,它通过搜集公共特性并把这种特性扩充到特例中来显示现实世界事件的通用性及专用性。整体-部分结构表达了人类的一种基本组织方式,即自然的整体和部分的结构关系,从而把一些部分的聚合构造成整体。例如,一辆汽车由发动机、传动装置和刹车装置组成。第五层,主题层,相当于全局系统的子系统或子模型。由于OOA模型的结构庞大而复杂,因此众多的对象有时很难处理。于是,可以把对象归到各个主题层中,可以把有关的对象用一个边框框起来加以实现。附录BObject-orientedanalysisintheapplicationofengineeringanalysisInthispaper,object-orientedanalysis,andgivesamodeloftheobject-orientedanalysisoftheexpression.Tothehydraulicsystemdesignengineeringbackgroundtoexploretheobject-orientedanalysisintheapplicationofengineeringanalysis.Inaccordancewiththecategory-Targetlayer,layerstructure,thethemelayer,servicesandattributesofthefive-levelanalysisofthehydraulicsystemofaclasshierarchyanditsconnectionandcommunication.

First,theobject-orientedanalysisIntroduction:thelarge-scalesoftwaredevelopmentprojects,whetheritisreal-timecontrolsystems,databasesystemsandartificialintelligencesystems,orspecifictoautomaticcodegeneration,orexpandtheplanttoacomputerintegratedmanufacturingsystem,thereisaAcommondemandintheanalysisstageistheestablishmentofinformationsystemsmodel.Amongthemanymethodsofanalysis,object-orientedanalysis(OOA)ismoreclosetohumanwayofthinking,isbeingmoreandmoresystematicanalysisofofficers.Object-orientedperspectiveontheviewthatthestructureofacomputerprogramshouldberequiredtoresolvetheissueofconsensus,ratherthanwithaconsistentmethodofanalysis.Experiencehasshownthatforanysoftwaresystem,oneofthemoststableelementoftheproblemisthecorrespondingdomain(PROBLEMDOMAIN)theingredients.Thesystemisalsotheproblembecausetheproblemisusuallythedomainofcertainingredients.Therefore,theissueofdomainanalysisofthefullandaccurateunderstandingistoensuresystemicstabilityoftheimportantfoundation.

Sowhatisittargetedintheend»Tongsudejiang,referringtotheobjectintheworldisanobjectiveentity,itcan"knowsomething"(thatis,datastorage),"dosomething"(thatis,packagingservices),and"synergywithotherobjects"(throughtheexchangeofinformation),Completed(modular)systemallthefeatures.Whyistheobjectofinterest»Theanswerissimpledatetoreuse.Whilecomputergeneratedfromthebeginning,wehavereusablecode,butobject-orientedtechnologyallowsreuseisnotonlythecode,therearemanyotherthings.Byobject-orientedtechnology,wecanreuserequirements,analysis,design,testplans,userinterfaceandarchitecture,andsoon.Object-orientedanalysisisbuiltonobjectsandtheirproperties,acategoryofitsmembers,andsomeofthesebasicoverallconceptofthefoundation.EncyclopediaBritannica:

"Inhumanawarenessandunderstandingoftherealworldinthecourseofthreetectonicwidespreaduseofthelaw:

1.Distinguishbetweenobjectsandtheirproperties.Forexample,thedistinctionbetweenatreeandthetreethesizeorlocationofspace.

2.Distinguishbetweentheobjectanditscomponents.Forexample,thedistinctionbetweenatreeandtreebranches.

3.Adifferentkindofobjectanddistinguish.Forexample,allthetreesandalltypesofstoneformationandtypeofdistinction."OOAisbuiltonmorethanthreeonthebasisofcommonlaw.OOAmodelthatdescribesaspecificdomainofthetarget,aswellasavarietyofstructuralrelationsandcommunicationsrelations.OOAmodelhastwopurposes.Firstofall,everysoftwarehavebeenestablishedinspecificrealworld,OOAmodelisusedtoformalizethereal-world"view."Itestablishedavarietyoftargets,namelythatthemajorsoftwaresystemsaswellastheorganizationalstructureoftherealworldimposedonthesoftwaresystemofrulesandconstraints.Secondly,givenasetoftargets,OOAmodelprovidesthemhowcollaborativesoftwaresystemtocompletetheworkasspecified.Thissynergyinthemodelthatistargetedmeansofcommunicationbetweenagroupofsourcesthatlinktothe.

Introducedmorethanasimpleobject-orientedanalysisinthispaper,andinthatway,thefollowingwillstudytheobject-orientedanalysisofthehydraulicsystemdesignapplications.

Thefirsttier,object-kindofquestionthatthedevelopmentofthebasicsystembuildingblocks.Objectsareintherealworldapplicationoftheconceptofabstractdomain.Thisisamodelofthewhole.Figureattheouterboundarythatexamplesoftheborder,infactitshowsthattargetednon-empty.Theiconsliningtheborder,saidtheboundary.Sometimessomecanbedefinedasablocktoachievethetarget,thatis,onlyboundaryandnoexamplesoftheborder.Insomecases,thedefinitionofthistargetisveryuseful.Wewillcallthemtemplateclassorabstractcategory.Classcanformatemplateforthemoreseniorofthepolymertoprovideaconvenientmeans.Thesecondlayer,layerattributes,theobject'spropertiesandexamplesoflinkingtogetheramodeloftheattributesoftheOOA.Weobjecttothestorageofdataknownastheobject'sproperties.Examplesofclassbetweentheconstraints,theymustcomplywiththeapplicationofthedomainOncertainrestrictionsorconditionsofservicerules.Forexample,aftertheabolitionofdeposit,thecorrespondingsubscribersshouldalsobecancelled,thismaybeaservicerules.Wecallfortheseexamplesoflinkingbound.

Thethirdtier,servicelayer,theobjectofcommunicationservicesandnewsoftheOOAmodeloftheservice.Weobjecttotheworkdonebythemethodknownastheservicesor.Thedifferentobjectsarerespectivelytheimplementationofcertainworkorfunction,communicationbetweenthemthroughthenews,theso-calledsynergies,asshowninFigureinthearrow.ObjectofservicesandexamplesoftargetedinformationoncommunicationsbetweenthecommoncomponentsoftheOOAmodeloftheservice.

Thefourthlayer,structurallayer,thelayerresponsibleforthecaptureapplication-specificdomainofthestructureofrelations.Generalization-thespecialtypeofstructureandaccesstomemberorganizations,helptodescribethetypeofspaceproblem-membersoflevels,throughthecollectionofpublicandexpandedtosuchpropertiesinspecialcasestoshowtherealworldeventsforthegeneralandSexual.Overall-partofthestructureofabasichumanorganization,thatisnaturalandpartoftheoverallstructure,sothatsomepartsofthepolymerstructureasawhole.Forexample,acarfromtheengine,transmissionandbrakecomponents.

Fifthfloor,thethemelayer,orglobalsystemsubsystemormodel.AsOOAmodelofthestructureoflargeandcomplex,somanyoftheobjectsitissometimesdifficulttohandle.Thus,theobjectcanreturntothethemeofall,canbetheobjectofaframe-uptoachieve.importjava.awt.*;importjava.applet.Applet;publicfinalclassrubikextendsApplet{inti;intj;intk;intn;into;intp;intq;intlastX;intlastY;intdx;intdy;intrectX[];intrectY[];ColorcolList[];Colorbgcolor;finaldoublesideVec[]={0.0,0.0,1.0,0.0,0.0,-1,0.0,-1,0.0,1.0,0.0,0.0,0.0,1.0,0.0,-1,0.0,0.0};finaldoublecorners[]={-1,-1,-1,1.0,-1,-1,1.0,1.0,-1,-1,1.0,-1,-1,-1,1.0,1.0,-1,1.0,1.0,1.0,1.0,-1,1.0,1.0};doubletopCorners[];doublebotCorners[];finalintsides[]={4,5,6,7,3,2,1,0,0,1,5,4,1,2,6,5,2,3,7,6,0,4,7,3};finalintnextSide[]={2,3,4,5,4,3,2,5,1,3,0,5,1,4,0,2,1,5,0,3,2,0,4,1};finalintmainBlocks[]={0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3};finalinttwistDir[]={-1,1,-1,1,-1,1,-1,1,1,1,1,1,1,-1,1,-1,1,1,1,1,-1,1,-1,1};finalintcolDir[]={-1,-1,1,-1,1,-1};finalintcircleOrder[]={0,1,2,5,8,7,6,3};inttopBlocks[];intbotBlocks[];intsideCols[];intsideW;intsideH;intdragReg;inttwistSide;intnearSide[];intbuffer[];doubledragCorn[];doubledragDir[];doubleeye[]={0.3651,0.1826,-0.9129};doubleeX[]={0.9309,-0.0716,0.3581};doubleeY[];doubleTeye[];doubleTeX[];doubleTeY[];doublelight[];doubletemp[]={0.0,0.0,0.0};doubletemp2[]={0.0,0.0,0.0};doublenewCoord[];doublesx;doublesy;doublesdxh;doublesdyh;doublesdxv;doublesdyv;doubled;doublet1;doublet2;doublet3;doublet4;doublet5;doublet6;doublephi;doublephibase;doubleCphi;doubleSphi;doublecurrDragDir[];booleannaturalState;booleantwisting;booleanOKtoDrag; doublelocal0;Mathm;GraphicsoffGraphics;ImageoffImage;publicvoidinit(){offImage=createImage(120,120);offGraphics=offImage.getGraphics();rectX=newint[4];rectY=newint[4];newCoord=newdouble[16];dragDir=newdouble[24];dragCorn=newdouble[96];topCorners=newdouble[24];botCorners=newdouble[24];topBlocks=newint[24];botBlocks=newint[24];buffer=newint[12];nearSide=newint[12];light=newdouble[3];Teye=newdouble[3];TeX=newdouble[3];TeY=newdouble[3];currDragDir=newdouble[2];eY=newdouble[3];vecProd(eye,0,eX,0,eY,0);normalize(eY,0);colList=newColor[120];for(i=0;i<20;i++){colList[i]=newColor(103+i*8,103+i*8,103+i*8);colList[i+20]=newColor(i*6,i*6,84+i*9);colList[i+40]=newColor(84+i*9,i*5,i*5);colList[i+60]=newColor(i*6,84+i*9,i*6);colList[i+80]=newColor(84+i*9,84+i*9,i*6);colList[i+100]=newColor(84+i*9,55+i*8,i*3);}sideCols=newint[54];for(i=0;i<54;i++)sideCols[i]=i/9;bgcolor=findBGColor();resize(125,125);repaint();}publicColorfindBGColor(){Colorcolor;Stringstring2="0123456789abcdef";intan[]=newint[6];Stringstring1=getParameter("bgcolor");if(string1!=null&&string1.length()==6){for(i=0;i<6;i++)for(j=0;j<16;j++)if(string1.charAt(i)==string2.charAt(j))an[i]=j;color=newColor(an[0]*16+an[1],an[2]*16+an[3],an[4]*16+an[5]);}elsecolor=Color.lightGray;returncolor;}publicdoublescalProd(doublead1[],inti,doublead2[],intj){returnad1[i]*ad2[j]+ad1[i+1]*ad2[j+1]+ad1[i+2]*ad2[j+2];}publicdoublevNorm(doublead[],inti){returnMath.sqrt(ad[i]*ad[i]+ad[i+1]*ad[i+1]+ad[i+2]*ad[i+2]);}publicdoublecosAng(doublead1[],inti,doublead2[],intj){returnscalProd(ad1,i,ad2,j)/(vNorm(ad1,i)*vNorm(ad2,j));}publicvoidnormalize(doublead[],inti){local0=vNorm(ad,i);ad[i]=ad[i]/local0;ad[i+1]=ad[i+1]/local0;ad[i+2]=ad[i+2]/local0;}publicvoidscalMult(doublead[],inti,doubled){ad[i]=ad[i]*d;ad[i+1]=ad[i+1]*d;ad[i+2]=ad[i+2]*d;}publicvoidaddVec(doublead1[],inti,doublead2[],intj){ad2[j]+=ad1[i];ad2[j+1]+=ad1[i+1];ad2[j+2]+=ad1[i+2];}publicvoidsubVec(doublead1[],inti,doublead2[],intj){ad2[j]-=ad1[i];ad2[j+1]-=ad1[i+1];ad2[j+2]-=ad1[i+2];}publicvoidcopyVec(doublead1[],inti,doublead2[],intj){ad2[j]=ad1[i];ad2[j+1]=ad1[i+1];ad2[j+2]=ad1[i+2];}publicvoidvecProd(doublead1[],inti,doublead2[],intj,doublead3[],intk){ad3[k]=ad1[i+1]*ad2[j+2]-ad1[i+2]*ad2[j+1];ad3[k+1]=ad1[i+2]*ad2[j]-ad1[i]*ad2[j+2];ad3[k+2]=ad1[i]*ad2[j+1]-ad1[i+1]*ad2[j];}publicvoidcutUpCube(){for(i=0;i<24;i++){topCorners[i]=corners[i];botCorners[i]=corners[i];}copyVec(sideVec,3*twistSide,temp,0);copyVec(temp,0,temp2,0);scalMult(temp,0,1.3333);scalMult(temp2,0,0.6667);for(i=0;i<8;i++){booleanflag=false;for(j=0;j<4;j++)if(i==sides[twistSide*4+j])flag=true;if(flag)subVec(temp2,0,botCorners,i*3);elseaddVec(temp,0,topCorners,i*3);}for(i=0;i<24;i++){topBlocks[i]=mainBlocks[i];botBlocks[i]=mainBlocks[i];}for(i=0;i<6;i++){if(i==twistSide){botBlocks[i*4+1]=0;botBlocks[i*4+3]=0;}else{k=-1;for(j=0;j<4;j++)if(nextSide[i*4+j]==twistSide)k=j;switch(k){case0:topBlocks[i*4+3]=1;botBlocks[i*4+2]=1;break;case1:topBlocks[i*4]=2;botBlocks[i*4+1]=2;break;case2:topBlocks[i*4+2]=2;botBlocks[i*4+3]=2;break;case3:topBlocks[i*4+1]=1;botBlocks[i*4]=1;break;case-1:topBlocks[i*4+1]=0;topBlocks[i*4+3]=0;break;}}}}publicbooleankeyDown(Eventevent,inti){if(i==114){twisting=false;naturalState=true;for(this.i=0;this.i<54;this.i++)sideCols[this.i]=this.i/9;repaint();}elseif(i==115){twisting=false;naturalState=true;for(this.i=0;this.i<20;this.i++)colorTwist((int)(Math.random()*6),(int)(Math.random()*3+1.0));repaint();}returnfalse;}publicbooleanmouseDrag(Eventevent,inti,intj){if(!twisting&&OKtoDrag){OKtoDrag=false;booleanflag=false;for(this.i=0;this.i<dragReg;this.i++){doubled1=dragCorn[this.i*8+1]-dragCorn[this.i*8];doubled2=dragCorn[this.i*8+5]-dragCorn[this.i*8+4];doubled3=dragCorn[this.i*8+3]-dragCorn[this.i*8];doubled4=dragCorn[this.i*8+7]-dragCorn[this.i*8+4];doubled5=(d4*((double)lastX-dragCorn[this.i*8])-d3*((double)lastY-dragCorn[this.i*8+4]))/(d1*d4-d3*d2);doubled6=(-d2*((double)lastX-dragCorn[this.i*8])+d1*((double)lastY-dragCorn[this.i*8+4]))/(d1*d4-d3*d2);if(d5>0.0&&d5<1.0&&d6>0.0&&d6<1.0){currDragDir[0]=dragDir[this.i*2];currDragDir[1]=dragDir[this.i*2+1];d=currDragDir[0]*(i-lastX)+currDragDir[1]*(j-lastY);d=d*d/((currDragDir[0]*currDragDir[0]+currDragDir[1]*currDragDir[1])*((i-lastX)*(i-lastX)+(j-lastY)*(j-lastY)));if(d>0.6){flag=true;twistSide=nearSide[this.i];this.i=100;}}}if(flag){if(naturalState){cutUpCube();naturalState=false;}twisting=true;phi=0.02*(currDragDir[0]*(i-lastX)+currDragDir[1]*(j-lastY))/Math.sqrt(currDragDir[0]*currDragDir[0]+currDragDir[1]*currDragDir[1]);repaint();returnfalse;}}OKtoDrag=false;if(!twisting){dx=lastX-i;copyVec(eX,0,temp,0);scalMult(temp,0,(double)dx*0.016);addVec(temp,0,eye,0);vecProd(eY,0,eye,0,eX,0);normalize(eX,0);normalize(eye,0);dy=j-lastY;copyVec(eY,0,temp,0);scalMult(temp,0,(double)dy*0.016);addVec(temp,0,eye,0);vecProd(eye,0,eX,0,eY,0);normalize(eY,0);normalize(eye,0);lastX=i;lastY=j;repaint();}else{phi=0.02*(currDragDir[0]*(i-lastX)+currDragDir[1]*(j-lastY))/Math.sqrt(currDragDir[0]*currDragDir[0]+currDragDir[1]*currDragDir[1]);repaint();}returnfalse;}publicbooleanmouseDown(Eventevent,inti,intj){lastX=i;lastY=j;OKtoDrag=true;returnfalse;}publicbooleanmouseUp(Eventevent,inti,intj){if(twisting){doubled;twisting=false;phibase+=phi;phi=0.0;for(d=phibase;d<0.0;d+=125.662)/*nullbody*/;intk=(int)(d*3.183);if(k%5==0||k%5==4){k=(k+1)/5%4;if(colDir[twistSide]<0)k=(4-k)%4;phibase=0.0;naturalState=true;colorTwist(twistSide,k);}repaint();}returnfalse;}publicvoidcolorTwist(inti1,intj1){intk4=0;intj4=j1*2;for(intk1=0;k1<8;k1++){buffer[j4]=sideCols[i1*9+circleOrder[k1]];j4=(j4+1)%8;}for(inti2=0;i2<8;i2++)sideCols[i1*9+circleOrder[i2]]=buffer[i2];j4=j1*3;for(intj2=0;j2<4;j2++){for(inti3=0;i3<4;i3++)if(nextSide[nextSide[i1*4+j2]*4+i3]==i1)k4=i3;for(intj3=0;j3<3;j3++){switch(k4){case0:buffer[j4]=sideCols[nextSide[i1*4+j2]*9+j3];break;case1:buffer[j4]=sideCols[nextSide[i1*4+j2]*9+2+3*j3];break;case2:buffer[j4]=sideCols[nextSide[i1*4+j2]*9+8-j3];break;case3:buffer[j4]=sideCols[nextSide[i1*4+j2]*9+6-3*j3];break;}j4=(j4+1)%12;}}j4=0;for(intk2=0;k2<4;k2++){for(intk3=0;k3<4;k3++)if(nextSide[nextSide[i1*4+k2]*4+k3]==i1)k4=k3;for(inti4=0;i4<3;i4++){switch(k4){case0:sideCols[nextSide[i1*4+k2]*9+i4]=buffer[j4];break;case1:sideCols[nextSide[i1*4+k2]*9+2+3*i4]=buffer[j4];break;case2:sideCols[nextSide[i1*4+k2]*9+8-i4]=buffer[j4];break;case3:sideCols[nextSide[i1*4+k2]*9+6-3*i4]=buffer[j4];break;}j4++;}}}publicvoidpaint(Graphicsg){dragReg=0;offGraphics.setColor(bgcolor);offGraphics.fillRect(0,0,120,120);if(naturalState)fixBlock(eye,eX,eY,corners,mainBlocks,0);else{copyVec(eye,0,Teye,0);copyVec(eX,0,TeX,0);Cphi=Math.cos(phi+phibase);Sphi=-Math.sin(phi+phibase);switch(twistSide){case0:Teye[0]=Cphi*eye[0]+Sphi*eye[1];TeX[0]=Cphi*eX[0]+Sphi*eX[1];Teye[1]=-Sphi*eye[0]+Cphi*eye[1];TeX[1]=-Sphi*eX[0]+Cphi*eX[1];break;case1:Teye[0]=Cphi*eye[0]-Sphi*eye[1];TeX[0]=Cphi*eX[0]-Sphi*eX[1];Teye[1]=Sphi*eye[0]+Cphi*eye[1];TeX[1]=Sphi*eX[0]+Cphi*eX[1];break;case2:Teye[0]=Cphi*eye[0]-Sphi*eye[2];TeX[0]=Cphi*eX[0]-Sphi*eX[2];Teye[2]=Sphi*eye[0]+Cphi*eye[2];TeX[2]=Sphi*eX[0]+Cphi*eX[2];break;case3:Teye[1]=Cphi*eye[1]+Sphi*eye[2];TeX[1]=Cphi*eX[1]+Sphi*eX[2];Teye[2]=-Sphi*eye[1]+Cphi*eye[2];TeX[2]=-Sphi*eX[1]+Cphi*eX[2];break;case4:Teye[0]=Cphi*eye[0]+Sphi*eye[2];TeX[0]=Cphi*eX[0]+Sphi*eX[2];Teye[2]=-Sphi*eye[0]+Cphi*eye[2];TeX[2]=-Sphi*eX[0]+Cphi*eX[2];break;case5:Teye[1]=Cphi*eye[1]-Sphi*eye[2];TeX[1]=Cphi*eX[1]-Sphi*eX[2];Teye[2]=Sphi*eye[1]+Cphi*eye[2];TeX[2]=Sphi*eX[1]+Cphi*eX[2];break;}vecProd(Teye,0,TeX,0,TeY,0);if(scalProd(eye,0,sideVec,twistSide*3)<0.0){fixBlock(Teye,TeX,TeY,topCorners,topBlocks,2);fixBlock(eye,eX,eY,botCorners,botBlocks,1);}else{fixBlock(eye,eX,eY,botCorners,botBlocks,1);fixBlock(Teye,TeX,TeY,topCorners,topBlocks,2);}}g.drawImage(offImage,0,0,this);}publicvoidupdate(Graphicsg){paint(g);}publicvoidfixBlock(doublead1[],doublead2[],doublead3[],doublead4[],intan[],inti){copyVec(ad1,0,light,0);scalMult(light,0,-3);addVec(ad2,0,light,0);subVec(ad3,0,light,0);for(this.i=0;this.i<8;this.i++){newCoord[this.i*2]=60+35.1*scalProd(ad4,this.i*3,ad2,0);newCoord[this.i*2+1]=60-35.1*scalProd(ad4,this.i*3,ad3,0);}for(this.i=0;this.i<6;this.i++){if(scalProd(ad1,0,sideVec,3*this.i)>0.001){k=(int)(9.6*(1.0-cosAng(light,0,sideVec,3*this.i)));offGraphics.setColor(Color.black);for(j=0;j<4;j++){rectX[j]=(int)newCoord[2*sides[this.i*4+j]];rectY[j]=(int)newCoord[2*sides[this.i*4+j]+1];}offGraphics.fillPolygon(rectX,rectY,4);sideW=an[this.i*4+1]-an[this.i*4];sideH=an[this.i*4+3]-an[this.i*4+2];if(sideW>0){sx=newCoord[2*sides[this.i*4]];sy=newCoord[2*sides[this.i*4]+1];sdxh=(newCoord[2*sides[this.i*4+1]]-sx)/sideW;sdxv=(newCoord[2*sides[this.i*4+3]]-sx)/sideH;sdyh=(newCoord[2*sides[this.i*4+1]+1]-sy)/sideW;sdyv=(newCoord[2*sides[this.i*4+3]+1]-sy)/sideH;p=an[this.i*4+2];for(n=0;n<sideH;n++){q=an[this.i*4];for(o=0;o<sideW;o++){rectX[0]=(int)(sx+((double)o+0.1)*sdxh+((double)n+0.1)*sdxv);rectX[1]=(int)(sx+((double)o+0.9)*sdxh+((double)n+0.1)*sdxv);rectX[2]=(int)(sx+((double)o+0.9)*sdxh+((double)n+0.9)*sdxv);rectX[3]=(int)(sx+((double)o+0.1)*sdxh+((double)n+0.9)*sdxv);rectY[0]=(int)(sy+((double)o+0.1)*sdyh+((double)n+0.1)*sdyv);

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论