⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svgacc.txt

📁 本程序用于可视化窗口中运行tc下的程序,因为tc2.0不支持粘贴复制等常用的文件操作,不过该系统在输入中文时会有些小问题
💻 TXT
📖 第 1 页 / 共 5 页
字号:
               {
                 d2scale(3,i,i,trio,tri);
                 drwtri();
                 sdelay(2);
                 ertri();
               }
               for(i=128;i<=256;i+=4)
               {
                 d2scale(3,i,i,trio,tri);
                 drwtri();
                 sdelay(2);
                 ertri();
               }
               drwtri();
               getch();
               videomodeset(vmode);
               exit(0);
            }

            void drwtri(void)
            {
               d2translate(3,320,240,tri,tri2);
               drwline(1,10,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
               drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
               drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
               return;
            }

            void ertri(void)
            {
               d2translate(3,320,240,tri,tri2);
               drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);


                                                                         23







               drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
               drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
               return;
            }




















































                                                                         24







          D2TRANSLATE

            PROTOTYPE

            extern void far d2translate (int points, int xtrans, int
            ytrans, D2Point far *inary, D2Point far *outary)

            INPUT

            numpoints - number of points to be translated
            xtrans - distance to translate along X axis
            ytrans - distance to translate along Y axis
            inary - D2Point pointer to array containing points to
            translate

            OUTPUT

            no value returned
            outary - D2Point array of translated values

            USAGE

            D2TRANSLATE takes the two dimensional points given in inary
            and translates them by the specified number of pixels along
            each axis.  The results are returned in outary which can be
            the same as inary.  The function assumes that space for outary
            has been properly allocated.

            SEE ALSO

            D2ROTATE, D2SCALE

            EXAMPLE

            /*
             * shows d2translate works
             */

            #include <stdlib.h>
            #include <conio.h>
            #include "svgacc.h"

            D2Point tri[3];
            D2Point trio[3];
            D2Point tri2[3];

            void drwtri(void);
            void ertri(void);

            void main(void)
            {
               int vmode,i;

               vmode = videomodeget();


                                                                         25







               if (!whichvga())
                 exit(1);
               if (whichmem()<512)
                 exit(1);
               res640();
               trio[0].x = 0;
               trio[0].y = 0;
               trio[1].x = -80;
               trio[1].y = 60;
               trio[2].x = 80;
               trio[2].y = 60;
               drwtri();
               for(i=0;i<=100;i+=4)
               {
                 d2translate(3,i,i,trio,tri);
                 drwtri();
                 sdelay(2);
                 ertri();
               }
               for(i=100;i>=0;i-=4)
               {
                 d2translate(3,i,i,trio,tri);
                 drwtri();
                 sdelay(2);
                 ertri();
               }
               drwtri();
               getch();
               videomodeset(vmode);
               exit(0);
            }

            void drwtri(void)
            {
               d2translate(3,320,240,tri,tri2);
               drwline(1,10,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
               drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
               drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
               return;
            }

            void ertri(void)
            {
               d2translate(3,320,240,tri,tri2);
               drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
               drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
               drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
               return;
            }







                                                                         26







          D3PROJECT

            PROTOTYPE

            extern int far d3project (int points, ProjParameters far
            *params, D3Point far *inary, D2Point far *outary)

            INPUT

            numpoints - number of points to be projected
            params - pointer to ProjParameters structure containing
            parameters used in projection
               eyex, eyey, eyez - 3D location of viewer
               scrd - distance from viewer to projection screen
               theta - angle from positive 3D X axis to viewing direction
               phi - angle from positive 3D Z axis to viewing direction
            inary - D3Point pointer to array containing points to project

            OUTPUT

            Returns 1 if successful, 0 if any one point failed.
            outary - D2Point array of projected values

            USAGE
                                +Z axis
                                   |                   /\
                                   |                  /  \
                                   |            !     \ * \
                                   |            !......X: /
                                   |            ! Phi / \/
                                   |            !    /  :
                                   |            !   /   :
                                   |            !  /    :
                                   |       EyeX ! /ScrD :
                                   |       EyeY !/      :
                                   |       EyeZ *- - - -:- - - - -
                                   |           / `      :
                                   |          /   `     :
                                   |         /      `   :
                                   |        /      ---` :
                                   |       /___----
                                   |      /     Theta
                                   |
                                   |_____________________________+Y axis
                                   /
                                  /
                                 /
                                /
                               /
                              /
                             /
                         +X axis




                                                                         27







            D3PROJECT projects a specified number, numpoints, of three
            dimensional points starting at inary into two dimensions
            according to the parameters in params.  The two dimensional
            points are stored in outary.  The function assumes space for
            outary has been properly allocated.  The location of the
            viewer in this three dimensional space is given by eyex, eyey,
            eyez in the ProjParameters structure.  The direction the
            viewer is facing is specified with scrd, theta, phi in the
            ProjParameters structure using spherical coordinates.  A
            virtual set of axes parallel to the true axes are placed at
            the viewer's location.  scrd is the distance from the viewer
            to the center of the projection screen, i.e. the currently
            defined viewport on the monitor's screen.  Theta is the angle
            in the virtual X-Y plane from the virtual X axis to the
            projection screen.  Positive angles rotate counter-clockwise
            in the X-Y plane.  Lastly, the angle of elevation above or
            below the virtual X-Y plane is given by phi.  Positive angles
            direct viewing above the plane; negative below.

            If a point is projected to a location behind the viewer, i.e.
            on the side of the viewer opposite the projection screen,
            D3PROJECT returns a zero indicating one or more failed points.
            The returned values of the X and Y for failed points will be -
            32768 to make them easily identified.

            SEE ALSO

            D3ROTATE, D3TRANSLATE, D3SCALE, FILLCONVEXPOLY, SETVIEW

            EXAMPLE

            /* shows d3project works */
            #include <stdlib.h>
            #include <conio.h>
            #include "svgacc.h"

            D2Point plot[8];
            void drwcube(void);

            void main(void)
            {
               int vmode,i,dummy;
               ProjParameters proj;
               D3Point cube[8] = { { 100,-100, 100},
                                { 100,-100,-100},
                                { 100, 100,-100},
                                { 100, 100, 100},
                                {-100,-100, 100},
                                {-100,-100,-100},
                                {-100, 100,-100},
                                {-100, 100, 100}};

               vmode = videomodeget();
               if (!whichvga())


                                                                         28







                 exit(1);
               if (whichmem()<512)
                 exit(1);
               res640();
               proj.eyex = -1040;
               proj.eyey = -600;
               proj.eyez = -1200;
               proj.scrd = 1700;
               proj.theta = 30;
               proj.phi = 45;
               dummy = d3project(8,&proj,cube,plot);
               drwcube();
               getch();
               videomodeset(vmode);
            }

            void drwcube(void)
            {
               int i;

               for(i=0;i<=2;i++)

               drwline(1,10,plot[i].x,plot[i].y,plot[i+1].x,plot[i+1].y);
               drwline(1,10,plot[3].x,plot[3].y,plot[0].x,plot[0].y);
               for(i=4;i<=6;i++)

               drwline(1,10,plot[i].x,plot[i].y,plot[i+1].x,plot[i+1].y);
               drwline(1,10,plot[7].x,plot[7].y,plot[4].x,plot[4].y);
               for(i=0;i<=3;i++)

               drwline(1,10,plot[i].x,plot[i].y,plot[i+4].x,plot[i+4].y);
               return;
            }























                                                                         29







          D3ROTATE

            PROTOTYPE

            extern void far d3rotate (int points, int xorigin, int
               yorigin, int zorigin, int zrang, int yrang, int xrang,
               D3Point far *inary, D3Point far *outary)

            INPUT

            numpoints - number of points to be rotated
            xorigin, yorigin, zorigin - center of rotation
            zrang - angle of rotation about the Z axis
            yrang - angle of rotation about the Y axis
            xrang - angle of rotation about the X axis
            inary - D3Point pointer to array containing points to rotate

            OUTPUT

            no value returned
            outary - D3Point array of rotated values

            USAGE

            D3ROTATE takes the three dimensional points given in inary and
            rotates them by the specified angles about xorigin, yorigin,
            zorigin.  The results are returned in outary which can be the
            same as inary.  A virtual set of axes are placed at the origin
            of rotation and rotation takes place about these axes.  A
            positive angle causes a counter-clockwise rotation from the
            positive X axis to the positive Y axis.  The function assumes
            space for outary has been properly allocated.

            SEE ALSO

            D3PROJECT, D3SCALE, D3TRANSLATE

            EXAMPLE

            /*
             * shows d3rotate works
             */

            #include <stdlib.h>
            #include <conio.h>
            #include "svgacc.h"

            D2Point plot[8];

            void drwcube(void);

            void main(void)
            {
               int vmode,i,dummy;


                                                                         30







               ProjParameters proj;
               D3Point rcube[8];
               D3Point cube[8] = { { 100,-100, 100},
                                { 100,-100,-100},
                                { 100, 100,-100},
                                { 100, 100, 100},
                                {-100,-100, 100},
                                {-100,-100,-100},
                                {-100, 100,-100},
                                {-100, 100, 100}};

               vmode = videomodeget();
               if (!whichvga() || (whichmem() < 512))
                 exit(1);
               res640();

               proj.eyex = -1040;
               proj.eyey = -600;
               proj.eyez = -1200;
               proj.scrd = 1700;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -