面向?qū)ο蟮姆治龇椒ㄔ诠こ滔到y(tǒng)分析中的應用及魔方源代碼-Java-Applet小程序_第1頁
面向?qū)ο蟮姆治龇椒ㄔ诠こ滔到y(tǒng)分析中的應用及魔方源代碼-Java-Applet小程序_第2頁
面向?qū)ο蟮姆治龇椒ㄔ诠こ滔到y(tǒng)分析中的應用及魔方源代碼-Java-Applet小程序_第3頁
面向?qū)ο蟮姆治龇椒ㄔ诠こ滔到y(tǒng)分析中的應用及魔方源代碼-Java-Applet小程序_第4頁
面向?qū)ο蟮姆治龇椒ㄔ诠こ滔到y(tǒng)分析中的應用及魔方源代碼-Java-Applet小程序_第5頁
已閱讀5頁,還剩21頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

附錄A面向?qū)ο蟮姆治龇椒ㄔ诠こ滔到y(tǒng)分析中的應用本文介紹了面向?qū)ο蟮姆治龇椒?,并給出了一種面向?qū)ο蟮姆治瞿P偷谋磉_方法。以液壓系統(tǒng)設(shè)計為工程應用背景,探討了面向?qū)ο蟮姆治龇椒ㄔ诠こ滔到y(tǒng)分析中的應用。按照類-對象層、結(jié)構(gòu)層、主題層、屬性層和服務(wù)層五個層次分析了液壓系統(tǒng)的類層次構(gòu)成及其連接與通信。一、面向?qū)ο蟮姆治龊喗椋涸诖笮蛙浖_發(fā)項目中,無論是實時控制系統(tǒng)、數(shù)據(jù)庫系統(tǒng)、人工智能系統(tǒng),還是具體到自動代碼生成,或擴展到一個工廠的計算機集成制造系統(tǒng),都存在著一個共同的需求,就是在系統(tǒng)分析階段建立系統(tǒng)的信息模型。在眾多的系統(tǒng)分析方法中,面向?qū)ο蟮姆治觯∣OA)方法更接近于人類的思維方式,正在被越來越多的系統(tǒng)分析人員使用。持面向?qū)ο笥^點的人認為,計算機程序的結(jié)構(gòu)應該與所需解決的問題一致,而不是與某種分析方法保持一致。經(jīng)驗表明,對任何軟件系統(tǒng)而言,其中最穩(wěn)定的成份是相應問題論域(PROBLEMDOMAIN)的成份。而系統(tǒng)出問題通常也是由于問題論域的某些成份。因此,對問題論域進行充分分析及準確理解是保證系統(tǒng)穩(wěn)定的重要基礎(chǔ)。面向?qū)ο蠓治龇椒ㄊ墙⒃趯ο蠹捌鋵傩?、類屬及其成員、整體及其部分這些基本概念的基礎(chǔ)上。大英百科全書指出:“人類在認識和理解現(xiàn)實世界的過程中普遍運用著三個構(gòu)造法則:1.區(qū)分對象及其屬性。例如,區(qū)分一棵樹和樹的大小或空間位置關(guān)系。2.區(qū)分整體對象及其組成部分。例如,區(qū)分一棵樹和樹枝。3.不同對象類的形成及區(qū)分。例如,所有樹的類和所有石頭的類的形成和區(qū)分?!監(jiān)OA就是建立在以上三個常用法則的基礎(chǔ)上。OOA模型描述了表示某個特定論域中的對象,以及各種各樣的結(jié)構(gòu)關(guān)系和通信關(guān)系。OOA模型有兩個用途。首先,每個軟件都建立在特定的現(xiàn)實世界中,OOA模型就是用來形式化該現(xiàn)實世界的“視圖”。它建立起各種對象,分別表示軟件系統(tǒng)主要的組織結(jié)構(gòu)以及現(xiàn)實世界強加給軟件系統(tǒng)的各種規(guī)則和約束條件。其次,給定一組對象,OOA模型規(guī)定了它們?nèi)绾螀f(xié)同才能完成軟件系統(tǒng)所指定的工作。這種協(xié)同在模型中是以表明對象之間通信方式的一組消息連接來表示的。以上簡單介紹了面向?qū)ο蟮姆治黾霸诒疚闹械谋硎痉椒?,下面將研究面向?qū)ο蟮姆治鲈谝簤合到y(tǒng)設(shè)計中的應用:第一層,對象-類層表示待開發(fā)系統(tǒng)的基本構(gòu)造塊。對象都是現(xiàn)實世界中應用論域概念的抽象。這一層是整個模型的基礎(chǔ)。圖符的外層邊界表示實例邊界,實際上它表明對象是非空的。而圖符的內(nèi)層邊界則表示類邊界。有時可以定義一些不當作程序塊來實現(xiàn)的對象,即只有類邊界而沒有實例邊界。在某些情形下,定義這種對象是很有用的。我們將它們稱為模板類或抽象類。模板類可以為結(jié)成較高級的聚合體提供一條方便的途徑。第二層,屬性層,對象的屬性和實例連接共同組成了OOA模型的屬性層。我們把對象所存儲的數(shù)據(jù)稱為對象的屬性。類的實例之間互相約束,它們必須遵從應用論域的某些限制條件或事務(wù)規(guī)則。例如,當定金取消后,相應的訂戶也應該被取消,這可能是一項事務(wù)規(guī)則。我們稱這些約束為實例連接。第三層,服務(wù)層,對象的服務(wù)和消息通信組成了OOA模型的服務(wù)層。我們把對象所做的工作稱為服務(wù)或方法。系統(tǒng)的不同對象都分別執(zhí)行一定的工作或功能,它們之間通過消息通信,即所謂的協(xié)同,如圖中的箭頭所示。對象的服務(wù)及對象實例之間的消息通信共同組成了OOA模型的服務(wù)層。第四層,結(jié)構(gòu)層,該層負責捕捉特定應用論域中的結(jié)構(gòu)關(guān)系。泛化---特化結(jié)構(gòu)獲得類及成員組織,有助于刻畫問題空間的類-成員層次,它通過搜集公共特性并把這種特性擴充到特例中來顯示現(xiàn)實世界事件的通用性及專用性。整體-部分結(jié)構(gòu)表達了人類的一種基本組織方式,即自然的整體和部分的結(jié)構(gòu)關(guān)系,從而把一些部分的聚合構(gòu)造成整體。例如,一輛汽車由發(fā)動機、傳動裝置和剎車裝置組成。第五層,主題層,相當于全局系統(tǒng)的子系統(tǒng)或子模型。由于OOA模型的結(jié)構(gòu)龐大而復雜,因此眾多的對象有時很難處理。于是,可以把對象歸到各個主題層中,可以把有關(guān)的對象用一個邊框框起來加以實現(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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論