




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
附錄A面向?qū)ο蟮姆治龇椒ㄔ诠こ滔到y(tǒng)分析中的應(yīng)用本文介紹了面向?qū)ο蟮姆治龇椒?,并給出了一種面向?qū)ο蟮姆治瞿P偷谋磉_(dá)方法。以液壓系統(tǒng)設(shè)計(jì)為工程應(yīng)用背景,探討了面向?qū)ο蟮姆治龇椒ㄔ诠こ滔到y(tǒng)分析中的應(yīng)用。按照類(lèi)-對(duì)象層、結(jié)構(gòu)層、主題層、屬性層和服務(wù)層五個(gè)層次分析了液壓系統(tǒng)的類(lèi)層次構(gòu)成及其連接與通信。一、面向?qū)ο蟮姆治龊?jiǎn)介:在大型軟件開(kāi)發(fā)項(xiàng)目中,無(wú)論是實(shí)時(shí)控制系統(tǒng)、數(shù)據(jù)庫(kù)系統(tǒng)、人工智能系統(tǒng),還是具體到自動(dòng)代碼生成,或擴(kuò)展到一個(gè)工廠的計(jì)算機(jī)集成制造系統(tǒng),都存在著一個(gè)共同的需求,就是在系統(tǒng)分析階段建立系統(tǒng)的信息模型。在眾多的系統(tǒng)分析方法中,面向?qū)ο蟮姆治觯∣OA)方法更接近于人類(lèi)的思維方式,正在被越來(lái)越多的系統(tǒng)分析人員使用。持面向?qū)ο笥^點(diǎn)的人認(rèn)為,計(jì)算機(jī)程序的結(jié)構(gòu)應(yīng)該與所需解決的問(wèn)題一致,而不是與某種分析方法保持一致。經(jīng)驗(yàn)表明,對(duì)任何軟件系統(tǒng)而言,其中最穩(wěn)定的成份是相應(yīng)問(wèn)題論域(PROBLEMDOMAIN)的成份。而系統(tǒng)出問(wèn)題通常也是由于問(wèn)題論域的某些成份。因此,對(duì)問(wèn)題論域進(jìn)行充分分析及準(zhǔn)確理解是保證系統(tǒng)穩(wěn)定的重要基礎(chǔ)。面向?qū)ο蠓治龇椒ㄊ墙⒃趯?duì)象及其屬性、類(lèi)屬及其成員、整體及其部分這些基本概念的基礎(chǔ)上。大英百科全書(shū)指出:“人類(lèi)在認(rèn)識(shí)和理解現(xiàn)實(shí)世界的過(guò)程中普遍運(yùn)用著三個(gè)構(gòu)造法則:1.區(qū)分對(duì)象及其屬性。例如,區(qū)分一棵樹(shù)和樹(shù)的大小或空間位置關(guān)系。2.區(qū)分整體對(duì)象及其組成部分。例如,區(qū)分一棵樹(shù)和樹(shù)枝。3.不同對(duì)象類(lèi)的形成及區(qū)分。例如,所有樹(shù)的類(lèi)和所有石頭的類(lèi)的形成和區(qū)分?!監(jiān)OA就是建立在以上三個(gè)常用法則的基礎(chǔ)上。OOA模型描述了表示某個(gè)特定論域中的對(duì)象,以及各種各樣的結(jié)構(gòu)關(guān)系和通信關(guān)系。OOA模型有兩個(gè)用途。首先,每個(gè)軟件都建立在特定的現(xiàn)實(shí)世界中,OOA模型就是用來(lái)形式化該現(xiàn)實(shí)世界的“視圖”。它建立起各種對(duì)象,分別表示軟件系統(tǒng)主要的組織結(jié)構(gòu)以及現(xiàn)實(shí)世界強(qiáng)加給軟件系統(tǒng)的各種規(guī)則和約束條件。其次,給定一組對(duì)象,OOA模型規(guī)定了它們?nèi)绾螀f(xié)同才能完成軟件系統(tǒng)所指定的工作。這種協(xié)同在模型中是以表明對(duì)象之間通信方式的一組消息連接來(lái)表示的。以上簡(jiǎn)單介紹了面向?qū)ο蟮姆治黾霸诒疚闹械谋硎痉椒?,下面將研究面向?qū)ο蟮姆治鲈谝簤合到y(tǒng)設(shè)計(jì)中的應(yīng)用:第一層,對(duì)象-類(lèi)層表示待開(kāi)發(fā)系統(tǒng)的基本構(gòu)造塊。對(duì)象都是現(xiàn)實(shí)世界中應(yīng)用論域概念的抽象。這一層是整個(gè)模型的基礎(chǔ)。圖符的外層邊界表示實(shí)例邊界,實(shí)際上它表明對(duì)象是非空的。而圖符的內(nèi)層邊界則表示類(lèi)邊界。有時(shí)可以定義一些不當(dāng)作程序塊來(lái)實(shí)現(xiàn)的對(duì)象,即只有類(lèi)邊界而沒(méi)有實(shí)例邊界。在某些情形下,定義這種對(duì)象是很有用的。我們將它們稱為模板類(lèi)或抽象類(lèi)。模板類(lèi)可以為結(jié)成較高級(jí)的聚合體提供一條方便的途徑。第二層,屬性層,對(duì)象的屬性和實(shí)例連接共同組成了OOA模型的屬性層。我們把對(duì)象所存儲(chǔ)的數(shù)據(jù)稱為對(duì)象的屬性。類(lèi)的實(shí)例之間互相約束,它們必須遵從應(yīng)用論域的某些限制條件或事務(wù)規(guī)則。例如,當(dāng)定金取消后,相應(yīng)的訂戶也應(yīng)該被取消,這可能是一項(xiàng)事務(wù)規(guī)則。我們稱這些約束為實(shí)例連接。第三層,服務(wù)層,對(duì)象的服務(wù)和消息通信組成了OOA模型的服務(wù)層。我們把對(duì)象所做的工作稱為服務(wù)或方法。系統(tǒng)的不同對(duì)象都分別執(zhí)行一定的工作或功能,它們之間通過(guò)消息通信,即所謂的協(xié)同,如圖中的箭頭所示。對(duì)象的服務(wù)及對(duì)象實(shí)例之間的消息通信共同組成了OOA模型的服務(wù)層。第四層,結(jié)構(gòu)層,該層負(fù)責(zé)捕捉特定應(yīng)用論域中的結(jié)構(gòu)關(guān)系。泛化---特化結(jié)構(gòu)獲得類(lèi)及成員組織,有助于刻畫(huà)問(wèn)題空間的類(lèi)-成員層次,它通過(guò)搜集公共特性并把這種特性擴(kuò)充到特例中來(lái)顯示現(xiàn)實(shí)世界事件的通用性及專用性。整體-部分結(jié)構(gòu)表達(dá)了人類(lèi)的一種基本組織方式,即自然的整體和部分的結(jié)構(gòu)關(guān)系,從而把一些部分的聚合構(gòu)造成整體。例如,一輛汽車(chē)由發(fā)動(dòng)機(jī)、傳動(dòng)裝置和剎車(chē)裝置組成。第五層,主題層,相當(dāng)于全局系統(tǒng)的子系統(tǒng)或子模型。由于OOA模型的結(jié)構(gòu)龐大而復(fù)雜,因此眾多的對(duì)象有時(shí)很難處理。于是,可以把對(duì)象歸到各個(gè)主題層中,可以把有關(guān)的對(duì)象用一個(gè)邊框框起來(lái)加以實(shí)現(xiàn)。附錄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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 航空航天技術(shù)基礎(chǔ)模擬試題卷
- 浙江國(guó)企招聘2025嘉興海鹽縣城市投資集團(tuán)有限公司招聘7人筆試參考題庫(kù)附帶答案詳解
- 2025浙江寧波市卓眾人力資源服務(wù)公司銷(xiāo)售業(yè)務(wù)人員專項(xiàng)招募20人筆試參考題庫(kù)附帶答案詳解
- 2025年中國(guó)葛洲壩集團(tuán)易普力股份有限公司禹州分公司招聘22人(河南)筆試參考題庫(kù)附帶答案詳解
- 膀胱治療儀試題及答案
- 2025上半年云南日?qǐng)?bào)報(bào)業(yè)集團(tuán)招聘34人筆試參考題庫(kù)附帶答案詳解
- 紡織品的面料對(duì)比與選用試題及答案
- 紡織行業(yè)內(nèi)審標(biāo)準(zhǔn)知識(shí)試題及答案
- 高標(biāo)準(zhǔn)農(nóng)田建設(shè)推動(dòng)鄉(xiāng)村振興戰(zhàn)略深入實(shí)施
- 貨車(chē)合伙合同協(xié)議書(shū)
- 2025年度考研政治馬克思主義政治經(jīng)濟(jì)學(xué)核心考點(diǎn)復(fù)習(xí)匯編
- 2025專利代理師筆試考試題庫(kù)帶答案
- 第3課《校園文化活動(dòng)我參與》教案 海燕版綜合實(shí)踐活動(dòng) 三年級(jí)下冊(cè)
- 2025年保密教育線上培訓(xùn)考試試題及答案
- 域名解析換編碼 課件 2024-2025學(xué)年人教版(2024)初中信息科技七年級(jí)上冊(cè)
- 整形美容醫(yī)院醫(yī)患溝通流程
- 大學(xué)生職業(yè)規(guī)劃大賽《運(yùn)動(dòng)康復(fù)專業(yè)》生涯發(fā)展展示
- 高樓遮光補(bǔ)償協(xié)議書(shū)范本
- 課題申報(bào)書(shū):生成式人工智能賦能高職教學(xué)變革研究
- 2025-2030專用車(chē)產(chǎn)業(yè)規(guī)劃及發(fā)展研究報(bào)告
- 2025屆百師聯(lián)盟高三聯(lián)考模擬預(yù)測(cè)(沖刺二)語(yǔ)文試題含答案
評(píng)論
0/150
提交評(píng)論