1
2
3
4
|
PACKETsimselbasisplotDEFINEStransform,setvalues,getvalues,getparameter,putparameter,newvalues,drawingarea,window,viewport,view,box,move,draw,mover,drawr,movecm,drawcm,movecmr,drawcmr,kreispunkte,circle,where:BOOL VARnewlimits:=TRUE,valuesnew:=TRUE,perspectiveprojektion:=FALSE;INT VARpixelhor,pixelvert;REAL VARdisplayhor,displayvert,sizehor,sizevert;drawingarea(sizehor,sizevert,pixelhor,pixelvert);displayhor:=real(pixelhor);displayvert:=real(pixelvert);REAL VARhminlimit:=0.0,hmaxlimit:=displayhor,vminlimit:=0.0,vmaxlimit:=displayvert,hmin:=0.0,hmax:=sizehor,vmin:=0.0,vmax:=sizevert,horrelation:=displayhor/sizehor,vertrelation:=displayvert/sizevert,relation:=sizehor/sizevert;ROW5ROW5REAL VARp:=ROW5ROW5REAL:(ROW5REAL:(1.0,0.0,0.0,0.0,0.0),ROW5REAL:(0.0,1.0,0.0,0.0,0.0),ROW5REAL:(0.0,0.0,1.0,0.0,0.0),ROW5REAL:(0.0,0.0,0.0,1.0,0.0),ROW5REAL:(0.0,0.0,0.0,0.0,1.0));ROW3ROW2REAL VARsized:=ROW3ROW2REAL:(ROW2REAL:(0.0,1.0),ROW2REAL:(0.0,1.0),ROW2REAL:(0.0,1.0));ROW2ROW2REAL VARlimitsd:=ROW2ROW2REAL:(ROW2REAL:(0.0,relation),ROW2REAL:(0.0,1.0));ROW4REAL VARanglesd:=ROW4REAL:(0.0,0.0,0.0,0.0);ROW2REAL VARobliqued:=ROW2REAL:(0.0,0.0);ROW3REAL VARperspectived:=ROW3REAL:(0.0,0.0,0.0);REAL VARsizehord:=sizehor,sizevertd:=sizevert;INT VARpixelhord:=pixelhor,pixelvertd:=pixelvert;INT VARi,j;REAL VARkreisschritt:=18.0;PROCkreispunkte(INT CONSTp):kreisschritt:=360.0/real(p)END PROCkreispunkte;BOOL OP=(ROW3ROW2REAL CONSTl,r):FORiFROM1UPTO3REP IFl[i][1]<>r[i][1]ORl[i][2]<>r[i][2]THEN LEAVE=WITH FALSE FI PER;TRUE END OP=;BOOL OP=(ROW2ROW2REAL CONSTl,r):FORiFROM1UPTO2REP IFl[i][1]<>r[i][1]ORl[i][2]<>r[i][2]THEN LEAVE=WITH FALSE FI PER;TRUE END OP=;BOOL OP=(ROW2REAL CONSTl,r):l[1]=r[1]ANDl[2]=r[2]END OP=;BOOL OP=(ROW3REAL CONSTl,r):l[1]=r[1]ANDl[2]=r[2]ANDl[3]=r[3]END OP=;BOOL OP=(ROW4REAL CONSTl,r):l[1]=r[1]ANDl[2]=r[2]ANDl[3]=r[3]ANDl[4]=r[4]END OP=;PROCwindow(BOOL CONSTdev):newlimits:=devEND PROCwindow;PROCwindow(REAL CONSTxmin,xmax,ymin,ymax):window(xmin,xmax,ymin,ymax,0.0,1.0)END PROCwindow;PROCwindow(REAL CONSTxmin,xmax,ymin,ymax,zmin,zmax):setvalues(ROW3ROW2REAL:(ROW2REAL:(xmin,xmax),ROW2REAL:(ymin,ymax),ROW2REAL:(zmin,zmax)),limitsd,anglesd,obliqued,perspectived)END PROCwindow;PROCviewport(REAL CONSThmin,hmax,vmin,vmax):setvalues(sized,ROW2ROW2REAL:(ROW2REAL:(hmin,hmax),ROW2REAL:(vmin,vmax)),anglesd,obliqued,perspectived)END PROCviewport;PROCview(REAL CONSTalpha):setvalues(sized,limitsd,ROW4REAL:(alpha,anglesd(2),anglesd(3),anglesd(4)),obliqued,perspectived)END PROCview;PROCview(REAL CONSTphi,theta):setvalues(sized,limitsd,ROW4REAL:(anglesd(1),sind(theta)*cosd(phi),sind(theta)*sind(phi),cosd(theta)),obliqued,perspectived)END PROCview;PROCview(REAL CONSTx,y,z):setvalues(sized,limitsd,ROW4REAL:(anglesd(1),x,y,z),obliqued,perspectived)END PROCview;setvalues(sized,limitsd,anglesd,obliqued,perspectived);PROCdrawingarea(REAL VARminh,maxh,minv,maxv):minh:=hminlimit;maxh:=hmaxlimit;minv:=vminlimit;maxv:=vmaxlimitEND PROCdrawingarea;BOOL PROCnewvalues:IFvaluesnewTHENvaluesnew:=FALSE;TRUE ELSE FALSE FI END PROCnewvalues;PROCgetparameter(ROW5ROW5REAL VARvalues):values:=p;END PROCgetparameter;PROCputparameter(ROW5ROW5REAL CONSTvalues):p:=values;END PROCputparameter;PROCgetvalues(ROW3ROW2REAL VARsize,ROW2ROW2REAL VARlimits,ROW4REAL VARangles,ROW2REAL VARoblique,ROW3REAL VARperspective):size:=sized;limits:=limitsd;angles:=anglesd;oblique:=obliqued;perspective:=perspectived;END PROCgetvalues;PROCsetvalues(ROW3ROW2REAL CONSTsize,ROW2ROW2REAL CONSTlimits,ROW4REAL CONSTangles,ROW2REAL CONSToblique,ROW3REAL CONSTperspective):drawingarea(sizehor,sizevert,pixelhor,pixelvert);displayhor:=real(pixelhor);displayvert:=real(pixelvert);IF NOTsamevaluesTHENvaluesnew:=TRUE;copyvalues;setviews;checkperspectiveprojektion;calclimits;changeprojektionFI.samevalues:sizehord=sizehorANDsizevertd=sizevertANDpixelhord=pixelhorANDpixelvertd=pixelvertANDsized=sizeANDlimitsd=limitsANDanglesd=anglesANDobliqued=obliqueANDperspectived=perspective.copyvalues:sizehord:=sizehor;sizevertd:=
sizevert;pixelhord:=pixelhor;pixelvertd:=pixelvert;hmaxlimit:=displayhor;vmaxlimit:=displayvert;hmax:=sizehor;vmax:=sizevert;horrelation:=displayhor/sizehor;vertrelation:=displayvert/sizevert;relation:=sizehor/sizevert;sized:=size;limitsd:=limits;anglesd:=angles;obliqued:=oblique;perspectived:=perspective.setviews:REAL VARdiagonale:=sqrt(angles[2]*angles[2]+angles[3]*angles[3]+angles[4]*angles[4]),projektion:=sqrt(angles[2]*angles[2]+angles[4]*angles[4]),sinp,cosp,sint,cost,sina,cosa;IFdiagonale=0.0THENsinp:=0.0;cosp:=1.0;sint:=0.0;cost:=1.0ELIFprojektion=0.0THENsinp:=angles[3]/diagonale;cosp:=projektion/diagonale;sint:=0.0;cost:=1.0ELSEsinp:=angles[3]/diagonale;cosp:=projektion/diagonale;sint:=angles[2]/projektion;cost:=angles[4]/projektionFI;REAL VARsinpsint:=sinp*sint,sinpcost:=sinp*cost,cospsint:=cosp*sint,cospcost:=cosp*cost,dx:=size[1][2]-size[1][1],dy:=size[2][2]-size[2][1],dz:=size[3][2]-size[3][1],normaz:=oblique[1],normbz:=oblique[2],normcx:=perspective[1]/dx,normcy:=perspective[2]/dy,normcz:=perspective[3]/dz;p:=ROW5ROW5REAL:(ROW5REAL:(cost/dx-cospsint/dx*normaz,-sinpsint/dx-cospsint/dx*normbz,0.0,-cospsint/dx*normcz,0.0),ROW5REAL:(-sinp/dy*normaz,cosp/dy-sinp/dy*normbz,0.0,-sinp/dy*normcz,0.0),ROW5REAL:(sint/dz+cospcost/dz*normaz,+sinpcost/dz+cospcost/dz*normbz,0.0,cospcost/dz*normcz,0.0),ROW5REAL:(-normcx,-normcy,0.0,1.0,0.0),ROW5REAL:(0.0,0.0,0.0,0.0,1.0));IFangles(1)=0.0THENsetalphaasyverticalELSEsina:=sind(angles(1));cosa:=cosd(angles(1))FI;FORjFROM1UPTO5REP REAL CONSTpj1:=p(j)(1);p(j)(1):=pj1*cosa-p(j)(2)*sina;p(j)(2):=pj1*sina+p(j)(2)*cosaPER.setalphaasyvertical:REAL VARr:=sqrt(p(2)(1)**2+p(2)(2)**2);IFr=0.0THENsina:=0.0;cosa:=1.0ELSEsina:=-p(2)(1)/r;cosa:=p(2)(2)/rFI.checkperspectiveprojektion:perspectiveprojektion:=perspective[3]<>0.0.calclimits:IFnewlimitsTHENcalctwodimextrema;IFalllimitssmallerthan2THENprozenteELSEzentimeterFI FI.calctwodimextrema:hmin:=maxreal;hmax:=-maxreal;vmin:=maxreal;vmax:=-maxreal;extrema(size[1][1],size[2][1],size[3][1],hmin,hmax,vmin,vmax);extrema(size[1][2],size[2][1],size[3][1],hmin,hmax,vmin,vmax);extrema(size[1][2],size[2][2],size[3][1],hmin,hmax,vmin,vmax);extrema(size[1][1],size[2][2],size[3][1],hmin,hmax,vmin,vmax);extrema(size[1][1],size[2][1],size[3][2],hmin,hmax,vmin,vmax);extrema(size[1][2],size[2][1],size[3][2],hmin,hmax,vmin,vmax);extrema(size[1][2],size[2][2],size[3][2],hmin,hmax,vmin,vmax);extrema(size[1][1],size[2][2],size[3][2],hmin,hmax,vmin,vmax).alllimitssmallerthan2:limits(1)(2)<2.0ANDlimits(2)(2)<2.0.prozente:hminlimit:=displayhor*limits(1)(1)/relation;hmaxlimit:=displayhor*limits(1)(2)/relation;vminlimit:=limits(2)(1)*displayvert;vmaxlimit:=limits(2)(2)*displayvert.zentimeter:hminlimit:=displayhor*(limits(1)(1)/sizehor);hmaxlimit:=displayhor*(limits(1)(2)/sizehor);vminlimit:=displayvert*(limits(2)(1)/sizevert);vmaxlimit:=displayvert*(limits(2)(2)/sizevert).changeprojektion:REAL VARsh:=(hmaxlimit-hminlimit)/(hmax-hmin),sv:=(vmaxlimit-vminlimit)/(vmax-vmin),dh:=hminlimit-hmin*sh,dv:=vminlimit-vmin*sv;FORjFROM1UPTO5REPp(j)(1):=p(j)(1)*sh;p(j)(2):=p(j)(2)*svPER;p(5)(1):=dh;p(5)(2):=dv.END PROCsetvalues;PROCtransform(REAL CONSTx,y,z,INT VARh,v):disablestop;IFperspectiveprojektionTHEN REAL CONSTw:=1.0/(x*p(1)(4)+y*p(2)(4)+z*p(3)(4)+1.0);h:=int((x*p(1)(1)+y*p(2)(1)+z*p(3)(1)+p(4)(1))*w+p(5)(1));v:=int((x*p(1)(2)+y*p(2)(2)+z*p(3)(2)+p(4)(2))*w+p(5)(2))ELSEh:=int(x*p(1)(1)+y*p(2)(1)+z*p(3)(1)+p(5)(1));v:=int(x*p(1)(2)+y*p(2)(2)+z*p(3)(2)+p(5)(2));FI;IFiserrorTHENh:=-1;v:=-1;clearerror;FI;enablestop;END PROCtransform;PROCextrema(REAL CONSTx,y,z,REAL VARhmin,hmax,vmin,vmax):REAL VARh,v;IFperspectiveprojektionTHEN REAL CONSTw:=1.0/(x*p(1)(4)+y*p(2)(4)+z*p(3)(4)+1.0);h:=(x*p(1)(1)+y*p(2)(1)+z*p(3)(1)+p(4)(1))*w;v:=(x*p(1)(2)+y*p(2)(2)+z*p(3)(2)+p(4)(2))*wELSEh:=(x*p(1)(1)+y*p(2)(1)+z*p(3)(1));v:=(x*p(1)(2)+y*p(2)(2)+z*p(3)(2))FI;IFh<hminTHENhmin:=hELIFh>hmaxTHENhmax:=hFI;IFv<vminTHENvmin:=vELIFv>vmaxTHENvmax:=vFI END PROCextrema;LET POS=STRUCT(REALx,y,z);POS VARpos:=POS
:(0.0,0.0,0.0);INT VARh:=0,v:=0;PROCbox:move(int(hminlimit+0.5),int(vminlimit+0.5));draw(int(hmaxlimit+0.5),int(vminlimit+0.5));draw(int(hmaxlimit+0.5),int(vmaxlimit+0.5));draw(int(hminlimit+0.5),int(vmaxlimit+0.5));draw(int(hminlimit+0.5),int(vminlimit+0.5))END PROCbox;PROCmove(REAL CONSTx,y):transform(x,y,0.0,h,v);move(h,v);pos:=POS:(x,y,0.0)END PROCmove;PROCdraw(REAL CONSTx,y):transform(x,y,0.0,h,v);draw(h,v);pos:=POS:(x,y,0.0)END PROCdraw;PROCmover(REAL CONSTx,y):transform(pos.x+x,pos.y+y,pos.z,h,v);move(h,v);pos:=POS:(pos.x+x,pos.y+y,pos.z)END PROCmover;PROCdrawr(REAL CONSTx,y):transform(pos.x+x,pos.y+y,pos.z,h,v);draw(h,v);pos:=POS:(pos.x+x,pos.y+y,pos.z)END PROCdrawr;PROCmovecm(REAL CONSTxcm,ycm):h:=int(xcm*horrelation+0.5);v:=int(ycm*vertrelation+0.5);move(h,v)END PROCmovecm;PROCdrawcm(REAL CONSTxcm,ycm):h:=int(xcm*horrelation+0.5);v:=int(ycm*vertrelation+0.5);draw(h,v);END PROCdrawcm;PROCmovecmr(REAL CONSTxcm,ycm):hINCRint(xcm*horrelation+0.5);vINCRint(ycm*vertrelation+0.5);move(h,v)END PROCmovecmr;PROCdrawcmr(REAL CONSTxcm,ycm):hINCRint(xcm*horrelation+0.5);vINCRint(ycm*vertrelation+0.5);draw(h,v)END PROCdrawcmr;PROCwhere(REAL VARx,y):x:=pos.x;y:=pos.yEND PROCwhere;PROCcircle(REAL CONSTr,from,to,INT CONSTpattern):REAL VARt:=from;INT VARi,j;transform(pos.x,pos.y,0.0,h,v);i:=h;j:=v;h:=i+int(horrelation*r*cosd(t));v:=j+int(vertrelation*r*sind(t));WHILEt<=toREPh:=i+int(horrelation*r*cosd(t));v:=j+int(vertrelation*r*sind(t));draw(h,v);tINCRkreisschrittPER;draw(h,v).END PROCcircle;ENDPACKETsimselbasisplot;
|