SOLID - Virginia Tech · John W. W1d1, Ch1ir11n V'" Dennis Jones Robert P. Schubert...

Preview:

Citation preview

A SOLID J:!-.OR

MOJ::>£e.:L, I NG Pl~OGRAM DESTGNERS

by

Patrick Scott Zeigler

Thesis submitted to the Faculty of the Virginia Polytechnic and State University

in partial fulfillment of the requirements for the degree of

MASTER OF ARCHITECTURE

APPROVED

P < >« l"C

John W. W1d1, Ch1ir11n

V'" Dennis Jones Robert P. Schubert

February, 1988

Blacksburg, Virginia

A SOLID FOR

MODELING PROGRAM DESIGNERS

by

Patrick Scott Zeigler

Committee Chairman : John W. Wade Architecture

(ABSTRACT)

The personal computer is rapidly finding its way

into the architectural working environment, at this

time however it is used mostly as a drafting tool. This

thesis is an investigation into programing that would

allow the computer to become a design tool.

The issues that are dealt with in this thesis

include an easy to use user interface that will not

inhibit the design process, and develop a system that

will allow design changes and additions to a model in a

three dimensional sketch like ability.

Three dimensional models of paper, clay, wood and

other materials have been used to create designs, and

aid the designer in making decisions. This type of

medium is difficult to make changes, and because of the

scale of such materials it becomes difficult to work on

interior spaces, thus more attention is usually placed

on the exterior design. With the use of the computer

these limitations may be eliminated, and the designer

may create a design from any perspective or view point.

ACKNOWLEDGEMENTS

I would like to offer a special thanks to Robert

Schubert, Dennis Jones and John Wade for their support and

advice throughout this study. I would also like to

recognize John and Dennis's work on the computer that has

inspired me to produce this thesis.

A warm appreciation is extended to my parents for

their support and sacrifices that made this study

possible.

Finally, I am most grateful for

precious loved ones.

iii

my most

TABLE OF CONTENTS

INTRODUCTION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......... 1

MODELING DESIGN PROCESS ............................. 5

GENERAL OVERVIEW OF SYSTEM .......................... 10

Setup .......................................... 12

Translation Function ........................... 14

Drawing Function ............................... 17

Main Menu Functions ............................ 19

Main Menu Diagram ......................... 20

Dimension Functions ....................... 21

Solids Menu ............................... 24

Modeling Menu ............................. 32

Rotation Functions .................... 34

Faceting Function ..................... 37

Gouraud Shading ...................... 40

Constant Shading ..................... 42

Translucency. . . . . . . . . . . . . . . . . . . . . . . . . 44

Scaling .............................. 49

Centering ............................ 51

Origin Set. . . . . . . . . . . . . . . . . . . . . . . . . . . 51

Viewport. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

Color ................................ 58

Remove Object ........................ 59

iv

Wind ... -,ws .............................. 62

Files ................................ 64

~,:::!'JC L US IONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . '3 f,

B~BLIOGRAPHY... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

APPENDIX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 0

VITA ............................................... 322

v

LIST OF DIAGRAMS

Modeling Design Diagram ............................. 7

General Overview Diagram ............................ 10

General Program Structure .......................... 11

Setup Diagram ....................................... 13

Translation Function. . . . . . .......................... 14

Translation Key Pad ................................. 16

Drawing Function Diagram ............................ 18

Main Menu Diagram .................................... 20

Dimension Functions .................................. 21

Dimension Functions Diagram .......................... 23

Solids Menu Diagram .................................. 26

Cursor Function Diagram .............................. 27

Command List Diagram ................................. 30

Composite Solids Functions ........................... 31

Modeling Menu Branches .............................. 33

Path of X Axis Rotation ............................. 36

Path For Facet Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Path For Gouraud Shading Functions . . . . . . . . . . . . . . . . . 41

Path For Constant Shading Functions . . . . . . . . . . . . . . . . 43

Translucency Functions Path ......................... 48

Path For Scale ...................................... 50

Command List Example For Modeling Origin . . . . . . . . . . . 52

Path For Modeling Origin . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

View Port Function Diagram .......................... 56

vi

Color Funtion Path. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Removal of Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

Point Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Windows.............................. . . . . . . . . . . . . . . 63

File Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

vii

INTRODUCTION:

In the last few years the introduction of the

Personal computer has brought Computer Aided Design (CAD)

to the small office and home. As the trend continues in

the next few years we will have mainframe power available

in the Personal Computer. Already many hardware

developers have created plug-in boards with a very fast

drawing speed, and call up graphic functions in firmware.

With the introduction of these boards greater speed, and

more flexibility in programing will be achieved.

At this time there are a great many three dimensional CAD

programs available, many are well suited for engineers,

and draftsmen but there are few that take into account the

needs of the designer. The designer's needs are much

different than that of the draftsman or engineer. The

designer needs a flexible program to use in case of

changes, and a visual program with the ability to observe

and compare. Because designers tend to be visual,

visualization is primary. Aid from the computer will make

the vision of the designer a reality in a matter of

minutes. If the designer is not satisfied with a design

then changes can be made neatly and quickly. The computer

gives instant feedback, which can speed up the entire

design process.

1

2

Three dimensional models are an essential tool for

creating designs; however, there are few methods available

that create 3D models quickly. Now with the introduction

of CAD, models are created, transformed, and viewed from

any perspective. CAD has an advantage in that the model

can be viewed from the inside out as well as the outside

in. This will aid the designer in creating new concepts

and better integration of ideas. At the moment there are

several limitations that exist before CAD can be used as a

designing tool. The first and most important being that

most designers are unfamiliar with the use of computers.

Second most programs on the market today are very

difficult to learn and work with. Once the programs

become more orientated to designers and become easier to

use, then more designers will turn to CAD for their

designing needs.

The purpose of this thesis is to create a solid

modeling program that can be used to create architectural

designs, jewelry, furniture and 3D art forms on the

computer.

3

By developing the design program the following

objectives should be accomplished:

Create a 3D design program for my personal use.

Develop a driver for the Matrox SM-640 graphics board.

Develop skills to understand how to program other

graphics boards on the market.

Develop skills in the C programing language.

Gain a better understanding of the computer operating

system (DOS).

Learn general computing skills.

Gain a better understanding of Computer Aided Design.

Be more aware of available computer hardware.

4

The scope of the thesis includes only 3D solid

modeling at this time. Elements that create a model are

handled in the way one would construct a block type model.

The programs methods of designing a model are similar to

that of a sketch book. A designer sketches are not so

concerned with exact dimensions, but more with the

relationships of parts. Changes may be made easily so the

designer can visualize a wider range of possibilities. The

designer has the ability to program in exact dimensions;

however, one of the strengths of the program is the

ability to allow the designer to also make visual

judgments, as in the sketch book. Therefore this program

should not be seen as a drafting tool, but a sketch tool.

MODELING DESIGN PROCESS :

One of the main aspects of this program is its ability

to allow the designer to test the relationships between

elements before making a commitment to their existence in

the work space. This is one of the computers strong

points, but is not fully utilized in most existing CADD

programs. Most other modeling mediums are not as flexible

as well. During the design process these changes and

comparisons are essential to allow

range of possibilities. If the

flexible, that inflexibility may

process.

the designer a full

drawing medium is not

influence the design

The program begins by presenting the designer with an

empty work space, this work space may be increased or

decreased in size at any time. Once the work space as been

defined a location indicator called a cursor is shown at

the origin 0.0, 0.0, 0.0 which is located at the center of

the viewport. The designer is then automatically put into

the object design phase, it is the main working

environment. The object design phase includes:

5

6

Volume Definition --Defines primitive, swept solid, extruded solids and composites

Translation --Defines the location of an object

Solid Description --Defines color, translucency, facets and shading

Transformation

Revaluate

--Defines Modeling transformations that effect the object

--Deletes objects from the work space

These commands allow the designer to move, transform

and define objects in three dimensional space before

making a commitment to include that object in the work

space. In this phase the object will appear only in

wireframe. While in the Comparison Testing phase the

object may be compared with existing objects in the model.

From there the designer enter into the Evaluation Phase.

At this point the designer may accept or reject the

present configuration. If the configuration is

unacceptable the designer may continue with the Object

Creation Phase. If the model is satisfactory the Model

Creation Phase is activated by pressing the space bar"

and the object with all of its attributes is drawn to the

screen and added to the modeling file. The Revaluate Phase

allows the designer to go back and remove any object that

has been added to the model.

7

MODELING DESIGN DIAGRAM

jvoLUME

I SOLID

MODELING WORKSPACE DISPLAY I

.-------------v---~~--~ LOCATION INDICATOR DISPLAY <-------~

(CURSOR)

OBJECT CREATION PHASE

DEFINITION~ I ~ TRANSLATION

v

DESCRIPTION~ ~ TRANSFORMATION

v

COMPARISON TESTING PHASE

v EVALUATION PHASE

ACCEPT <-t->j REJECT i------------->

..---v-----. REVALUATE -v v-~------~~

OBJECT DELETION a: subtracts object

from model ------->-->

v----------------------. MODEL CREATION PHASE

a: draws object b: adds object to model >------->

GENERAL OVERVIEW OF SYSTEM

The program begins by entering automatically into the

main function. It then defines all global variables, and

sets all graphic attributes, these attributes

include: window size viewport size viewing reference point clipping planes viewing distance lighting direction and intensity shading type color look up table

Once the attributes are set they are stored in a file

called SETUP.D . SETUP.D is called up whenever there are

any changes made to the setup attributes. The main

function also creates COMMAND.D , this is the active work

file, it will contain location of primitives, objects,

modeling transformations, lighting attributes and color

used in creating a model. SETUP.D and COMMAND.D together

make up the Command List, which is used to recreate the

model at another time.

8

Once the main function creates the command list files

it then opens up the keyboard function which gives access

to cursor, drawing and main menu functions, the user will

remain inside the main and keyboard function until the

user exits the system.

The cursor function draws on the screen a 3D

cross-hair that locates the current X, Y,and Z locations.

If a primitive or composite object is chosen the cursor

will take the shape of that object, and draw a fully

shaded representation of that object, once the drawing

command is activated. The drawing function also opens the

command list file and sends drawing attributes to the file

along with the chosen object. After these commands are

sent to the file a permanent work file is created, and the

file is closed. The program then enters back into the

keyboard function, and waits for another input command.

10

GENERAL OVERVIEW DIAGRAM:

MAIN FUNCTION { see setup diagram } a: defines and gives value to variables b: turns on graphics screen c: sets modeling attributes d: opens command list files e: gives access to keyboard function f: displays coordinates g: calls file module to save command list < h: exits to operating system

> KEYBOARD FUNCTION a: exits back to main function b: allows access to drawing and cursor

functions give access to main menus function

MAIN MENUS > a: includes main menus that branch to

sub-menus {see menu diagram } exits back to keyboard function

> draws current cursor shape writes solid configuration and modeling attributes to command list file

11

&ENERAl PRO&RAlt STRUCTURE :

cuR50Rl FUNCTIONS I

: "AIN FUNCTION : I • I i

i KEYBOARD FUNCTION I I

I v---, I "AIN "ENU I i BRANCHES

I DRA~ml I FUNCTIONS ! I .

I

r---V : TRANSLATION ~ FUNCTIONS !

I 1

l11ne:s10N souDsl lnooE~INB I OllI:IN I 'vm;oRr coLiiRl ! REn;V!l m;Oil r-r:LEI 'FUNCTION "ENU "ENU SET ftENU "ENU.. ! i OBJECT I "ENU i I ftENU i

ROTITE orgl+gnd IRDTA!E I i ~ IEYE ;IEN ! ! REC;IVE i 10 ~ G orgl-irid IROIA;E Y i !REDl I PLAN i ! SEND

'----..------' ~'

-....----- . I I I

or9Y-9rid DISTANCE I I &REEN I l"ULTIYIENJ I

IWLTIPLE

12

SRTUP FUNCTIONS:

The first part of the Main Function consists of a

function that defines all global variables used in the

program. Once the variables have been defined, they are

then assigned values, and set to the modeling attribute

function, which sets the graphic screen to the assigned

values. The program then creates two files SETUP.D and

COMMAND.D SETUP.D is responsible for all initial

attributes and viewing commands. COMMAND.D is responsible

to record all changes of the initial attributes and

additions of objects with there locations. Together they

are called the Command List. The Command List when passed

through the program will recreate any drawing or model

previously created on the screen.

After the Command List files have been set up the

program enters into the menu setup function. This function

displays the main menus accessible from the keyboard. At

this point the program enters into the keyboard function

which wait for the users input. The keyboard function is

the most active function in the program, and can branch to

most any other function in the program. The main branches

include: menu branch, translation branch, and drawing

branch.

13

SETUP DIAGRAM:

MAIN FUNCTION ..--~~~~-v~~~~~---.

VARIABLE DEFINITIONS I

.--~~~~~~~-v~~~~~~~~---.

SET MODELING ATTRIBUTES a: set command list to ASCII b: clear screen c: set text window position d: test window on e: display graphics screen f: set view-port size g: set window size h: set projection angle i: set viewing distance j: set hither clipping plane k: set yon clipping plane 1: enable light source m: set light attributes n: set drawing accuracy o: set shade type p: set viewing operations q: set viewing reference point r: set X axis view s: set Y axis view t: set Z axis view u: set color look-up table v: set color w: reset modeling matrix

I ..--~~~~~~-v~~~~~~~~~

OPEN COMMAND LIST FILES SETUP.D

COMMAND.D I

--~~~~~~-v~~~~~~~~~

STORE MODELING ATTRIBUTES IN SETUP.D

I ..--~~~~~~-v~~~~~~~~~

DISPLAY MAIN MENU I v

KEYBOARD FUNCTION

14

TRANSLATION FUNCTION:

One of the most important and most used functions is

the Translation Function it allows the user to move an

object freely on the screen, calculate distance from the

last entry and stores X, Y and Z locations. The

Translation function is actually a group of separate

subfunctions that are accessed through the "num" key pad.

Each key will activate a specific function that will move

the object in a particular direction, they are as follows:

KEY FUNCTION

moves z axis negative 0 moves z axis positive 1 moves x axis negative & y axis negative 2 moves y axis negative 3 moves x axis positive & y axis negative 4 moves x axis negative 5 6 moves x axis positive 7 moves x axis negative & y axis positive 8 moves y axis positive 9 moves y axis positive & x axis positive

decrease grid space + increases grid space

15

TRANSLATION "ON" KEY PAD FUNCTIONS

move (Y+) v <~~~~(X+,Y+)

(Y+),(X-)--~ ~~I 1 ~~~~~move (X+)

7~~~~~~~-~ ~ EJ ~---decrease grid space

( x-)' Y-)--;11 ~ E:+-+-+--(X+)' (Y-)

move CY-)

lo _.-JCJ <~-increase grid space I

move {Z+) L.__.roove (Z-)

Each time a key is pressed it will automatically move

the cursor or object in the chosen direction. At the

bottom of the screen there is a constant read out of the

present coordinate location, as well as the last modeling

origin entered.

COORDINATE INFORMATION

XD=0.00 X=0.00

YD=0.00 Y=0.00

ZD=0.00 Z=0.00

ROTATION INFORMATION

RX=O:O RY=O:O RZ=O:O RX=O:O RY=O:O RZ=O:O

Once the proper coordinates have been located the

space" bar should be pressed, this will enter into the

Drawing Function, and record the object and its location.

The Command used for translation is MDTRAN rx, ry, rz. The

rx, ry and rz represent relative X, Y and Z coordinates.

For example : MDTRAN 50.0, 0.0, 0.0 will move the drawing

point to 50.0, 0.0, 0.0. If it is entered twice the active

point would be 100.0, 0.0, 0.0.

16

TRANSLATION FUNCTION DIAGRAM

"PRESS KEY"

o--; decrease grid size grid 1 ~>->

E}-; increase grid size grid + 1 ~>->

&-~ x + grid, MDT RAN grid, 0.0, 0. 0 ~>->

E}-; x - grid, MDT RAN -grid, 0.0, 0. 0 ~>->

&-; y + grid, MDT RAN 0.0, grid, 0. 0 ~>->

~~ y - grid, MDT RAN 0.0, -grid, 0.0~>->

~; z + grid, MDT RAN 0.0, 0.0, grid~>->

o-; z - grid, MDT RAN o.o. 0. 0, -grid~>

~;x-.Y+grid, MD TRAN -grid, grid, 0. 0 ~>->

~~x+.Y+grid. MDT RAN grid, grid, 0. 0 ~>->

~~X-,Y-grid, MDT RAN -grid, -grid, 0. 0 ~>->

~~X+,Y-grid, MDT RAN grid, -grid, 0. 0 ~>->

~;x+,Y+grid, MD TRAN grid, grid, 0.0~>

17

DRAWING FUNCTION

The Drawing function is very closely tied to the

Translation Function, Cursor Function and Main Menu

functions. Whenever a change in status of the

coordinates, cursor shape or modeling attributes are made,

the drawing function records these changes in the Command

List. After a Command List of objects and modeling

attributes is created, the model can be recreated at

another time. The Drawing Function and Main Menu functions

act together to const~uct the Command list. The Drawing

Function is activated by pressing the "Space" bar, once

this is done the XOR drawing mode is turned off and the

shading attributes are set. After this is accomplished the

cursor Flag is checked to see which primitive or solid is

to be drawn at the active coordinate location. Next the

rotation attributes are arranged so that the proper order

of execution will take place. Then COMMAND.D file is

opened and the solid along with its modeling attributes is

written to the file. If any rotation or scaling attributes

are active the modeling matrix most be reset to the

default values, This is because rotation and scaling

effects the entire modeling matrix not just the object as

it may appear when running the program.

18

DRAWING FUNCTION DIAGRAM :

..--~~~~~v~~~~~~~

turns off RUBBERBAND model I

r-~~~~~v~~~~~~-

s e ts shading mode on I

..--~~~~~v~~~~~~~

checks cursor flag a: if 0 then Cross hair b: if 1 then BLOCK c: if 2 then CYLINDER d: if 3 then TUBE e: if 4 then SPHERE f: if 5 then TORUS g: if 6 then CONE h: if 7 then WEDGE i: if 8 Then CREATED

I ...--~~~~~v~~~~~~~

opens COMMAND LIST file I

~~~~~-v~~~~~~-

o r gan i z es MODELING TRANSFORMATIONS

in order of execution I

~~~~~-v~~~~~~~

sends modeling attributes to COMMAND LIST

I ~~~~~~v~~~~~~~

sends cursor shape to COMMAND LIST

I ..--~~~~~v~~~~~~~

sends reverse order of MODELING TRANSFORMATIONS

to COMMAND LIST I I ..... , _<_C_L_O_SE_S_C_O~-MA_N_D_F_I_L_E _ __,

EXAMPLE: MDROTX 90 MD ROTZ 120 MDROTY 180

INCLUDES: SCALE ROTATION

INCLUDES: PRIMITIVES SWEPT SOLID COMPOSITES

EXAMPLE: MDROTY 180 MD ROTZ 120 MDROTX 90

19

MAIN MKNU FUNCTIONS:

From the Keyboard Function eight main menus or

functions are accessible, and they represent eight

specific groups of functions that are used in the creation

of a model. Each group is represented in an abbreviated

form at the top of the screen. {see fig below}

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

The menus and functions are arranged in an order of

most frequent use. Each four letter abbreviation

represents the following function or menu.

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

DIMENSION FUNCTION SOLID MENU MODELING MENU MODELING ORIGIN FUNCTION VIEW MENU COLOR MENU REMOVE OBJECT FUNCTION SET PLAN, ELEVATION OR MULTIPLE WINDOW SENDS OR RECEIVES WORKING FILES ERASES THE ENTIRE SCREEN

The main menus will then branch to more specific

sub-menus. Many of the major functions such as translation

and drawing are even accessible from within the sub menus.

The sub-menus will always return back to the main menu by

pressing "Esc".

MAIN MENU DIAGRAM

KEYBOARD FUNCTION

to MENU

FUNCTION

20

DIMENSION FUNCTION a: increases and decreases

primitive dimensions

SOLIDS MENU a: gives access to all

solid creation commands

MODELING MENU a: gives access to all

modeling commands

ORIGIN SET FUNCTION a: translates modeling

origin point

VIEWPORT MENU a: allows the viewer to

select any view point

COLOR MENU a: allows the viewer to

select object color

REMOVE OBJECT FUNCTION a: removes object located

at cursor location

WINDOW MENU a: selects single, multiple

plan or elevation view

FILE MENU a: creates and receives

work files

21

DIMENSION FUNCTION:

The dimension function allows the user to increase or

decrease the length, height or width of a block primitive

and the radius of a sphere or cylindrical primitive. Once

the function is entered by pressing "d" .The dimension

function will be activated, then the num keys will

control expansion or contraction along the width, length,

height or radius. The amount of expansion is determined by

the value of the grid spacing which can be adjusted by the

plus and minus keys.

DIMENSION "ON" KEY PAD FUNCTIONS

increase height -----, or

radius ~ ~ ~~~~~-increase decrease v width ~~~~ ~ ~ ~~ecrease

width

grid space

decrease height

or radius

EJ2]@] + <~-increase grid space

I a ~ m=J CJ ._____. decrease length __J L__increase length

22

The dimension function works by adding or subtracting

the grid value to the dimension value. Once the value are

defined then they are used in the solid function to

specify a height, length, width or radius, an example of

this is as follows:

PSOLID 4 WIDTH HEIGHT LENGTH

PSOLID - command for solids

4 - sets solid mode to block

WIDTH - defines width value

HEIGHT - defines height value

LENGTH - defines length value

In order to draw a block with a width of 100, height

of 50 and length of 20. The command

PSOLID 4 100.0 50.0 20.0

must be created and sent to the Command List.

23

DIMENSION FUNCTION DIAGRAM

"PRESS KEY"

EJ-~ increase grid size, grid + 1 ~>->

[]--~ decrease grid size, grid - 1 ~>->

E}-~ increase length, length + grid ~>->

EJ-~ decrease length, length - grid ~>->

~a I ~ increase height, height + grid ~>->

2)-~ decrease height, height - grid ~>->

~~ increase depth, depth + grid r>-> CJ-~ decrease depth, depth - grid ~>

24

SOLIDS MENU :

The Solids Menu gives the user access to a set of

functions that will draw a set of primitives, swept solids

or composite solids. The first function will display the

selection of solids available to the user at the top of

the screen like the figure below.

BLOC COLM TUBE SPHR WEDG PYRY RING EXTR LATH MULT

The solids are arranged in an order most frequently

used, and a four letter abbreviation is used to symbolize

each object, the abbreviations are represented as:

BLOC COLM TUBE SPHR WEDG PYRY RING EXTR LATH MULT

BLOCK CYLINDER, COLUMN TUBE SPHERE WEDGE CONE, PYRAMID TORUS, RING, WHEEL EXTRUDED SOLID TURNED SOLID COMPOSITE SOLIDS

In order to activate one of the solid commands press

the first letter of the abbreviation on the keyboard. Once

this is done a value is set to a variable that corresponds

to the assigned solid, and the cursor will become that

solid. The cursor will remain that solid until a change is

made. If the "space" bar is pressed it will activate the

drawing function. The selected solid will then be drawn

to the screen and sent to the Command List along with

other attributes that define the solid.

25

The command used to activate any primitive solid is

PSOLID, then a mode zero to six is used to specify the

type a solid. The following modes are used:

CYLINDER = 0 CONE - 1 -SPHERE = 2 TORUS = 3 BLOCK = 4 WEDGE = 5 TUBE = 6

The mode number is written directly after the solid

command, such as for a sphere. " PSOLID 2 " After the mode

number comes the dimension information. Each primitive has

its own format, they are as follows:

CYLINDER - PSOLID 0' RADIUS, LENGTH CONE - PSOLID 1 ' RADIUS-TOP, RADIUS-BOTTOM, LENGTH SPHERE - PSOLID 2, RADIUS TORUS = PSOLID 3, RADIUS-INTERIOR, RADIUS-EXTERIOR BLOCK = PSOLID 4, WIDTH, HEIGHT, LENGTH WEDGE = PSOLID 5, WIDTH, HEIGHT, LENGTH TUBE = PSOLID 6, RADIUS-INTERIOR, RADIUS-EX, LENGTH

The mode number is activated through the solids menu.

Once the selection is made a number is assigned to

variable that dictates the cursor shape and the primitive

that will be drawn.

26

CREATE SOLIDS FUNCTIONS:

EXAMPLE BLOCK

<----~

MAIN KEYBOARD FUNCTION

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE KRAS

SOLIDS FUNCTION "waits for keyboard input"

BLOC COLM TUBE SPHR WEDG PYRY RING RXTR LATH MULT

I l"prejs anl of lhe flllowtng kjys" I I 0000000080 I ·1· sets I valuj of flag 'or clrsor I shapj" I

cp cp cµ cp cp cp cp cµ cµ cµ v v v v v v v v v v

I -------~v-----------.

DRAW CURSOR FUNCTION if FLAG = 1 draws a BLOCK if FLAG = 2 draws a CYLINDER if FLAG - 3 draws a TUBE if FLAG = 4 draws a SPHERE if FLAG - 5 draws a WEDGE if FLAG = 6 draws a CONE if FLAG = 7 draws a TORUS if FLAG - 8 draws a COMPOSITE

.____~~~>----------'

27

CURSOR FUNCTION DIAGRAM

if cursor flag equals zero then cursor remains a CROSS HAIR

if cursor flag equals one then cursor becomes a BLOCK

if cursor flag equals two then cursor becomes a CYLINDER

if cursor flag equals three then cursor becomes a TUBE

if cursor flag equals four then cursor becomes a SPHERE

if cursor flag equals five then cursor becomes a TORUS

if cursor flag equals six then cursor becomes a CONE

if cursor flag equals seven then cursor becomes a WEDGE

if cursor flag equals eight then cursor is CREATED by the user

28

Because swept, extruded and composite solids require

more information another format is used, for swept and

extruded solids the Command SSOLID is used, the extruded

solid uses mode 1 , and swept solid uses mode 2. Then

following the mode number is a closed 2D vector that is

either extruded along a sweep vector, or rotated around

the Y axis in a counter-clockwise direction. In order to

draw a prism shape, the command format is as follows:

SSOLID 0, NUMBKR-OF-VKRTICKS, X Y POINT SKT

EXAMPLE: for prism with points 0.0, 0.0, 0.0, 100.0, -100.0, 100.0, 0.0, 0.0

SSOLID 0, 4 0.0, 0. 0,

-100.0, 0. 0,

0.0 100.0 100.0

0.0

For Composite Solids the Command List Definition or

Solid Definition commands may be used. They are as

follows:

COMMAND LIST DEFINITIONS

CLBEG num - begins Command List num = {0 ... 256} CLEND - ends current Command List CLRUN num - runs list num

SOLID DEFINITION COMMANDS

SOLBEG num - begins Solid List num = {0 ... 256} SOLEND - ends current Solid List SOLRUN num - runs list num

29

The advantage to using one over the other is the the

Command List is faster and may include any other command

to define an object, while Solid Definition will allow

subtraction and intersection of solids {not yet

implemented}. An example of a composite solid may be a

frame that has four block primitives intersected at ends.

The following is an example:

CLBEG 1 begin Command List 1

MDT RAN -8.0, 0.0, 0.0 move to -8,0,0

PSOLID 4' 2.0, 14.0, 4.0 draw block ( 1 )

MDT RAN 8.0, 8.0, 0.0 move 8,8,0

PSOLID 4, 18.0, 2.0, 4.0 draw block ( 2)

MDT RAN 8.0, -8.0, 0.0 move 8,-8,0

PSOLID 4, 2.0, 14.0, 4.0 draw block ( 3 )

MDT RAN -8.0, -8.0, 0.0 move -8,-8,0

PSOLID 4, 18.0, 2.0, 4.0 draw block ( 4 )

CL END end List

CLRUN 1 run List 1

30

CL BEG 1 begin Command List 1 MD TRAN -8.0, 0.0, 0.0 move to -8,0,0 PSOLID 4' 2.0, 14.0, 4.0 draw block (1) MDTRAN 8.0, 8.0, 0.0 move 8,8,0 PSOLID 4, 18.0, 2.0, 4.0 draw block ( 2) MDT RAN 8.0, -8.0, 0.0 move 8,-8,0 PSOLID 4' 2.0, 14.0, 4.0 draw block ( 3) MDT RAN -8.0, -8.0, 0.0 move -8,-8,0 PSOLID 4' 18.0, 2.0, 4.0 draw block ( 4 ) CLEND end List CLRUN 1 run List ' .i.

FRONT VIEW RIGHT SIDE VIEW

x + z -~-----> >

+ WIDTH LENGTH

y I a= ijl > - < ->

I I I v- <-' -----18-' -------

I I v-(2)-+- 0,8,0 2 -+-A -

( 1 ) ( 3)

14 - -t-8,0,0 0,0,0 >,1), >-+- -+-

(4)-f- 0,-8,0 -+-

31

CREATE COMPOSITE SOLIDS FUNCTIONS:

EXAMPLE

v SOLIDS MENU FUNCTION

··waits for keyboard input"

BLOC COLM TUBI SPHR WEDG PYRY RING EXTR LATH MULT

I l"preis anj of lhe flllowlng kjys" I I 0000000080 I i' sets I valui of jlag jor clrsor I shapj" I 000800000.___......

....-~~~~~v~~~~~--.

COMPOSITE SOLID MENU

COMPOSITE CREATE NEW RECEIVE FILE I

8 ,.--~~~~~v~~~~~~~~~--.

COMPOSITE SOLID FUNCTION

WHAT IS THE NAME ?

a: receives name b: creates file c: writes CLBEG 1 command d: writes commands to new file

and COMMAND.D e: closes files f: returns to main~~~~~~~~~~~~~~~__.

32

MODELING MENU :

The Modeling Menu gives access to a set of functions

that will effect certain attributes associated with a

primitive or object. These attributes are presented at the

top of the screen after the user presses the key "m" for

the modeling menu. The modeling menu screen display will

be drawn at the top of the screen, like the figure below,

the set of abbreviations that are displayed will

correspond to a set of modeling functions.

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

.--~~~~~~-v~~~~~~~~~~~~~~~~~~~~~

ROTATE FACET GSHADE ASHADE TRANSL SCALE CENTER

ROTATE FACET

GSHADK ASHADE TRANSL SCALE CENTER

OBJECT ROTATION ON THE X, Y OR Z AXIS FACETS SOLID PRIMITIVES TO A GREATER

OR LESSER DEGREE OF ACCURACY SETS TO GOURAUD SHADING SETS TO CONSTANT SHADING SETS TRANSLUCENCY INDEX SCALES OBJECTS ON THE X, Y OR Z AXIS RESETS AND CENTERS MODELING MATRIX

Kach of these functions also has its own command they are as follows:

ROTATE MDROTX num, MDROTY num, MDROTZ num FACET DISPAT 4 num {0 ... 7} GSHADE DISPAT 0 1 ASHADK DISPAT 0 0 TRANSL DISPAT 1 num {0 ... 15} SCALE MD SC AL sx, sy, sz

33

MODELING MENU BRANCHES:

MAIN KKYBOARD FUNCTION

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

1l:waits for keyboard input"

L, PRESS->-q=i KEY

.--~~~~~~~~~~~v~~~~~~~~~~~~--.

MODELING MENU FUNCTION .. waits for keyboard input"

ROTATE FACET GSHADE ASHADK TRANSL SCALE CENTER

I 'press ajy of the following I I

00 0 00

34

This set of modeling functions will give access to

another set of functions related to the heading, or is

only a single function. In order to activate a command

press the key of the first letter of the word or

abbreviation. If the word represents a function it will be

activated, if it branches to another menu it will present

the user with a new set of functions.

ROTATION FUNCTIONS:

The Rotation Functions branch to sub-functions Rotate

X a.xis, Rotate Y a.xis and Rotate Z axis. Each of the

different axis rotation functions are displayed at the top

of the screen, so that the user may choose by pressing

either the " X" key for X a.xis rotation, the "Y" key for

Y axis rotation,or the " Z" for Z a.xis rotation. Once the

choice is made the program will enter into that specific

rotation function. Once entered into one of three rotation

functions another menu will be displayed. That menu will

consist of a series of numbers that represent different

angles that the object will be rotated on. The " F9" and

" FlO" keys will activate a separate menu cursor that will

rotate the object in real time. This effect will allow the

designer to make a visual choice. If the designer already

knows which angle is to be used the cursor can be place on

the first letter of the menu. This will activate a query

35

function that will receive any angle that is desired. Each

axis rotation function can be accessed from the other

simply by pressing the letters X, Y or Z. This will

eliminate the need to return back to the main rotation

function. Also, translation and grid space commands are

available within each function. This will give the user

the ability to create models freely that would require

multiple rotations of a single element, such as a spiral

stairway. In order to exit back to the main menu the the

"Ksc" should be pressed.

Once a rotation values been set they are stored in a

variable, each axes has its own variable. If the variable

is greater than zero then the rotation commands will be

written with the solid object it defines, and then another

command will also be written to rotate the modeling matrix

back to zero. Here is an example block rotated at 45

degrees on the Z- axis

MD TRAN MDORG MD ROTZ LOCATE PSOLID MDROTZ

0.0, 0.0, 0.0 0.0, 0.0, 0.0 45 0.0, 0.0, 0.0 4, 10.0, 70.0, 50.0--315

locates block at or1g1n set modeling origin rotates modeling matrix 45 locates centroid at origin draws block sets modeling matrix to 0

36

PATH OF X-AXIS ROTATION:

I I

00 ROTATION MENU FUNCTION

.--~~~~~~~-v~~~~~~~~~~~~~~~~~--.

ROTATION ROT X ROT Y ROT Z ......__ ____ , "waits for k!yboardlinput"

v v SELECT X AXIS 1;1 Iii y AXIS L...:_j t.__:__j or Z AXIS ROTATION

x ROTATION FUNCTION MENU

x 30 45 60 90 120 135 150 180 210 225 240 270 300 315 330

I "waits for keyboard input"

"press one of the following keys"

SPACE BAR I IKscj-> <-CURSOR-> EXECUTES to Y-AXIS Z-AXIS to MAIN SELECTION SELECTION ROTATION MENU

1-. .--~~~-v~~~~~~~~~--.

X AXIS FUNCTION a: executes X axis rotation b: assigns new value to

ROTATE X variable c: exits to KEYBOARD FUNCTION

37

FACETING FUNCTION:

The Faceting Function has the ability to draw curved

surfaces or solids to a greater or lesser precision. In

this graphic system curved and circular objects are drawn

with a series of lines or planes that represent that

object; therefore, a round column can be represented as a

six sided column in gouraud shading and may be drawn very

quickly with little accuracy, or may be drawn slowly

having sixty sides with a greater amount of accuracy.

Another useful aspect of the Faceting function is the

ability to draw an eight, six or twelve sided column just

by adjusting the faceting angle. If this is the desired

outcome then the Constant Shading Function should be used.

The Faceting Function and shading functions work together

to create different attributes associated with the manner

in which the object is drawn. The Faceting Function is

activated by the modeling menu branch, and access is

achieved by pressing the "m" key, then the "f" key. Once

the faceting function has been entered it will present its

own menu, that menu consist of a series of numbers that

represent the faceting angle. If the "F9'' or "FlO" keys

are pressed they activate a menu cursor that will select

the desired angle.

38

The command for faceting is Dispat 4 num, num may be

any number from 0 ... 7. The higher the number the more

accurate the model and the slower the drawing speed. The

number will also give a particular number of sides to a

circular edge. They are as follows

NUM ANGLE NUMBER OF SIDES TO CIRCULAR EDGE

0 90 4 1 60 6 2 45 8 3 30 12 4 20 18 5 15 24 6 10 36 7 6 60

An example command list for an eight sided column

would be :

DISPAT 4, 2 DISPAT O, 0 LOCATE 0.0, 0.0, 0.0 PSOLID 0, 35.0, 130.0

sets to eight sided circular edge sets to constant shade

locates solid at the origin -- defines solid as a column

39

PATH FOR FACETING FUNCTION:

<------. <------.

MAIN KEYBOARD FUNCTION

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

MODELING MENU FUNCTION "waits for keyboard input"

ROTATE FACET GSHADE ASHADK TRANSL SCALI CENTKR

"press any of I I

thj follojing keysj I v F 0 00 00

~ING FUNCTION MENU

FACKT 90 60 45 30 20 15

"waits for keyboard input" I "press one of the following keys"

~ linof SPACE BAR

KXRCUTKS SELECTION

..--------v------. FACET FUNCTION a: sends selected ->

angle to board

EJ MAIN MKNU

FACET FILE FUNCTION a: opens COMMAND.D b: writes DISPAT 4 nu.m c: closes COMMAND.D

10

II

d: exit to KEYBOARD FUNCTION

6

40

GOURAUD SHADING FUNCTION:

The Gouraud Shading function is represented by the

abbreviation GSHADE. This type of shading performs a

blending of all the surface planes so that the object has

a very smooth surface appearance. The Shading Function is

very useful in creating round smooth surfaces. It is also

used in conjunction with the Faceting Function when

drawing time is important, example: a sphere drawn with

gouraud shading at a faceting of fifteen degrees will

appear smooth and round, and may be drawn quickly. At the

same time a sphere drawn at six degree facets will have a

more accurate spherical shape, but it will take over twice

the amount of time to draw. When a model that has several

hundred circular objects in it is being redrawn, it may be

an advantage to use a greater faceting angle in the design

development stage and to use a higher accuracy image for

presentation purposes. In order to activate gouraud

shading the user must first enter into the Modeling Menu

then press the "g" key, this will automatically set the

shading mode and all other objects will be drawn in

gouraud shading until a change is made.

The Gouraud shading command is DISPAT 0 1. Once placed

in the Command list all following objects will be drawn in

Gouraud Shading.

41

PATH FOR GOURAUD SHADING FUNCTION:

<----~

MAIN KEYBOARD FUNCTION

DIHN SOLD MODL ORGN VIEW COLR RHOV WNDW FILE ERAS

MODELING MENU FUNCTION "waits for keyboard input"

ROTATE FACET GSHADK ASHADK TRANSL SCALE CENTER

I I the following keys'j I

I I

00 00 00 ..--------v----~

GOURAUD SHADING FUNCTION ->

a: sets shading to gouraud

FILE SHADING FUNCTION a: opens COMMAND.D b: writes GOURAUD SHADE

COMMAND DISPAT 0 1 c: closes COKMAND.D d: exits to KEYBOARD

42

CONSTANT SHADING :

The Constant Shading or Angular Shading function is

represented by the Abbreviation ASHADE. This type of

shading shades each surface patch separately, with this

shading technique all angles facets are made visible. By

using Constant Shading the sphere primitive can represent

a tetrahedron, octohedron, decahedron, dodecahedron and

more simply by adjusting the faceting angle. Cones,

columns, rings and tubes can also be faceted to make a

wide range of primitives that have four to sixty-four

equal sides. In order to activate constant shading the

user must first enter into the Modeling Menu by pressing

the ''m.. key then press the "a" key.

The Constant shading command is DISPAT 0 0. Once

placed in the Command list all following objects will be

drawn in Constant Shading.

43

PATH FOR CONSTANT SHADING FUNCTION:

<----~

MAIN KEYBOARD FUNCTION

DIMN SOLD MODL ORGN VIRW COLR RMOV WNDW FILE ERAS

1l:waits for keyboard input"

~> PRESS->~ KEY

MODELING MENU FUNCTION "waits for keyboard input"

ROTATE FACET GSHADE ASHADE TRANSL SCALE CKNTKR

I ~press ore of the I

00 0 v A

.---------~v CONSTANT SHADING

FUNCTION a: sets shading to

constant

following I

keys'j I 0 00

FILE SHADING FUNCTION > a: opens COMMAND.D

b: writes DISPAT 0 0 SHADE COMMAND

c: closes COMMAND.D <l: exits to KEYBOARD

44

TRANSLUCENCY FUNCTION

The translucency function transforms a solid opaque

object into one that has a different level of

translucency. There are five levels of translucency that

may be activated, they are : 100% opaque, 50% opaque, 25%

opaque and 12.5% opaque. Each level then has different

patterns of dithering that the translucency mask is

applied to. The 50% level is the simplest and has two

levels. Below is a diagram showing two complementary

masks on a 2 X 2 pixel area of an image.*

~ ~ LEVEL 1

~ ~ LEVEL 2

0 = DO NOT CHANGE

X = DRAW THE PIXEL

If level 1 is applied then a 50~ translucent object is

drawn. Level 2 will also draw a 50% mask and is the

compliment of level 1. The advantage to this is that the

two can then be combined. For example if a red translucent

object is in front of a yellow translucent object, the

viewer would see orange where the two overlap. If both use

level 1 then one would mask the other and the first drawn

object would only be seen.

45

The 25% mask works on the same method, but has four

different patterns, they are diagramed as follows:

0 = PIXEL IS NOT DRAWN

LKVKL 3

x 0 x 0 x 0 0 0 0 0

I 0 I 0 x 0 0 0 0 0

LRVKL 4

0 x 0 I 0

0 0 0 0 0

0 x 0 x 0

0 0 0 0 0

LKVRL 5

0 0 0 0 0

x 0 x 0 x

0 0 0 0 0

x 0 x 0 x

LKVRL 6

0 0 0 0 0

0 x 0 x 0

0 0 0 0 0

0 x 0 x 0

X = PIXEL IS DRAWN

0 x 0

0 0 0

0 x 0

0 0 0

x 0 x 0 0 0

x 0 x 0 0 0

0 0 0

0 x 0

0 0 0

0 x 0

0 0 0

x 0 x 0 0 0

x 0 x

46

The 25% mask allows four translucent objects to be seen

overlapping each other. One pixel is drawn for every 2x2

pixel area. The values are from level 3-6.

The 12.5% translucency mask values are from 7-14 this

mask allows eight different planes to viewed through each

other, two pixels are drawn for every 4 x 4 pixel area.

LEVEL 7 - 14

the number level selected will draw the

corresponding pixel number.

7 12 14 9 7 12 14 9

11 8 10 13 11 8 10 13

14 9 7 12 14 9 7 12

10 13 11 8 10 13 11 8

47

Another advantage to translucency is that the color

table can be increased by blending colors. The 50% mask

allows the blending of two colors in the color table while

the 25% mask would allow four colors to be blended while

the 12.5% eight.

In order to activate this command the modeling menu

must first be entered by pressing "m" then by pressing the

"t" key the translucency menu will be shown. The different

levels of translucency will be displayed at the top of the

screen.

TRANSL 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

By pressing the "F9" and "FlO" keys the menu cursor

will move to the desired level, or by pressing the desired

"num" key, once selected the "space" bar will activate

that command. The translucency index will not change

unless another selection is made.

The COMMAND LIST format for translucency is as

follows:

DISPAT 1 (level)

example for a translucency of 50%

DISPAT 1 2

48

PATH FOR TRANSLUCENCY FUNCTION:

<------.

MAIN KEYBOARD FUNCTION

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

MODELING MENU FUNCTION "waits for keyboard input"

ROTATE FACET GSHADE ASHADE TRANSL SCALE CENTER

I ;press ore of keys'i I 00 [£] 0ITJ .--------------~v----------.

TRANSLUCENCY MENU FUNCTION

TRANSL 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

100% 50% 25% 12.5% "select with "F9" "FlO" cursor keys"

.-------v-----~ TRANSLUCENCY FUNCTION a: sets translucency

I .-------v-----~

FILE TRANSLUCENCY a: opens COMMAND.D b: writes TRANSLUCENCY

15

COMMAND "DISPAT 1 2"~-------' c: closes COMMAND.D d: exits to KEYBOARD

49

SCALING FUNCTION :

The scale functions include scaling on the X, Y and Z

axis. Kach can be performed all at once or separately.

When all three axes are scaled the object will retain the

same proportions as the original object. If one axis such

as the X axis is scaled then only the dimensions on that

axis will be scaled. This is useful in creating new

primitives, example: a sphere or a column can be scaled on

one axis to become more elliptical in cross section.

Scaling differs from the Dimension Function in that the

everything on the axis being scaled is changed after the

function is activated, while the dimension function acts

only on the primitive being drawn. The scaling values

will remain on until the function ls called again.

The Scale Function is activated by entering into the

Modeling Menu by pressing "m" the by pressing "s". Once in

the function a scaling menu will be displayed

SCALE XYZ AXIS X AXIS Y AXIS Z AXIS

Once the selection is made by either the menu cursor or by

pressing the highlighted key, a query will ask the user

for the scaling value.

The COMM.AND LIST format is as follows: MDSCAL 0.5, 0.5, 0.5

This command will scale the X, Y and Z axis by 0.5.

50

PATH FOR SCALE XYZ AXIS FUNCTION:

<------..

MAIN KEYBOARD FUNCTION

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

MODELING MENU FUNCTION "waits for keyboard input"

ROTATE FACET GSHADE ASHADK TRANSL SCALE CENTER

I "press one of the following keys" I I I I I I

00 0 0 0 ~ 0 v

SCALE MENU FUNCTION

SCALE XYZ AXIS X AXIS Y AXIS Z AXIS

~---1----1-----1-----1--~

8 0 0 0 ~-----v--~

QUERY FUNCTION WHAT VALUE ?

receives input VALUE

I v

SCALE FUNCTION a: scale x axis b: scale y axis c: scale z axis

by by by

SET SCALE VALUE a: sets VALUE

VALUE -> b: sets VALUE VALUE c: sets VALUE VALUE d: returns to

x y z main

51

CENTERING FUNCTION

The Centering function acts as a reset button it will

set Scaling and Rotation values to there default values.

It will also set the cursor back to the origin. The

command MDIDEN is used to reset the modeling matrix. Once

it is called all translation, rotation and scaling value

are set to their default values.

ORIGIN SET

The Origin Set Function is closely associated with

rotation and scaling functions. This function allows the

User to set a particular point in which to rotate an

object about, or be able rotate an object on end. Without

this function objects will only be able rotate around

there centroid; however, by being able to move the point

of rotation, complex composite solids may be constructed

quite easily. An excellent example would again be the

construction of a spiral stairway. The same object may be

rotated around the same Y axis while only increasing the Y

value.In order to activate MDORG press the "o" key, this

will save the current location, and enter into access to

the Translation functions. The user may then move the

cursor to desired point. Once this is accomplished the

"space" bar should be pressed, this will record the new

point and the difference between the two points. An

example of a rotated block on end is as follows:

52

COMMAND LIST EXAMPLE FOR MDORG:

MDTRAN 0.0, 0.0, 0.0 LOCATE 0.0, 0.0, 0.0 PSOLID 4, 2.0, 18.0, 4.0 MDTRAN 0.0, 8.0, 0.0 MDORG 0.0, 0.0, 0.0 MDROTZ 270 PSOLID 4, 2.0, 18, 4.0 MDROTZ 90

FRONT VIEW

x + .------>

+ WIDTH

18 I I I I I !6 1 <

18 - (1)

+ . 0, 8. 0. 0.0

I I I I I I I I

111111111111111

L._Q.0, 0.0, 0.0

RIGHT SIDE VIEW

z -----> LENGTH

>

>

+ ____ __J

+

53

PATH FOR MODELING ORIGIN FUNCTION:

v

MAIN KEYBOARD FUNCTION

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

MODELING ORIGIN FUNCTION

stores current coordinate setting in orgX, orgY, orgZ

1 TRANSLATION FUNCTION moves to new coordinate location X,Y,Z

I

calculates difference of points orgX - X = orgXd orgY - Y = orgYd orgZ - Z = orgZd

in orgXd, orgYd, orgZd varibles these variables will translate cursor position in CURSOR FUNCTION

MDTRAN orgXd, orgYd, orgZd

54

VIEWPORT FUNCTIONS

The viewport function include those functions that

allow viewing transformations, these function do not alter

the model in any way, they only allow the viewer to have

different view points of the model. The program will allow

the user to view the model from any angle, from an outer

or inner perspective. This will allow a walk through

perspective of a model. The functions that are included

are as follows:

ROTATE X ROTATE Y ROTATE Z DISTANCE VIEWPOINT --WINDOW -----

rotates the model view around the X axis rotates the model view around the Y axis rotates the model view around the Z axis determines the distance from the view point determines the point that is being viewed zoom for orthographic projections

These functions work within the file SKTUP.D if any

changes are made to the viewpoint of the model the entire

Command List most be run with the new changes in the setup

file. Kach function will create a Command in the SKTUP.D

file, They are as follows:

ROTATE x VWROTX angle ROTATE y VWROTY angle ROTATE Z VWROTZ angle DISTANCE DI STAN dist VIEWPOINT - VWRPT x, y' z WINDOW ----- WINDOW xl, x2, yl' y2

55

A COMMAND LIST example for viewing a block at 315

degrees on the Y axis is as follows :

VWPORT WINDOW PROJCT DI STAN VWR PT VWROTX VWROTY VWROTZ PSOLID

0, 640, 0, 480 ----sets the viewport to full screen -640.0, 640, -480, 480 ----------- sets window size 50 -------------------------- sets projection angle 500 ------------ sets distance from reference point 0.0, 0.0, 0.0----- sets location of reference point 0 ------------- sets 0 degrees rotation on x axis 315 ----------- sets 315 degrees rotation on Y axis 0 ------------- sets 0 degrees rotation on Z axis 4, 30.0, 30.0, 30.0 ------ defines solid block size

block --. v----......

0.0, 0.0, 0.0, viewing reference -v- point

X axis_J 315 degrees

distance 500

Z axis----

-t- viewer

The Viewing Functions are accessed by pressing the "v"

key and entering into the View Menu Function. Once in the

View Menu the following display will be given:

ROTATE X ROTATE Y ROTATE Z DISTANCE VIEW PT WINDOW

To activate a given function the user then must press

the highlighted letter.

56

VIEWPORT FUNCTION DIAGRAM :

EXAMPLE ROTATE VIEW 315 DEGREES ON THE Y AXIS:

I

<----~

MAIN KEYBOARD FUNCTION

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

KEY

.-------------v---------------, VIEWPORT MENU FUNCTION

"waits for keyboard input"

ROTATE X ROTATE Y ROTATE Z DISTANCE VIEW PT

I press any of the following keys"' I I I

0 0 0 0 "branches to corresponding function "

v ROTATE VIEW Y AXIS

FUNCTION

WHAT ANGLE ROTATION ? I a: receives response b: opens SETUP.D c: sets new value in

Command List VWROTY 315

d: closes SETUP.D e: runs entire Command

List d: returns to main

I

WINDO

I 0

57

COLOR FUNCTION

The Color Functions are a set of functions that

control the color of an object. They are accessed through

the Color Menu Function which is activated by pressing the

"c" key. Once activated it will display the color menu.

WHITE RED YELLOW GREEN BLUE SKY PURPLE

To select the desired color the user then may press

the first letter of that color. All objects drawn after

the selection will be drawn in that color until another

selection is made. After the selection has been made the

color command COLOR num is added to the command list.

Once added to the command list the object will be

recreated in the selected color. Each color represent 32

shades of that color. This will give a very realistic

shading of an object. The maximum colors available on the

screen are 256, however this can be increased by using the

transparency function and blend two to four colors

together. Kach color is coded with a number which

activates the graphics board to that specific color. The

list is as follows:

WHITE 224 RED 32 YELLOW 128 GREEN 64 BLOK 96 SKY 218 PURPLE 252

58

COLOR FUNCTION DIAGRAM

EXAMPLE ADD COLOR RED:

DIMN

COLOR .. waits for

WHITE RED YELLOW

KEY

v MENU FUNCTION keyboard input ..

GREEN BLUE SKY

I "press any of the following keys" I I I I I

<-------.

ERAS

PURPLE

I 0 0 0 0 0 0 .--~~v~~~~~~-~~

COLOR SET FUNCTION a: sets color value

COLOR 32 b: opens command list c: sets new value in

Command List COLOR 32

d: closes COMMAND.D d: returns to main

59

REMOVE FUNCTION:

The Remove Function purpose is to allow the user to

delete unwanted objects from the screen. The is a very

useful function especially in the design stage when many

changes may be made. The Remove Function is activated by

pressing the "r" key. Once the key is pressed the cursor

will take the shape of a block, this block may then be

move to any location on the screen. When the "r" key is

pressed a second time all objects that are inside of the

block will be deleted from the screen and the command

list. In

capability

order to provide a more accurate deleting

the blocks dimensions may be changed by using

the Dimension Function. The function works simply by

comparing the coordinates of the deleting block to that of

the objects on the screen. Those objects that are within

the blocks boundaries will not be redrawn to the screen.

All curved shapes such as spheres and cones will be given

a rectilinear boundary definition to speed up

calculations. For even faster removal the function may be

set to locate only the centroid or closest object to the

cursor location. An example of boundary definition

removal is as follows:

REMOVAL OF OBJECT (3)

FRONT

I (1)

( 2 3)

-- ~ -

60

RT. SIDE

[ ] (4

POINT CHECK: each corresponding point must lie within the boxes boundaries

4' 15' 1 9,15,l

point 1 r-1 point 2 6,12~2 ,....., +.12,2

6' 0'

point 3 4,-3,l

I I 7,0,2

point 4 9,-3,1

9,15,4 9,15,l

point sQ point 2 7,12, ,12,2

7' 0, '0, 2

point sU 9,-3,4

point 4 9,-3,l

61

POINT EVALUATION each point must test true for the object to be removed.

POINT LOCATION BOX TEST OBJECT

POINT 1 FRONT LEFT TOP x 4 < 6 y 15 ) 12 z 1 < 2

POINT 2 FRONT RIGHT TOP x 9 ) 7 y 15 ) 12 z 1 < 2

POINT 3 FRONT LEFT BOTTOM x 4 < 6 y -3 < 0 z 1 < 2

POINT 4 FRONT RIGHT BOTTOM x 9 ) 7 y -3 < 0 z 1 < 2

POINT 5 BACK RIGHT TOP x 9 ) 7 y 15 ) 12 z 4 ) 3

POINT 6 BACK RIGHT BOTTOM x 9 ) 7 y -3 < 0 z 4 ) 3

POINT 7 BACK LEFT TOP x 4 < 6 y 15 ) 12 z 4 ) 3

POINT 8 BACK LEFT BOTTOM x 9 ) 6 y -3 < 0 z 4 > 3

62

WINDOW FUNCTIONS :

The Window Functions are a set of functions that allow

the user to move from orthographic projections to

perspective views, also is the ability to set the number

of viewing windows from one to three. The purpose of these

functions is to give the user multiple views of a model.

When in the design stage it is very critical that the

designer be able to view an object from several

perspectives. While in a perspective view it is nearly

impossible to determine the space relationship between two

objects without a undistorted form of measurement such as

a plan or elevation. The multiple window does just that,

it gives a plan, elevation and a perspective view of the

model. A cursor is visible in all three window

simultaneously.

The function are activated by pressing the "w" key,

once this is done the Window Menu will be displayed at the

top of the screen.

WINDOW RYR VIRW PLAN ELEVATION MULTIVIKW

63

WINDOWS FUNCTION DIAGRAM

EXAMPLE MULTIVIEW:

<------.

MAIN KEYBOARD FUNCTION

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

input" .I PRESS Cf] KEY

v:--11 WINDOW MENU FUNCTION "waits for keyboard input" I

WINDOW KYK VIEW PLAN ELEVATION MULTIVIEW

I "press any of the following keys"

0 "branches to corresponding function "

~----------~v------------~ MULTIVIEW FUNCTION

a: sets mutiview flag on b: opens Command List c: screen is set to right 2/3 of screen d: Read File command activates

commands from Command List e: Command List passes through

eye view setup routine f: screen is set to top 1/3 of screen g: Command List passes through

plan setup routine h: screen is set to bottom 1/3 of screen i: Command List passes through

elevation setup routine j: closes Command List k: cursors are drawn to the 3 active windows 1: exit to main

l l

64

FILE FUNCTIONS

The Filing Functions are the designers way of storing

Command Lists of models. The functions consist of two, one

to create a new file and one to display an existing file.

To activate these functions the user must press the "f"

key. Once this is done the menu will query the user, if a

new file will be created or an existing file should be

displayed. A "c" or "r" key should be pressed. After a key

is selected another query will ask for a name. If a file

list is needed press the "f" key, all existing work files

will be presented with a brief description. The file names

may also be filed with a suffix code and put into separate

categories. The Create new file works simply by writing

the existing COMMAND.D List to the newly created file. The

receive function is very similar replaces the existing

COMMAND.D file with the selected file.

FILK CRKATK NKW FILE RKCKIVK EXISTING FILK

WHAT IS THK FILK NAMK ?

ANY COMMENTS ABOUT THE FILK ?

65

FILE FUNCTION DIAGRAM

EXAMPLE RECEIVE FILE:

<------..

MAIN KEYBOARD FUNCTION

DIMN SOLD MODL ORGN VIEW COLR RMOV WNDW FILE ERAS

PRESsCf J KEY

FILE MENU FUNCTION v~ "waits for keyboard input"

FILE CREATE NEW FILE RECEIVE EXISTING FILE

I "press any of the following keys"

0 "branches to corresponding function "

..----------------v---------------. FILE FUNCTION

WHAT IS THE FILE NAME ?

a: receives name b: clears COMMAND.D c: reads file

.__E_x_I_s_T_I_N_G __ F_IL_E __ ~~>l.__c_o_M_M_A_N_D_.~n----~ I

,-D-I-SP_L_A_Y-;-UN_C_T_I_ON--.1

d: writes to COMMAND.D new file e: displays new COMMAND.D 1: exit to main

l j

66

CONCLUSIONS :

After undertaking such an extensive project a great

amount of learning and experience has taken place. One of

the biggest lessons has been, that while working with the

computer a whole new world has begun to unfold. The

computer has become the teacher, a very demanding one that

demands a clear structured way of thinking. The computer

language itself is a part of this structure. The structure

of the language itself seems to open up new ways of

thinking, and a greater awareness of the working process

of our own mind. After all it is man communicating to a

machine, and man creating the structure in which to

communicate.

This last year has been my first exposure to

computers and their capabilities, and my conclusions are

quite simple, its simply one of the tools of the future

that will be in almost every working environment,

especially in the designers work space. Those of us who

choose not to be involved with computer, are actually

selecting a very limited future.

If I look at where this program will be in the future

I would predict that there will be libraries of

subroutines available, which this program could utilize,

examples would be complex light shading, and reflection of

67

surfaces. Ray tracing routines which are done on super

computers will be more widely available and a program such

as this one would be able to utilize such routines. The

menu structure and how they accessed be comes a very

important issue, because the menus structure may greatly

effect the design process. Future revisions will examine

and refine the relationship between design process and the

program interface. This program is now dependent on a

very sophisticated graphics board, I selected this option

because at present solid modeling on standard systems is

much too slow. Most of the design work needs to done in

wire-frame, then transferred into shaded objects; However,

with the use of more powerful hardware solid modeling

becomes possible. In a few years this will chanF.e,

personal computer speeds will go up and prices should come

down. Already in one year, computing speed has been

greatly improved, and in a few more years personal

computers may have the speed of a supercomputer. The main

hardware improvements may probably always be speed, memory

and resolution. The Software improvements will focus on

what this thesis has investigated, how we are able to

68

communicate with the computer in terms of design. I

believe this thesis has dealt with many design issues, and

the end result is a program that may be used to create a

3D model in a way that the designer may understand;

however, I must add this is just the beginning. This

thesis is more an expression and investigation of a design

process rather than an end product.

BIBLIOGRAPHY

Martin, D., Prata, S. ,and Waite M., C Primer Plus, Howard W.Sams & Company, Indianapolis, Indiana, 1987

Lafore, R., Microsoft C Programming for the IBM, Howard W.Sams & Company, Indianapolis, Indiana, 1987

Prata, S., Advanced C Primer++, Howard W.Sams & Company, Indianapolis, Indiana, 1987

Wolverton, V., Running MSDOS, Microsoft Press, Redmond Washington, 1985

Matrox Electrical Systems Limited, Space Machine 640 Users Manual, Matrox Electrical Systems LTD, 1987

69

APPENDIX:

SOURCE CODE IN C FOR SOLID MODELING PROGRAM

10

71

1• BAii ro1CT101-11TB011n-s11sc11-a111T11-rt10TTAl-BAill&1s-v11novs-ccLIAII-iABIDSl-Bc1s1-1ss-Kc11T11-ccL1&1s-cTRP T-CCLIAIJ-OIGSIT•/

linclude "std.h" /•CALLS IIIRIAL fILIS•/ linclgde <fcntl.h> linclgde <s1s\t1pes.h> linclude <s1s\stat.h> linclgde <io.h> linclgde <stdio.h> linclude 0 ke1s.h 0

ldef ine LI! 40 ldef ine !AILIB 81 ldef ine VBITI 255 int Jill, J812, ,,,1, ,,,2; ,. VAIIBLIS lOR lOLL SCRllB VIIVPORT•/ int Yv1lp, Yv12p, Y&Jlp, Y&J2p;/a STORKS OPPIR RIGHT NIIDON *I int Yv1le, Yv12e, Y&Jle, YvJ2e;/a STORIS LOMIR RIGHT MIIDOM *I int Yv1lY, Yv12Y, ,,,1,, Y&J2Y;/a STORIS Lilt MIIDON t/

int r1cnt1,r1cnt1,r1cnt1; /t VAR FOR ROTATIOI ORDIR•/ int rcnt1,rcnt1, rcnti; int r1t, ryt, rzt; /* STORIS TOTAL ROTATIOI VALOIS t/ int Yv1, ,,,, Tvz; I* BOLDS VIIM VIIDOM ROTATIOI VALOIS*/ int rz,rz2,r1, r12,r1,r12; I* HOLDS ROTATIOI YALOIS t/ int tv10, t11l, t110, t11l, tveO, tvel;/a STORIS TIIT WIIDON SIZI•/

int returnYali; int firstcall;

int Yectotal;

int r1d,r1d,rzd; int sscount;

int ssnu1;

int total;

int ssct;

int Jtot;

int cl, cli; int t1T; int proj; int ltenl, lten2; int vdov; int bcol; int ltnu1, lt1a1; int col;

/t RITORIS IITIGIR VALUI FRO! STRIBGt/ I* OSID II TAlA.-flLIPRI!I(), SOL!.-SS!ll02();BOILDS SNIPTSOLID CO!!ABD LIST t/ /t Tll.,!lIIYAR; TA2f GITlILl(),SSOLIDR(J,CPLAB(),CILIYAT(J,SROP. -- COOITS

IO!BIR or YICTORS IM SMIPT SOLIDS •/ !• TA1A.,CPRI!l2(),fCITI(); STORKS DifrlRllCI or GIYll AIGLI •/ !• TA2V.,GITfILl(),SSOLIDR(),CPLll(),CILIYAT(); COITS IO!BIR or PASSIS

THROUGH SSOLID rOICTIOIS t/ I* TA2V.,SSOLIDR(),CPLll(),CILIVlTI(),; SROP.,LATRl(J,IITODI(); DITIR!IllS

SSOLID TTPI */ !• TA2Y.,GITrILl0(),SSOLIDR, CPL!l(),CILIY!T();COUITS NU!BIB or VICTORS

P!SSID TBROOGB rOICTIOI•/ !• T!2Y.,GITJILl0(),SSOLIDR, CPLAl(),CILIYAT();COOITS MU!BIR or YICTOBS

P!SSID TBROOGH rOICTIOlt/ !• T!2f .,GITfILIO(),SSOLIDR, CPL!l(),CILIVAT();CODITS ID!Bll or VICTORS

P!SSID TBROOGi fUICTIOI•/ /t TlfILIS.,setgp(J; BOLDS CLl!R SCRlll VARIBLIS •/ !• T!fILIS., setup(); te1t vindo1 Jisible •/ I* T!fILIS., setup(); SITS PBOJICTIOI !IGLI */ /t T!fILIS., setup(); ll!BLI LIGHT SOORCI */ /1 SITS SCRlll TO SIIGLI OR !DLTIPLI •/ I* SITS B!ClGRODID COLOR t/ /1 SITS LIGHT 10!811 !RD SBADIS !V!ILBLI t/ /1 SITS COLOR *I

int curs; int planon; int tess; int 1enur; int shad; int e1ton; int ra1disk; int orgy; int cursnu1; int cliston; int •ali;

72

I* DIYiliS CURSOR TYPI */ I* BOLDS VliM , PLAI, ILIVATION KUMBiR */ I* BOLDS FACiTllG VALUi */ /t TA3A. ,rotate(), ;SITS ROTATION MllOS */ I* SITS SBADIHG VALUE t/ I* SOLi. ; TURIS 01 ilTRODi SOLID t/ I* SITS RAMDISI */ I* TACORS. ; ACTIVATES ORIGIM YOMCTIOMS t/ I* SITS CURSOR SOLID TYPE */ /* SITS COllAMD LIST OH */

int faceton; /* SIT rACITllG 01 *I int bop; I* FLAG FOR SOBTRACTIOI */ int bolcount; /ttalaBOOLIAI COUNT•/ double return•al; /t RITORI IITIGIR VALOI FORK STRING */ double zoo1Yal; I* llCRIASIS OR DiCRiASiS WIIDOW SIZi */ double 1d,1d,1d; I* DlrrlRilCI rROI LAST POIHT llTIRID */ double org1d,org1d,org1d; /* DlrrKRllCI rROI ORIGll TO PRillTIVI CENTROID*/ double s1,s1 1 s1; /*BOLDS SCALIIG VALOIS */ double rotnu1; I* SHOP., TA2., TA2V.; VALUE FOR ROTATIOI or TORRID SOILDS•/ double 1,1,z; I* CURSOR LOCATIOI INDICATORS*/ double speed; /* GRID SPACIIG */ double dist; I* fiiMIIG DISTAICI *I double a1b,lt1,lt1,ltz; /* LIGBTIIG DIRICTIOI */ double •vpt1,Tvpt1,•vpt1; /* TArILiS. setup(); YllMIIG RifiRllCI POIIT t/ double via1l,vin12,via1l,vin12;/t SIT MIIDOM SIZE t/ double dis1,disb; I* SIT CLIPPIIG PLANK DISTAICI *I double 1f,Jf,zf; /t TAlA.; STORKS PRlfIOOS l,T,Z LOCATIOI t/ double height,vidth,leagth; /t PRillTlfl DilllSIOIS t/ double orf1,orf1,orgz; /t !ODILllG ORIGII LOCATIOlt/ double depthl,depth2,depth3; /t SBOP.,TA2f., ; BllGBT Of SWIPT SOLID*/ double org1t, org1t, orgzt; /* DlfflRllCI rRO! ORIGII TO CilTROID or PRI!ITIYI */ double 1list2se; /* I fALOI LIST fOR SWEPT SOLIDS */ double Jlistzst; /* T YALOI LIST FOR SWlPT SOLIDS l/ double •1ptr; I* I POllTIR FOR YALOI LIST roR SWEPT SOLIDS */ double *Jptr; I* T POIITIR roR f ALOI LIST roR SMIPT SOLIDS */ double p1l, pJl, p1l; /t STORIS PIRl!ITIR fALOIS roR DILITi OBJiCT t/ double p12, pJ2, pz2; double p13, pJ3, pz3; double p14, pJ4, pz4; doable p15, py5, pz5; double p16, py6, pz6; double p17, py7, pz7; doable p18,py8, pz8;

BOOL main( l { extern int rx,ry,rz; extern int rcntx, rcnty,rcntz; extern double 1d,yd,zd; extern double x, J, z, speed; int i:ey ; FILI •cl; pginit(O,l); pgcold(); cl : fopen("co11and.d", "v"); fclose(cl); 1ainur(); cleari{O); 1aindisp(); setscrn(); i:eyloop(); displa(l); } /* end 1ain */

/**********************! i:eyloop() {

73

I* BIGINNIIG or BAIN JOICTION l/ I* GLOBAL Y&RI&BLI DlfIIITIOIS l/

I* TORIS 01 SB-640 l/ I* ilSITS BOARD Bl!OiY *I

I* DIFill cl TO OPll COBB&ID rILI */ I* CLOSI FILI */ I* DIFillS ALL GLOBAL Y&RIBLIS t/ I* CLl&RS SCilll t/

I* DISPLAYS !&II !110 */ I* SITS SCRlll COORDil&TIS */ I* llYBO&RD LOOP t/ I* TDilS ON CG& BODI a/

extern double x,J,z,speed,xd,yd,id; extern int rx,ry,rz,rcntx,rcnty,rcntz; int i:ey; i:ey : getche(); vhile(i:ey !: 113)

{ i:eyboard(i:ey);

printf (

I* GITS CHAR JROB llYBO&RD */ I* TIST FOR "q" t/

I* OPINS llYBO&RD JOICTIOI *I I* PRIITS CURSOR LOCATION &ID ROTATION IlrORBATION *I

"\o 1d: l.2f yd: l.2f zd: l.2f rx: Sd:Sd ry: td:td rz: td:td", (1d-1),(yd-y), (zd-z),rx,rcnt1,ry,rcnty,rz,rcnt1); printf ( "\o x : l.2f J : l.2f z : l.2f grid : %.2f" , x, y, z, speed) ; key: getcbe(); /* RIADS lEYBO&RD CB&B */ } /* vhile loop•/

} /*****************! !*********************/

setscrn( l { I* DR&NS CORSOB OR CURSORS TO SCRlll */ extern int vdov;

}

if(vdoll==Ol cursor();

if(vdov::l) vindovs();

/:nnuuuuun•/

''**************************! keyboard (key l int key; { extern double speed;

s11itch(key) {

case f2: extract(); break;

case ASTRII:reset(); break;

case IS :clears(O); cleari(O); linfun(O); setcl2(); displa(O); tnis(l); •ie11rot(); reset();

break; case fl : bop++;

subtract(); break;

case OS : 10rgset(); break;

case !llOS : speed -: 1.0; break;

case PLUS : speed += 1.0; break;

I* !All llYBOARD fONCTIOK *I

I* TIST CASI *I

I* BRAICB TO ORIGII SIT */

I* DICRIASI GRID *I

I* IICRIASI GRID */

I* case CO : ccleari ( bcol); CLUBS SCUii break; *I

case FOOR : case LARR : left(); I* CURSOR Lift */

break; case SII case RARR: richt(); I* CURSOR RIGHT */

break; case UGBT : case OP: up(); I* CURSOR OP s/

break; case TWO case DOWI : do11n(); I* CURSOR DOWI */

break; case SIVIK : case HO!I : apleft(); I* CURSOR OPLlfT */

break; case 1111 case PGOP : upricht(); I* CURSOR UPRIGHT */

break;

75

case TBRU case PGDI : do11nright();

break; I* CURSOR DONN RIGHT */

case on : case llD : do11nleft();

break; case ZIBO : case IIS : for11ard();

break; case PERIOD : case DIL : back();

break; default : ; } /* s11itch •/

ke1board2(ke1); }

'***************! ke1board2(ke1) char ke1; { extern int 11do11,raldisk;

I* CURSOR DONI Liff */

I* CURSOR fORNARD */

I* CURSOR BAC( *I

I* lltBOARD IITllSIOI •/

extern double zoo1tal,11inxl, 11inx2, 11in1l, 11in12; extern int tvxl, Yvx2, YVJl, YllJ2; extern double x,1,z; rILI •cl;

svitch(keJ) { case RS : re1obJ(); /* Rl!OYIS OBJECTS l/

printf("reaoYe test\n"); break;

I* case YO : ra1diskf(); SIT RA!DISl break; *I

case YS : 1aindisp(); !• YllM !110 •/ Yien(); break;

case IS : cY11x(); /l RISIT I AIIS YIIM */ break;

case TS: ctvJ(); /t RISIT t AIIS YIIM */ break;

case ZS : ctvz(); /t RISIT % AIIS YIIM *I break;

case MS : 1aindisp(); /*DISPLAY MIIDON !110 */ vindon(); break;

cue IS : cclearf (};

default : ;

I* CLIAR JILi */

} /S Slli tcb S/ ke1board3( keJ); } , ................ ,

76

!•••••••••••••••! keyboard3(key) int key; { e1tern int tv10,tv1l,tvyO, tvyl,tveO,tvel; svitch(key)

{ I* case PIRCllT : readflist(); RIAD rILILIST

break; *I case OS: displa(l); /* DISPLAY CGA *I

break; case 00: displa(O); /*DISPLAY GRAPHICS SCRlll *I

bruk; case TS: tvpos (0,639,1,479,0,0); I* CLIAR TIIT WINDOM *I

tnis (0); break;

case TO : tvpos (tv10,tv1l,tvyO, tv1l,tveO,tvel); /I OPll TIIT MIIDOM */ tnis (1); break;

case JS : aaindisp(); /I DISPLAY JILi !110 I/ f ile1(); break;

case CR : cpria(); /1 DRAW PRI!ITIYI */ break;

/1 case !S: pgdi(l); SIT CG&

}

break; */ default : ;

} /I svitch I/ keyboardUley);

, ............... , ie1board4(ke1) int ke1; { S1itch(ie1)

{

case CS: if(1do1::l) 1iD.dovs();

if(1do1::0) cursor();

clruD.( 251); ccolor(); clruD.( 251); setscn ( ) ; break;

case SS: if(1do1::l) 1iadovs();

if (1do1::0) cursor(); clrun( 251); pri1ithe(); clraD.(251); setscrD.();

break; case IS:if(1do1::l)

1iD.dovs ( ) ; if(1do1::0)

case DS:

/t case IL:

default : ; } /* sli tch •/

cursor(); clruD.(251); uodeliar( l; clraa(251); setscreea(); break;

CIOdel() j break;

break; t/

11

I* SITS COLOR *I

I* SITS SOLID •/

/t SITS IODILIIG •/

I* SITS DIBllSIOIS */

'***********************! 1ainvar()

78

{ /* SITS Y!LUIS TO GLOBAL Y!RI!BLKS */ extern int aenur,,11,f1y,,1z,cl,cli,t110,t11l,t110,t11l,tveO,tvel extern int tvf,fill,,112,,111,Yvy2,proj,ltenl,lten2; extern int ltnu1,lt1a1,col,1dov; extern int org9 1clcount,planon,tess,r1t,r1t,rzt,shad; extern int f11lp, Y112p, Yvylp, fiJ2p; extern int Yv1le, f112e, fiJle, fiJ2e; extern int ,,,1,, ,,,z,, ,,,1,, ,,,z,; extern int rcnt1, rcnty, rcntz; extern int e1ton,ssnu1,Yectotal, firstcall, ra1disk,cliston; extern int sscount,ssnu1,total,ssct,Ytot,returnYali,bop,bolcount; bolcount:O; bop:O; faceton:l; cliston:O; returuali=O; total:O; aenur:O; orgy:Q; ssct:O; Ytot:O; sscount:O; firstcall:O; eiton:l; SSDUl:O; Yectotal:O; radisk=O; ncnti:O; rcnti: O; rcnty: 0; rcnti: O; siad : 1; nllp : O; n12p : 213; nylp : 246; ny2p : 459; nlle : O; n12e : 213; nyle : 33; ny2e : 246; Hilt : 213; HI2Y : 639; HJlY : 33; HJ2Y : 459; nt:O; r1t:O;

rzt:O; tess:4; planon:O; curs=l5; clcount:O; 11do11:0; nx:O; n1:0; nz:O; col:O; cli:O; t1110:0; tnl:639; t1110:0; tv11=33; t11eO: O; tvel: 23; tn: l; nil :27; n12:613; n11=35; n12=460; proj: 50; ltenl=O; lten2:1; ltnU1= O; ltaax: 31; col=220;

79

clbeg(241); /*SITS YIIV VIIDOV roa PLAI */ projct(O); t11port(t111lp, t1112p, TllJlp, TllJ2p);

clend(); clbei(242); I* SITS YIIV WIIDOV roa ILIYATIOI */

projct(O); t11port(t111le, t1112e, t111le, ••J2e);

clend(); clbeg(243); I* SITS YIIV PORT roR SHADID !ODIL *I

pro jct( 50); tvport(tllllT, Tll2T, ,,,.1,, TllJ2T);

clend();

floahar(); }

·ls*****************I

}

80

floatnr() { I* SITS VALOIS TO FLOATING POIIT GLOBAL VABIABLIS */ extern double orgxd,orgJd,orgzd; extern double x,J,&,speed,dist,a1b,ltx,lt1,lt1; extern double heigbt,1idth,length,depthl,depth2,depth3; extern double 1inxl,1inx2,1inJl,1in12,dish,dis1; extern double orgx, orgy, orcz, rotnu1,s1,s1,sz; extern double orcxt, orgyt, orgzt,1001tal,returntal; extern double t1pt1,t1pt1, t1pt1; returnnl:O.O; ZOOlfal:l.0; orgxt=lO.O; orgyt:lO.O; orgzt=lO.O; org1d:O.O; orgyd:O.O; orgzd:O.O; 51:1.0; sy:l.0; sz:l.O; rotnu1:0.0; depthl:O.O; depth2=0.0; depth3:0.0; 1:0.0; 1:0.0; z:O.O; speed:20.0; org1:0.0; orn=O.O; org1:0.0; dist=600.0; dis1=2500.0; dish=-450.0; a.b:0.25; ltl= -UO.O; lty: -101.0; ltz: -41.0; npti :0.0; nptJ :0. 0; nptz :0.0; Rind: -284.0; 1inx2: 284.0; liDJl: -213.0; 1in12= 213.0; height: 10.0; 1idtb: 10.0; length:50.0; setupnrs();

:/ nnuunnnanuunnnnan/

setupvars( l {

81

I* SITS UP GRAPHIC SCRllM a/ e1tern int planon,vdov,vv1,vvy,vvi,cl,cli,tv10,tv1l,tv10,tvyl, tveO,tvel ; e1tern int tvv, tv1l, vv12, tvyl, vvy2, proj, ltenl, lten2; e1tern int shade,planon,ltnu1, lt1a1, col,tess; e1tern double a1b, 1,y,i, speed,dist, a1b, lt1; e1tern double lty,ltz,height, width, length; e1tern double vin1l,vin12,vinyl,viny2,dish,disy,vvpt1,vvpty,vvptz; ca(); /* COKKAIDS 11 ASClI •/ clbeg(249); /* BIGIIS COKKAMD LIST 249 •/

if (vdov ::0) clears( OJ; tvpos(tv10,tv1l,tvyO, tvyl,tveO,tvel); tnis ( tvv);

if(planon::O) cleari(O); tvpos(tv10,tv1l,tv10, tvyl,tveO,tvel); tnis(tnl; displa(O); tvport(Ylll, Yll2, YIJl, 91J2); 1indo1(1in1l, 1in12, vinyl, viny2);

if(planon::O) pro jct( proj); distan(dist); disth(dish); di sty( disy); cliph(l); clipy(l l; light(O, a1b, 31, lt1, lty, lti); li ten ( 0, 1); v1rpt(v1pt1,v1pty,v1pt1); niden();

if(planon::O) { nrotl(n1); nroty( ny); nrotl(vn); } lutint( 6); color(col); 1diden(); clend(); dispat( 4, tess); if(shade::1)

dispat(O,l); if(shade::O) dispat(2, OJ; clrun(249); }

I* CLEARS SCRlll */ I* SITS TIIT WINDON SIZI *I

I* ACTIVATIS TIIT NIIDON */

I* CLIARS INTINSITY BUfflR t/ I* SITS TIIT WINDON SIZI */

I* ACTif ATIS TIIT WINDON •/ I* ACTIVATES GRAPHICS SCRlll */ I* SITS VIIN PORT SIZI •/ I* SITS NIIDON SIZI *I

I* SITS PROJICTIOI AMGLI */ I* SITS DISTAICI */ I* SITS f ROIT CLIPPING PLAll I* SIT BACl CLIPPIIG PLAll */ I* ACTIVATES fROIT CLIPPING PLABI •/ I* &CTIYATIS BAC( CLIPPIBG PLAll a/ I* SIT LIGBTIIG DIRICTIOI •/ I* lCTif ATIS LIGHT SOORCI a/ I* SIT YIINIIG RlflRllCI POIKT •/ I* ilSITS YIINIBG KATRII *I

I* SITS I AIIS YIINIBG AMGLI •/ I* SITS Y AIIS YIINIIG !IGLI */

I* CALLS LOO( OP TABLI */ I* Dlf IllS COLOR */ I* RISITS KODILIIG KATRII •/ I* KIDS CL *I I* SITS f ACITIIG DIGRll •/

I* RUIS CL *I

windows() {

82

/t DRAWS CURSORS TO KULTI NIKDONS t/ extern int r1,rr,rz,,wr,,w1,9wz,planon; extern double win1l, win12, winrl, vinr2; window(win1l, win12, winrl, 1inr2);

niden( ); clrun(2U); nrotr(nr); nrot1(270); nrotz(O); planon:l; cursor(); cl run( 242); niden(); nrotr(nr); nrotx(O); nrotz(O); planon:2; if((••r ::0) ll (rx::O) ll (rr::O))

cursorel(); if((nr !:0) : : (n!:O) : : (rr!:O) )

cursor(); cl run( 243); niden( ); nrotx( n1); nrotr(nr); nrotz( JH); planon:O;

cursor(); }

t1aaaataaaaaaataaaaaaaa/ ccleari(bcol)

I* RISITS YIIW WINDON t/ /a ROIS CL 241 • SITS PLAI NIIDOW t/

/t ACTIYATIS PLAI YIIN t/

/t DRAWS COBSOB TO PLAN YIIW *I

/a ROIS CL 242 "SITS ILIVATIOI WINDOW a/ /a RISITS YIIN PORT •/ I* ROTATIS Y AIIS YIIN •/

/a TISTS JOB ROTATIOI t/

/t DRAMS ILIYATIOI CURSOR *I

/t llSITS YIIWPORT a/ /t IOTATIS VIIWPORT a/

int bcol; /t CLIARS IITllSITY BOffll TO GIVll COLOR •/ { printf("\ngiJe backgroundcolor: "}; scanf("Sd",lbcol); if ((bcol<O) :: (bcol>255))

bcol:O; cleari(bcol); printf("\n backgroundcolor: id ",bcol);

cleari(bcol); 11indisp(); setscrn(); }

tnnnannnann/

ra1diskf () { extern int ra1disk; rILK *cl; fILK *fl; fILI *f2; static char input 1z; radisk :1; setupf(); cl: fopeo("d:re10,e.i", "v"); fclose( cl); printf("\n RA! DISI II OPIRATIOM"); f2: fopen("co11and.d","r"); fl: fopen("d:co11and.d","1"); vhile (fgets(ioput,LI!,f2)!:MULL)

fprintf(fl, ·is",ioput); !close( fl); fclose(f2); }

!*******************************/ caodel ()

83

I* STORKS RA! DISI FILI OM DISI */

{ /* DI!llSIOIIKG rUICTIOI */ extern doable speed, vidth, height,leoght; extern int 1do1; int ch; ch : getche(); vhile(ch !=SPACI)

{ /* CASI roR DI!llSIOI CBAIGIS */ svitch(ch)

{ case !IIUS : speed -: 1.0; I* DICRKASI GRID *I

break; case PLUS : speed t: 1.0; I* IICRIASI GRID */

break; case f ODR : case LARR :

1ease4(); break;

case SII : case URR :

1ease6(); break;

case IIGBT: case UP : 1ease8();

break; case TVO : case DOVI: 1ease2();

break;

}

case URO : case 115 : 1caseO();

break; case PIRIOD: case DIL : 1caseb();

break; default . ,

printf("\n 1idth : l.2f height : l.2f ch : getche();

1•••··············1 1ease4() { extern double speed,1idth; extern int 1do1; if (wdo1::l)

windovs(); if(1do1::0)

cursor(); 1idth:1idth-speed; 1idth:abs(width); if (1do1::l)

lindo1s(); if (1dow::O)

cursor(); }

/UUUUUUUUS/ acase6() { extern double speed,width; extern int 1dow; if (1do1::l)

windo1s(); if(1do1::0)

carsor(); 1idth:width+speed; 1idth:abs(1idth); if (1dow::l)

1indovs(); if(1do1::0)

cursor(); }

!•••••••••••••••••!

84

length : l.2f grid : l.2f",1idth,height,length,speed);

I* DICKIASI WIDTH */

I* IKCRKASK WIDTH */

1case8() {

}

extern double height; extern int 11do11; if (11do11::l)

11indo11s(); if (11do11::0J

cursor(); beieht=height+speed; height:abs(heieht); if (11do11::l)

windo11s(); if(11do11::0)

cursor();

~··············••/ acase2() { extern double speed, height; extern int 11do11; if (11do11::l)

11indo11s(); if(11do11::0)

cursor(); height:height-speed; height=abs(height); if (11do11::l)

11indovs(); if (11do11::0)

cursor(); } ,, ................ , tcaseO() { extern double speed,length; extern iat 11do11; if (11do11::l)

11indo11s(); if (vdov::O)

cursor(); length:length+speed; length:abs(length); if (vdov::l)

11indovs (); if(11do11::Q)

cursor(); }

ti••••••••••••••••!

85

/t IKCRIASI HIIGHT t/

/t IKCRXASI LEIGHT t/

1caseb() { extern double speed,length; extern int 11do11; if (11do11::l)

11indo11s(); if(11do11::0)

cursor(); length= length-speed; length:abs(lengtb); if ( 11do11:: 1)

11indo11s(); if(11do11::0)

CllfSOr(); }

/c••••*******'**''/ abs(x) double x; ( doable 1; 1:(x<0)?-1:x; ret11rn 1; }

!••*******************/ 1center() { extern int curs,1do11;

86

/S DICRIASI LINGHT */

I* RITURIS ABSOLUTE VALUI *I

I* RISITS !ODILIIG !ATRII AID CllTKRS CURSOR *I

extern double orgx,orgy,org1,orgxd,org1d,org1d; extern doable sx,s1,s1,1,1,1,xf,1f,1f; e1tern int ra1disk,rx,r1,r1,rc1t1,rcnt1,rcnt1; nu •cl;

ldiden(); curs=l5; if (radisk::O) cl: fopen("coll&ind.d", ·a·); if ( raldisk:: 1) cl : fopen("d:co11and.d", "a");

fprintf(cl, "\nldiden\n"); fclose(cl); sx:l. 0; s1:1. O; 51:1.0; 1:0.0; 1=0.0; 1:0.0;

I* RISITS !ODILIIG !ATRII */

I* OPllS CO!!AID LIST f ILi */

I* CLOSIS flLI t/ /t RISITS SC&LIIG f &LUIS */

I* SITS CURSOR TO ORIGII t/

If:O.O; 1f:O.O; zf:O.O; n:O; rf=O; n:O; rcnti:O; rcnt1=0; rcnti:O; orgx:O.O; orgy:O.O; orgz:O.O; orgxd:O.O; orgyd:O.O; orgzd:O.O; setupnrs(); setupf ();

/t••·····················••! cclears() { extern int bcol; cursor(); clears (bcol); cursor(); }

!•••·························1 cupt() { extern double x,1,z; extern double Y1ptx,Y1pt1, •1pt1;

nptx:x; npty:1; nptz:z; setupf (); getf ile(); }

87

/t ROTATIOI VALUIS ARI SIT TO ZIRO */

/t ROTATIOI ORDliS Ail ilSIT t/

/t KODILIIG ORIGII IS RISIT */

I* CLIAiS SCilll */

I* SIT CORRllT IYZ LOCTIOI TO VIIM RlflRllCI POIIT */

''************************! cclearf () { e1tern int 1do1,curs; e1tern doable s1,s1,s1,1 11,1,1f,1f,1f;

88

I* CLIARS CORRIMT COKKAMD LIST JILi t/

e1tern int raldisk,r1, rJ, r1,rcnt1,rcnt1 ,rcntz; e1tern doable 1in1l,1in1l,1in12, 1in12; e1tern int Y11lp, Y112p, YIJlp, YIJ2p; e1tern int Y11le, Y112e, YIJle, YIJ2e; e1tern int Y11lY, Y112Y, YIJlY, YIJ2Y; e1ter1 int fill, fll2, YIJl, YIJ2; e1ter1 doable org1d, org1,or11d; extern doable or11, org1d, org1; e1tern int Yll,YIJ, Y11;

fILI •cl; if (r11disk::O)

cl: fopen("co11and.d", "•"); if (r11disk::l)

cl : fopea("d:co11aad.d", "1");

fpriatf(cl,"\n"); fclose( cl); n1:0; HJ=O; n1:0; nidea(); u:l. O; s1:1. O; sz:l.O;

n:O; r1:0; n:O; rcat1:0; rcat1=0; rcatl=O; 1:0.0; 1=0.0; 1:0.0; lf:O.O; 1f:O.O; af:O.O; or11d:O.O; org1:0.0; orad=O.O; ora:O.O; orad:O.O; ora=O.O;

I* OPllS llLI a/ /I CLIABS JILi I/

/a CLOSIS JILi I/

I* IODILIIG f !LOIS !II llSIT I/

1diden( l; clears( OJ; cleari( 0);

1aindisp(); setscrn();

if(1do11::0) { linfun(O); color(250); IOYe(11in1l,iin1l); rect(1ln12, &inJ2); }

if(vdog::l)

89

/t BORDIRS ARI RIDRAWI •/

{ /t BORDIRS ARI RIDRAWI TO KULTIPLi NIIDONS •/ Yiport(Yllllp, Yil2p, YiJ}p, YiJ2p);

linfun(O); color(250); IOYe(iin1l,iiDJl); rect(&in12, &iny2);

Yiport(Yiile, Yi12e, Yiyle, YiJ2e); linfun(O); color(250); 10Ye(11in1l,&inyl); rect(&in12, &iny2);

Yiport(Yillf, fil2Y, YllJlY, fiJ2Y); linfun(O); color(250); IOYe(iiDil,iinyl); rect(1in12, &iny2);

}

Jt••···············••! /itttttttttttttttttttttttt/ /t CLIARS CORRllT COKKAID LIST f ILi t/ reset() { extern int &do1,curs; extern double s1,sy,s1,1,7,1,1f,Jf,1f; extern int raldisk,r1, rJ, r1,rcnt1,rcnty ,rcntz; extern double 1in1l,&inyl,&i112, &in12; extern int •11lp, •1112p, ••Jlp, ••J2p; extern int ••1le, YiI2e, •111le, •1112e; extern int YillY, Yil2t, YIJlY, YIJ2Y; e1tern int t11l, t112, YiJl, ••12; extern double org1d, org1,or11d; extern double orgy, org1d, org1; extern int t11,tiJ, •11;

FILI •cl; setscrn(); if (raadisk::O)

cl: fopen("co11and.d", "a"); if ( raadisk:: 1)

cl : fopen("d:co11and.d", "a'); fprintf(cl, "\n1diden'); fclose(cl); if( (Yu!:O):: (n1!:0):: (nz!:O))

{ niden(); n1:0; n1:0; nz:O;

getf ile(); }

51:1.0; s1:1.0; sz:l.0; rx:O; r1:0; rz:O; rcnt1:0; rcnt1:0; rcntz:O; x:O.O; 1=0.0; z:O.O; xf:0.0; 1f:O.O; zf:O.O; org1d:O.O; org1:0.0; orad:O.O; org,:0.0; orgyd:O.O; orn=O.O; adiden(); if(vdoir::O)

{ clears(O); dispi(O); }

if(vdoir::l) { dispi( 0); }

aaiDdisp(); setscrn(); }

/attttttttttaaaaaaaat/

90

!• OPKMS fILX •/ !• CLEARS FILI •/

/t CLOSIS FILI •/ I* TIST If YIIV MIIDOM ACTIVI *I

I* !ODILIIG YALDIS Ail RISIT */

!• DISPLAYS !Aii !KID •/

91

/*******************/ aorgset()

I* !ODILING ORIGIN IS SIT */

{ extern double 1,y,z,1f,yf,zf,org1,orgy,orgz; extern int rz,r1,r1,curs,org•,cursnu1; extern double orgxd,orgyd,orgzd; extern double org1,orgy,orgz; int ch;

org•=l; setscrn();

if(n !=O:: rx!:O: :r1!=0l { adiden(); rz:O; ry:O; rx:O; orgxd:O.O; orgyd:O.O; orgzd=O.Q; orgy:y; orgx:1; orgz:z; 1dtran(1,y, z); }

orgxt:1; or11t=1; orgzt:z; setscrn(); cursnua:curs;

I* TIST roa ROTATIOM VALUIS */ I* If ROTATION IS ACTIYI !UST BISIT */

I* STORKS DlflBIMCI II CURS LOCATIOK AND !ODILIMG ORIGIM */

I* STORKS CURRIMT LOCATIOM */

I* ACTIVATES CURRllT LOCATION *I

curs:15; /* SITS CURSOR TO CROSS BAIR *I cb:getche(); VMPORT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); vhile(ch !:SPACIJ

{ svitch(ch)

{ case !IIUS : speed -: 1.0; /t DICRl!SI GRID *I

break; case PLUS : speed +: 1.0; /t IICRIASI GRID */

break;

case roaa : case LARR : left();

break; case Sii : case RARR : ritht();

break;

}

case UGBT : case OP : up();

break; case TWO : case DOVR : down();

break; case URO : case IMS: forward();

break; case nu : case PGOP: upright();

break; case Slill : case BOBK : upleft();

break; case 011 : case KID : do1nleft();

break; case TBRI!: case PGDI :downright();

break; case PHIOD : case DKL : back();

break; defa11lt: ; }

YVPOiT(0,639,0,479); 1indo1(0.0 , 639.0, 0.0, 479.0); ch:getche(); }

orc•=O; orr1:1+org1d; oru=1+orgyd; orgz:z+orgzd; cars:carsn111;

/**********************************!

92

,. THIS SIT or fOHCTIOHS DRAMS A SOLID TO THI SCRlll •/

Sinclude "std.h" linclude <fcntl.h> linclude <sys\types.h> linclude <sys\stat.h> linclude <io.h> linclude <stdio.h> ldef ine LIB 40

·/ UUUUUUUUU/ cpri1() { extern int •111lp, •1112p, •111lp, •1112p; extern int •111le, •1112e, •111le, •1112e; extern int •vxlv, •1112•, •1111•, •1112•; extern int •1111, •1112, •1111, •1112; extern int curs,•11x,•111,•11z,planon,shad,tess; extern int rz,r1,r1,10rg,displ, disp2,11do11,col; extern double 11inxl,11in1l,11in12, 11in12; extern double x,1,z,1f,1f,zf; extern double height,11idth,len1th; extern double org1, org1, orcz; extern double 1d,1d,zd; rILI •cl; 1d:1; 1d=1; zd:z; tnis(O); if(11do11::l)

{ 11indo11s(); linfun( 0); 11irefr(2, 0); niden(); Yllport(Yllllp, flll2p, f111lp, fl12p); projct(D); dispat(4,tess); nrot1(n1); nroti(270); cpri1f(); niden(); •vport(•vxle, •vx2e, •11le, •1112e); nrot1(n1); nrot1( 0); dispat(4,tess); cprilf (); Yvport(YillY, YII2Y, •111•, •112•); projct(50); dispat(4,tess);

93

I* STORKS POIIT LOCATIOI *I

I* TUilS orr TllT WINDOW •! I* TISTS fOi BULTIPLI MIIDOWS •/

I* IRASIS CURSOR *I !• PilPAilS roR PLAI DRAMIIG */

I* DRAWS SOLID TO SCRlll */

!• SIT UP roa ILIVATIOI •/

I* DRAWS SOLID TO SCRlll t/ I* SITS UP PliSPICTIVI VllW */

dispat(O,sbad); cpri1f (); dispi(OJ; color(255); color( col); }

if (11do11::0) { y11port(Yv1l, •v12, •vrl, •vr2); cursor(); if(planon::l :: planon::2)

{ dispat(4,tess); cprilf (); linfun( 0); virefr(2, 0); projct(O);

} if (planon::O)

{

}

pro jct( 50); dispat(O,shad); cpri1f(); dispi(O);

} cpri12();

if(planon::OJ *I { dispi(O); }

if (vdov::O) {

}

cursor(); •1port(•11l, ,,,2, Tvyl, ••r2); 10fe(vin1l,11inyl); rect(vin12, 1iny2); color( col);

if( vdov:: 1) { vindovs(); color(250); •11port(•111le, •1112e, •vyle, •1112e); 10fe(11in1l,11i1yl);

94

I* TORRS OM SHADING */

I* SITS YIKMPORT */

I* TISTS roR PLAN OR ILIYATIOI */

I* DRAMS II MIRKFBAMI *I

I* TISTS FOR PIRSPKCTIYI */

I* DRAMS II SHADID MODI */

I* BRAICBIS TO cpri12 JOICTIOM */ I* cpri12 f ILIS SOLID TO COMMAID LIST MITH ATTRIBOTKS

I* RIDRAMS SRKll BORDIR */

rect(vinx2, 1iny2); Ylport(YIXlp, YIX2p, Ylylp, Yl12p); 10Ye(1inxl,1in1l); rect(vinx2, 1in12); Ylport(YlllY, Yll2Y, YIJlY, Yl12Y); pro jct( 0); linfun( 0); lirefr(2, 0); 10Ye(1inxl,1in1l); rect(vinx2, 1in12);

} tnis(l);

} , ................... , cpri12() {

95

I* STORKS SOLID COKKAMDS TO COKKAMD LIST t/

e1tern int r&,r1 1 rx,10r&,displ, disp2,1do1,col,bop; extern double 1,1,z,xf,1f,1f; e1tern double beigbt,1idtb,len1tb; double 1t,1t,1t,12 112,z2; extern double s1,s1,s1,org1, orCJ, orcz; e1tern int r1d,r1d,rzd,firstcall,curs,raldisk; rILI tcl; extern int bolcount;

12:1; 12=1; z2:z; 1t:12-d; 1t=12-1f; zt=&2-d; d:l2; 1!=12; d:z2; nd:380-n;

r1d=360-r1; rzd:360-rz; if(bop!:O)

{ cl: fopen("sub.i","a");

bole11(cl); }

if((raldisk::O)ll(bop::O)) cl : fopen("co11and.d", "a");

if((raldisk::l)ll(bop::Q)) cl: fopen("d:co11and.d", "a");

/t CALCDLATIS DISTAICI fBOK LAST POIIT t/

/t CALCULATES DlfflRllCI II ROTATION TO !All A FOLL CIBCLI t/

!• TIST roa RAB DIS( 01 ., /t OPll APPROPRIATI JILi t/

96

if(bop::O) { if(firstcall !:O : : curs !=8) I* TIST fOR rIRST INTRY */

}

fprintf(cl, "locate t.lf, t.lf, t.lf\n" 1111,1); fprintf(cl, "1dtran t.lf, S.lf, S.lf\n",1t,1t,zt);

I* NRITIS I y z COORDIN&TI or SOLID *I I* WRITIS DISTAICI f RO! LAST POINT */

if(s1!:l.O) /* TIST fOi ACTIVI SCALI fOHCTIOR t/ { fprintf(cl, 0 1dorg t.lf,X.lf,X.lf\n" ,org1,orgy,orgz); /t WRITIS !ODILING ORIGIN TO rILI t/ fprintf(cl,"ldscal X.2f,X.2f,S.2f\n°,s1,s1,s1); I* NRITIS SCALI VALUI or SOLID t/

} if((r1 !: 0) ll ( ry::O) ll (rz::O)) /* TIST rOR I ROTATION VALDI */

{ fprintf(cl, "ldorg X.lf,S.lf,S.lf\n°,org1,orgy,org1); /t PRINTS VALUI TO CO!!AND LIST t/ fprintf(cl,"1drot1 td\n",r1);

} if((ry !: OJ ll ( r1::0) ll (rz::O)) /t TIST fOR Y ROTATION VALDI t/

{ fprintf(cl, 0 1dorg S.lf,S.lf,S.lf\n" ,org1,org1,orgz ); fprintf(cl,"ldroty td\n",ry); I* PRIITS VALDI TO CO!!AID LIST*/ }

if((r1 !: 0) ll ( rx::O) ll [ry::O)) /t TIST fOi i iOTATIOI VALOI t/ { fprintf(cl, 0 1dorg S.lf,S.lf,t.lf\n°,org1,org1,org1 ); I* PRINTS VALDI TO CO!!AND LIST t/ fprintf(cl,"ldrot1 Xd\n',r1); }

frcnt1a(cl); /* TIST fOR ORDIR Of IIICOTIOI t/ frcntya(cl); frcntza(cl); filepri1(cl); /* fILIS SOLID TO CO!!AID LIST t/

if((r1 !: 0) ll ( ry::O) ll (rz::O)) ST */ { TDillD BACl t/ fprintf(cl, "ldrot1 ld\a",r1d); }

if((rJ !: 0) ll ( rx::O) ll (rz::O)) { fprintf(cl, "ldroty Xd\n" ,ryd); }

if((r1 != 0) ll ( rx::O) ll (ry::O)) { fprintf(cl, "ldrot1 Sd\a",rzd); }

/t TBISI fOKCTIOKS NRITI TO TRI CO!!AID LI

I* TBI A!ODIT THI !ODILING !ATRII !OST Bl

97

frcntxb(cl); /t CBICIS THI KIICOTIOM ORDKR •/ frcntyb(cl); frcntzb( cl); if(sx!:l.0)

{ fprintf(cl,"1dorg S.lf,S.lf,S.lf\n",orcx,or11,org1); /t SC&LIS !ODILIIG !ATRII BACI

TO OH•/ fprintf(cl,"ldscal S.2f,S.2f,S.2f\n" ,(l.0/sx),(1.0/sx),(1.0/sx));

}

fclose(cl); }

!••••••••••••••••••! olean(cl)

nu •cl; {

extern int col,bolcount; extern double x,y,1;

if(bolcount::O) { color(32); fprintf(cl,"\nsolbop l"); }

fprintf(cl, "\nldiden"); fprintf(cl, "\n1dtran S.lf, S.lf, S.lf\n",x,1,1); bolcount++; }

/\••••••••••••••••••/

!• WRITES I J z COORDIIATI or SOLID •/

frcntxa(cl) /• CBICIS IIICOTIOI ORDIR •/ rILI •cl; { extern int rcntx,rcnt1,rc1t1; extern int r1,r1 1 rx,10rc; extern double x,J,1,xf,Jf,1f; extern double orcx, or11, orgz; if (rcntx::l)

{ if((rcaty::2)ll(rcnt1::0) )

{ fprintf(cl,"ldori S.lf,S.lf,S.lf\n",or1x,or11,org1); fprintf(cl,"ldrotx ld\n",rx); fprintf(cl,"ldrotr ld\n",ry); }

98

if((rcnt1==2Jll(rcntz::3) ) { fprintf(cl, "ldorg X.lf,%.lf,l.lf\n" ,org1,orgy,orgz); fprintf(cl,"ldroti Xd\n",ri); fprintf(cl,"adrot1 ld\n",ry); fprintf(cl, "1drotz Xd\n" ,rz); }

if((rcntz::2)ll(rcnt1==0J { fprintf(cl, "adorg %.lf,%.lf,X.lf\n" ,org1,orgy,orgz); fprintf(cl, "adrot1 Xd\n",r1); fprintf(cl, "adrotz ld\n" ,rz); }

if((rcntz::2)ll(rcnt1==3) { fprintf(cl, "adorg l.lf,%.lf,%.lf\n°,org1,orgy,orgz); fprintf(cl,"adrot1 Xd\n" ,r1); fprintf(cl, "1drot1 Xd\n" ,rz); fprintf(cl, "1drot1 Xd\n" ,ry); }

} '*******************/

frcntib(cl) lILI •cl;

{ extern int rcnt1,rcnt1,rcntz; extern int r1d,r7d,r1d,t0rg; extern double 1,1,1; extern double org1, org1, orgi; if (rcnti==l)

{ if((rcnty::2)ll(rcntz::O)

{ fprintf(cl, "adroty Xd\n",ryd); fprintf(cl, "adrotx Xd\n" ,rid);

} if((rcnt1==2)ll(rcntz::3)

{

}

fprintf(cl, "1drot1 Xd\n" ,rzd); fprintf(cl,"adroty Xd\n",ryd); fprintf(cl, "ldrot1 ld\n",rid);

I* ROTATIS BACI KIICOTIOI ORDIR FOR I*/

if((rcntz::2)ll(rcnty::O) { fprintf(cl, "1drotz ld\n",rzd); fprintf(cl, "ldrot1 ld\n",r1d);

} if((rcntz::2)ll(rcnty::3)

{

}

fprintf(cl, "1droty ld\n" ,ryd); fprintf(cl, "1drota ld\n" ,rzd); fprintf(cl, "1drot1 ld\n" ,rid);

} }

Ii••··············••! frcntya(cl) FILI •cl; { extern int rcnt1,rcnty,rcntz,rz,ry,r1,1org; extern double 1,y,z, org1, orgy, orgz; if (rcnty::l)

{ if((rcnt1::2)ll(rcntz::O)

{

99

/t ROTATES BACl lllCOTIOM ORDKR FOR Y•/

fprintf(cl, "1dorc l.lf ,l.lf,l.lf\n" ,org1,orgy,orgz); fprintf(cl, "ldroty ld\n" ,ry);

}

fprintf(cl, "ldrot1 ld\n" ,r1); }

if((rcnt1::2)ll(rcntz::3) { fprintf(cl, "1dorg l.lf,l.lf,l.lf\n" ,org1,orgy,orgz); fprintf(cl, "1drot1 ld\n",ry); fprintf(cl, "ldrot1 ld\n" ,r1); fprintf(cl, "ldrot& ld\n" ,rz); }

if((rcntz::2)ll(rcnt1::0) { fprintf(cl,"1dorf l.lf,l.lf,l.lf\n",or11,orgy,orgz); fprintf(cl, "ldroty ld\n",ry); fprintf(cl, "ldrotz ld\n",rz); }

if((rcntz::2)ll(rcnt1::3) { fprintf(cl, "1dorg l.lf,l.lf,l.lf\n" ,org1,orgy,orgz); fprintf(cl,"ldroty ld\n",ry); fprintf(cl, "ldrotz ld\n",rz); fprintf(cl, "ldrot1 ld\n",r1); }

!*****************'/

frcntyb(cl) FILI •cl; { extern int rcnt1,rcnty,rcntz, r1d,ryd,rzd;

if (rcnty::l)

}

{ if{(rcnt1::2)ll(rcntz::0))

{ fprintf(cl, "adrot1 ld\n" ,rid); fprintf(cl,"adroty ld\n" ,ryd); }

if{(rcnt1::2)ll(rcntz::3)) { fprintf(cl,"adrotz ld\n",rzd); fprintf(cl,"1drot1 ld\n" ,rid); fprintf(cl,"1droty ld\n",ryd); }

if((rcntz::2)ll(rcntx::0)) { fprintf(cl,"1drotz ld\n" ,rzd); fprintf{cl, "adroty ld\n" ,ryd); }

if((rcntz::2)ll(rcnt1::J)) { fprintf{cl, "adrot1 ld\n" ,rid); fprintf(cl, "ldrot1 ld\n" ,rzd); fprintf{cl, "ldroty ld\n" ,ryd); }

100

/*******************/ frcntza(cl) I* ROTATIS BACI IIICOTIOI ORDIR fORt/ FILI tel; { extern int rcnt1,rcaty,rcnt1,r1,ry,r1; extern doable 1,y,z,1f,yf,1f 1 or11, orgy, orgi; if (rcnti::l)

{ if((rcnt1::2)ll(rcnty::O))

{ fprintf(cl, "ldor1 l.lf,l.lf,l.lf\1",or11,orgy,org1 ); fprintf(cl, "ldroti ld\n" ,ri); fprintf(cl, "ldrot1 ld\n",r1); }

101

if((rcnt1::2)ll(rcnty::3)) { fprintf(cl,"ldorg S.lf,S.lf,S.lf\n",org1,orgy,orgz ); fprintf(cl, "1drot& Sd\n" ,r&);

}

fprintf(cl, "1drot1 Sd\n" ,r1); fprintf(cl, "1drot1 Sd\o",r1); }

if((rcoty::2)ll(rcot1::0)) { fprintf(cl,"1dorg S.lf,S.lf,S.lf\n" ,org1,org1,orgz ); fprintf(cl, "1drot1 Sd\n",r1); fprintf(cl, "ldrotJ Sd\n" ,rJ); }

if((rcoty::2)ll(rcnt1::3)) { fprintf(cl,"ldorg S.lf,S.lf,S.lf\o",org1,org1,org1 ); fprintf(cl, "ldrotz Sd\n",rz); fprintf(cl,"ldrotJ Sd\n",r1); fprintf(cl, "ldrot1 Sd\n",r1); }

!•••••••••••••••••••! frcntzb(cl) lILI tel; { e1tern int rcnt1,rcnt1,rcntz; e1tern double org1, or(J, orgz; extern int r1d,r1d,rzd; if (rcntz::l)

{ if((rcnt1::2)ll(rcnt1==0)

{ fprintf(cl, "ldrot1 Sd\1",r1d); fprintf(cl, "ldrotz Sd\a" ,rzd); }

if((rcnt1::2)ll(rcnt1::3) { fprintf(cl,"ldrotJ Sd\1°,rJd); fprintf(cl,"ldrot1 Sd\1" ,rid); fprintf(cl, "1drotz Sd\a",rzd); }

if((rcnt1==2)ll(rcnt1::0) { fprintf(cl,"ldrotJ Sd\n",ryd); fprintf(cl,"adrotz Sd\n",rzd); }

}

if((rcnty::2)&l(rcntx==3) { fprintf(cl, "1drot1 ld\n",r1d); fprintf(cl, "ldroty Sd\n" ,ryd); fprintf(cl, "1drotz Sd\n" ,rzd); }

102

.,, .................. , fl lepri1( cl) r1u •cl;

{ nt1 •f2; extern double 1,y,z; extern double rotnu1,height,1idth,length; extern int firstcall, Jectotal,curs; static char input••;

I* FILIS SOLID TO COKKAID LIST */

t if(curs!:8)

*I fprintf(cl, "locate S.lf, S.lf, S.lf\n" ,1,y,z);

if(curs::l) { fprintf(cl, "psolid }

if(curs::2) { fprintf(cl, "psolid }

if(curs::J) { fprintf(cl,"psolid }

if(curs==4) { fprintf(cl, "psolid }

if(curs::5) { fprintf(cl,"psolid }

if(curs::6) { fpriatf(cl, "psolid }

I* rILIS BLOC( •/

4, S.lf, S.lf,S.lf\n", 1idtb,height,lengtb);

I* rILIS CTLIIDIR */

0, S.lf,S.lf\n", iidtb/2.0,height);

!• lILIS TOBI */

6, l.lf, l.lf,l.lf\n", leagtb/2.0,iidth/2.0, height);

I* FILIS SPHIRI */

2, l.lf\1°, heigbt/2.0);

I* f ILIS TORUS */

3, l.lf, l.lf\n", length/2.0, iidth/2.0);

I* fILIS COii *I 1, S.lf,S.lf,S.lf\n", iidth/2.0,length/2.0, height);

103

if(curs::7) /* PILKS WKDGK */ { fprintf(cl, "psolid 5, l.lf, l.lf,l.lf\n\n" ,vidth,height,length); }

if(curs::8) {

if(firstcall ::OJ { fprintf(cl, "\nclbec l\n");

f2: fopen("ssolid.d", "r"); T */

vhile (fgets(input,LIB,f2)!:BOLLJ fprintf(cl, "ls" ,input);

fclose(f2); firstcall ++; fprintf(cl,

"\nclend l\n"); fprintflcl."locate l.lf. l.lf. l.lf\n".x.r.zl:

}

l hrintflcl. "clrun l\n"l:

I lUUUU1UUUUUUUU/ cpri1f() { extern int col,bop,curs; extern double hei1ht,vidth,length;

if(curs::l) { block(4,vidth, height, lencth);

} if(curs::2)

{ colu1a(O, vidth/2.0, height);

} if(curs::3)

{ tube(8,length/2.0,vidth/2.0, height); }

I* TIST POR PIRST KHTRY */

I* VRITIS SVKPT SOLID YIRTICKS TO COBB&MD LIS

I• WRITES I T z COORDIR&TI or SOLID .,

if(curs::4) { sphere(2,height/2.0); }

if(curs==5l { toros(3, length/2.0, vidth/2.0); }

if(curs::6) { cone{l,vidtb/2.0,length/2.0, height); }

if(curs::7) { vedge{5,vidtb, height,lengtb); }

if(curs::8) {

printf("\n IIICDTI CLCORS \n"); clrun(l); }

} , .................... , col2() { e1tern doable ftar,ftarl,ftar2,ftar3; colo1n(O,ftar2, ftar3); printf("\ncolu11 l, S.lf, S.lf", ftar2,ftar3); } , ................... ,

spbere2() { e1tern double ftar,ftarl,ftar2; sphere( 2, fyar2); printf("\nsphere 2 S.lf", ftar2); }

/i1uua11u1111111 /

104

105

t••rOICTIOMS II THIS SICTIOI DIAL MITH lllCOTIOI or TBI COKKAHDS rBOK THI DISI •/ linclude <fcntl.h> linclude <s1s\types.h> I* DlfIKIS llTIRIAL fILIS •/ linclude <sys\stat.h> linclude <io.h> linclude <stdio.h> linclude "std.h" linclude <s1s\t1pes.h> linclude <io.h> linclude <string.h> linclude "co1aands.h" char sign; int i•ar,iYarl,i•ar2,i•ar3,i•ar4.i•ar5,i•ar6,count, clcount; /* llTIRIAL VARIABLIS •/ double f•ar,f•arl,fYar2,f•ar3,f•ar4,f•ar5,f•ar6; double icon, Jeon, icon; , .................. , 1yzsend() /I STORIS IT Z LOCATIOI or CURSOR•/ { e1tern double icon, JCOn, zcon, l, ,, z; 1con:1; 1con:y; zcon:z;

} 1 ••••••••••••••••• ,

11zreturn() { e1tern double icon, JCOll, ZCOll, l, ,, z; 1: icon; y: Jeon; z: zcon; } , .................. ,

/aatttttttttttttttttt/ fu1c1( i1put) char input10; { distant( input); li tenf (input); lightf (input); t1idenf( input); t1rptf( input); t1rptf(input); lutintf(input); colorf(input); adidenf(inpat); adtranf( input); solidf (input);

/t ilTOilS I T Z CURSOR LOCATIOI t/

/t ACTIYATIS COBBAIDS If BATCH OCCORS *I

rot1f(input); scalf (input); rot1f (input); rotzf( input); orgf (input); nrotyf( input); solbegf( input); solendf(input); solbopf(input); solrunf (input); clbegf (input); clendf(input); clrunf(input); }

''******************! fllnc2(input) char inputu; { caf (input); clearsf(input); clear if( input); tvposf (input); tnisf (input); displaf(input); nportf(input); vindod(input); projctf(input); distaDf(input); li tenf (input); lightf( input); nidenf (input); nrptf (input); nrptf( input); nrotd( input) i nrot1f (input) i nrotzf(input); lutintf( input); colorf (input); tdidenf (input); tdtranf( input); solidf(input); dispatf( input); rot1f(input); scalf(hput); rot1f(inp11t); rotzf (input); orgf (input); solbegf( input);

106

solendf(input); solbopf(input); solrunf(input); clbegf( input); cleadf( input); clrunf (input); }

107

!t••••••••••••••••••! solrunf(input) I* &CTIY&TIS SOLROI COBBl&D t/ char inputu; { extern int count,i•arl; if (((strc1p(input,SOLROK):: 0)) ll (count< 1))

{ sol run( harl); printf("\nSOLROI Sd",i•arl); count++; }

solbeaf(input) char inputu; { extern int count,iYarl;

I* &CTIY&TIS SOLBIG COBBl&D */

if (((strc1p(input,SOLBIG):: 0)) ll (count< 1)) {

}

sol beg( inrl); printf("\nSOLBIG Sd",i•arl); count++; } , ................... ,

soleadf(input) char inputu;

{ e1tern int count;

I* &CTIY&TIS SOLllD COBBl&D */

if (((strc1p(input,SOLllD):: 0)) ll (count< 1)) { solend(); printf( 0 \1SOLllD "); count++; }

108

!••******************/ solbopf(input) !• ACTIYATIS SOLBOP CO!!M&D •/ cbar inputu; { eitern int count,ifarl; if (((strc1p(input,SOLBOP):: 0)) ll (count< lll

{

}

solbop(iurl); printf("\nSOLBOP Sd",irarl); count++; }

/••*******'*****''''/ solidf(input) I* lllCOTIS PRI!ITIYI CO!!&IDS *I cbar inputu; { eitern double frar,frarl,frar2, fJar3,ffar4; eitern int ifar; eitern int couat; COOIT 0111; if (((strc1p(input,PSOLID):: 0))) { if(inrl :: 0)

{ na1:0; printf("COLO!ll S.lf, S.lf\n" ,fJar2, fJar3); col2(); }

if(inrl :: 1) { cone(!, fJar2, fJar3,fJar4); printf("COll S.lf, S.lf, S.lf\n",fJar2, fJar3,fJar4); count++; }

if(inrl :: 2) { spbere2(); printf("SPBIRI S.lf\n",fJar2); coant++; }

if(inrl :: 3) {

}

torus(3, fJar2, fJar3); printf("TOROS S.lf S.lf\n",frar2,fJar3); count++; }

solidf2( input); }

109

/'*******************/ solidf2(input) /* IIKCDTKS PiIKITIYK COKKAKDS *I char inputu; { extern double f•ar, fyarl, fyar2, f•ar3, f•ar4; extern int inr; extern int count; coon nu1; if ( i nrl ::4)

{ block( 4, f•ar2, ffar3, fyar4); printf("BLOC( l.lf, l.lf, l.lf\n",f•ar2, f•ar3,fYar4); counttt; }

if(inrl ::5) { vedge(5, f•ar2,f•ar3,fYar4); printf("WIDGI l.lf l.lf l.lf\n",f•ar2,f•ar3,f•ar4); counttt; }

if(harl :: 6) {

} }

tube(6, f•ar2,f•ar3,f•ar4); printf("TDBI l.lf l.lf l.lf\n" ,f•ar2,f•ar3,f•ar4); counttt;

!******************! dispatf (input) I* IIICDTIS DISPAT CO!!AMDS */ char inpotu; { extern int i•ar,i•arl,i•ar2; extern int count; if (((strc1p(input,DISPATl== 0)) &l (count< 1))

{ if(inrl :: 0)

{ /* lllCDTIS SBADIIG CO!!AIDS *I dispat(O, i•ar2); printf("dispat ld, ld\n",i•arl,i•ar2); count++; }

if(harl :: 1) { dispat{l, iYar2); /S lllCDTIS TRAISLDCllCT CO!!AIDS s/ printf{"dispat ld, ld\n" ,i•arl, ivar2); count++; }

if(i•arl :: 2) {

110

dispat(2, i•ar2); printf("dispat ld\n",i•ar2);

I* lllCOTIS MIRIJRA!I CO!!AIDS •/

count++; }

if(i•arl :: 3) /* IIICUTIS BACIJACI CO!BAIDS •/ { dispat(3, i•ar2); printf("dispat Sd Sd\n" ,i•arl,i•ar2); count++; }

if (i•arl ::4) /* lllCUTIS J&CIT CO!!&MDS •/ { dispat(4, i•ar2); printf("dispat ld, Sd\n" ,iYarl, i•ar2); count++; }

} 1~················••1 1dtranf(input) /l lllCUTIS TRAISL&TIOM COB!ANDS */

char input11; { e1tern double fYar,f•arl,fYar2,f•ar3; e1tern int count; if (((strc1p(input,!DTR&I):: 0)) ll (count< 1))

{ 1dtran(f•arl, fyar2, fyar3); printf("1dtrantest\n");

count++; }

1···················1 1didenf(input) char input11; { e1tern int count;

I* IIICUTIS !ODILIIG B&TRII RISIT CO!BANDS •/

if (((strc1p(input,!DIDll):: 0)) ll (count< 1)) { printf("1dtest\n"); ldiden(); count++;

}

111

'*******************! colorf(input) /* lllCDTIS COLORT CO!!ANDS *I char input11; { extern int iYar,iYarl; extern int count; if (((strc1p(input,COLOR):: 0)) AA (count < 1))

}

{ printf("coltest\n"); color(inrl); count++;

}

'*******************! lutintf(input) /* KIICDTIS LDT SIT CO!!ANDS */ char inputu; { extern int iYar,iYarl; e1tern int count; if (((strc1p(input,LDTIIT):: 0)) AA (count< 1))

}

{ printf("luttest\n"); lo tint( 6); count++;

}

1 ••••••••••••••••••• , Y1rot1f(input) /* lllCOTIS YIIM MIIDOM ROTATI % COBBAIDS */ char input10; { extern int iYar,iYarl;

exter1 int count; if (((strc1p(input,YVROT%):: 0)) ll (cou1t < 1))

{ printf("y11test\n"); nrot&(iurl); count++; }

}

···············••••! Y1rot1f(input) /* IIICDTIS VIIV VIIDOM ROTATI T COBBAIDS *I char i1p11t11; { extern int iYar,iYarl; e1ter1 int count;

if (((strc1p(input,YNROTY):: 0)) ll (count< 1)) { printf("vv1test\n"); nrot1( harl); counttt;

} }

4••••***************1

112

vvrot1f(input) /* IIICOTIS YIIW MIIDOW ROTATI I CO!!ANDS *I char input10; { e1tern int ivar,iYarl; e1tern int count; if (((strc1p(input,YNROTI):: 0)) ll (count < 1))

}

{ printf("vv1test\n"); nrotl( ivarl); count++; }

'*******************/ nrptf(input)

char inputu; {

I* IIICOTIS VIIN RlflRllCI POIIT CO!!AIDS •/

e1tern double fyar,fvarl,fYar2,fvar3; e1tern int count; if (((strc1p(input,YNRPT):: 0)) ll (count < 1))

{ printf("y1rptest\n"); Yirpt(fYarl,fvar2,fvar3); count++; }

} 4••••••••***********1

nidenf(inp11t) char inputu;

{ e1tern int co11nt;

I* IIICOTIS f IIW NIIDON RISIT CO!!AIDS */

if (((strc1p(input,fWIDll):: 0)) ll (count< 1)) { printf("Y1test\n"); niden(); count++; }

113

'~******************! !••******************/

lightf(input) char input11;

/t lllCOTIS LIGHTING ATTRIBUTIS CO!!ANDS t/

{ e1tern int iYar,ivarl,ivar2,ivar3,ivar4,itar5,ivar6; e1tern double ftar,ftarl; e1tern int count;

if (((strc1p(input,LIGBT):: 0)) ll (count< 1)) { printf("lighttest ld, l.2f, ld, l.lf, l.lf, l.lf\n",iYarl,fYar2,iYar3,fvar4,fYar5,ftar6); light(iYarl,ftar2,itar3,f,ar4,fYar5,ftar6); count++; }

} littttttttttttttttttt/

litenf(input) /t IRABLIS LIGHTING MU!BKR CO!!AMDS t/ char input11; { e1tern int itar,itarl,1Yar2; e1tern int count;

if (((strc1p(input,LITIM):: 0)) ll (count< 1)) { printf("litentest\n"); liten(itarl,itar2); count++; }

} !********************!

distaaf(input) /t SITS fIIVIIG DISTAICI CO!!AIDS t/ char input11; { e1tern double ftarl; e1tern int count;

if (((strc1p(input,DISTAI):: 0)) ll (count < 1)) { printf("disttest\n"); distan(ftarl); count++; }

/ttttttttttttttttttt/

114

projctf(input) char input1 o;

I* SITS PROJICTIOR AHGLI CO!!AMDS •!

{ extern int iTarl; extern int count;

if {((strc1p(input,PROJCT):: 0)) l& (count< 1)) { printf("projtest\n"); projct( harl l; count++: l

1•t•••···············1 11indollf (input) char inputu; { extern double 11inxl, 11inx2, 11in1l, 11in12; extern int count;

I* SITS WINDOW SIZI CO!!AKDS *I

if (((strc1p(input, WIMDOW):: 0)) ll (count < 1)) { printf("11indotest\n"); 11indo11(11in1l, 11in12, 11inyl, 11in12); count++; }

} /~******************!

nportf(input) char inputu; { extern int 1do1,T11l, Tvx2, TtJl, YIJ2; extern int TvxlY, Tvx2T, ''JlT, TIJ2T; extern int couat;

/t SITS YIIW PORT SIZI CO!!AKDS t/

if (((strc1p(input,VVPORT):: 0)) ll (count< 1)) {

if(vdov::l) { Tlport(TIXlT, TIX2T, flJlY, TIJ2T); }

if (vdov::O) { Tlport(Ylll, Yll2,Y1Jl,YIJ2); }

printf("Tportest\n"); count++;

} }

/tttttttitttttttttttt/

115

displaf (input) char inputu;

/t SITS GRAPIC DISPLAY COKKANDS •/

{ extern int iYarl; extern int count;

if (((strc1p(input,DISPLA):: 0)) ll (coant < 1)) { printf("testdisp\n"); displa(inrl); coant++; }

1••··················1 tnisf(inpat) !• SITS TIITMIIDOM VISIBLI COKKAIDS t/ char inpat11; { extern int iYar,iTarl; e1tern int coant;

if (((strc1p(inpat,TMVIS):: 0)) ll (count < 1)) { printf("tvTistest\n"); tnis(l); count++; }

} , .................... , tvposf (input) char input11; {

/t SITS TIITMIIDOW POSITIOK COKKAIDS •/

extern int iYar,iYarl,iTar2,iTar3,iTar4,iTar5,iTar6,count; if( ((strc1p(inpat,TMPOS):: 0)) ll (coant< 1))

{ printf( "tvpostest,Xd,Xd, Xd, Xd, %d,%d\n°,iYarl,iYar2,iTar3,itar4,iYar5,itar6); t1pos(iY1rl,iYar2,iYar3,i'ar4,iYar5,i'ar6); coant++; } , .................... ,

clearif(inpat) char inpa tu ; { e1tern int count;

!• CLIARS IKTllSITY BOrr11 COKKAIDS *I

if( ((strc1p(input,CLIARI):: 0)) ll (count< 1)) { printf("CLIARI~st\n"); cleari(O); couat++; }

116

!********************! clearsf (input) /1 CLK&BS SCBKKI COKK&IDS 1/ char inputu; { extern int count;

if (((strcap(input,CLK&iS):: 0)) && (count< 1)) { printf("clertest\n"); clears(O); count++; }

/111111111111l1111111/ caf(input) /1 ASCII COKK&KDS 1/ char inputu; { extern int count; if (((strcap(input,C&):: 0)) ll (count::O))

{ printf("catest\n"); ca(); count++; }

/11111111111111111111/ pginitf(input) /1 IIITI&TIS GRAPHICS COKKAIDS •/ char inputu; { extern int couat;

if (((strcap(input,PGIKIT) :: 0)) ll (count::O)) { printf("pgtest\n"); pgini t( 0, 1); count++; }

/11111111111111111111/ clipJf (input) char inputu; { extern int count;

extern int itar,itarl;

/1 SKTS TOI CLIPPIIG PL&IK */

if (((strcap(input,CLIPY) :: 0)) ll (count::Q)) {

}

printf("CLIPYtest\n"); clipJ(inrl); couat++;

, ...........•........ , clipbf( input) char input11; { extern int count;

extern int iYar,ivarl; if (((strc1p(input,CLIPB) :: 0)) ll (count::Q))

{ printf("CLIPBtest\n"); cliph(inrl); counttt; }

} /********************! ' distbf(inpat)

char inpat1t; { extern doable fyar,fYarl; extern int count;

if (((strc1p(inpat,DISTB) :: 0)) ll (coant::O))

}

{ printf("DISTBtest\n"); disth(harl); count++;

}

t/********************I

117

I* SITS BITBIB CLIPPING PLAMI *I

I* SiTS BITBli CLIPPIIG PLAIK DISTAIClt/

distyf(inpat) /* SITS YOI CLIPPIIG PLAll DISTAICI•/ char iDpatu; { extern double fyar,fYarl; extern int count;

if (((strc1p(inpat,DISTY) :: 0)) ll (coant::O)) { printf("DISTYtest\n"); distJ( furl); count++; }

'****************/ clbegf(input) char input11; { extern int ifar,i,arl; extern int count;

if (((strc1p(input,CLBIG) :: 0)) ll (coant::O)) { printf("CLISTBIGtest\n"); clbeg(inrl); clcount++; count++; }

} ''****************! ~/****************!

clendf(input) char inputu; {

extern int count; if (((strc1p(inpat,CLllD) :: 0)) ll (coant::O))

{

}

printf("CLIST in llDtest\n"); clend(); count++; }

'****************/ clrunf( input) char inputu; { extern int count; extern int ifar,i,arl;

if (((strc1p(inpat,CLiOI) :: 0)) ll (count::O)) { printf("CLiOltest Sd\a·,1,arl); clrua(harl); count++; }

118

I* BIGIKS COKKAKD LIST *I

I* llDS CO!!AKD LIST */

I* ROIS CO!!AID LIST */

119

''****************! • scalf(input) I* ACTIVATES SCALE COBBAMD *I

char inputu; { e1tern int count;

e1tern double ffar,f,arl,f,ar2,f,ar3; if {({strc1p(input,BDSCAL) :: 0)) ll (count::O))

{ printf("BDSCALI test%.2f,1.2f,1.2f,\n",f,arl, ffar2, ffar3); lldscal{ffarl, ffar2, ffarl}; count++;

} } ., ................ ,

' rot1f(input) char inputu; { e1tern int cont,ifar,ifarl;

I* ACTIVATES ROTATION I COBBBAKD *I

if (((strc1p(input,BDROTI) :: 0)} ll (count::O)) {

}

printf("rot z test\n"}; 1drotl( i nrl); count++; } , ................ ,

· rotyf(input) char inputu; { e1tern int couat,ifar,ifarl;

/t ACTIVATES ROTATION Y COBBBAMD t/

if (((strc1p(input,BDROTT) :: 0}) ll (count::O)) { printf(" ROT Y test\n"); ldrot1(inrl); count++; }

}

'·············••! rot&f( input} char inputu; { e1tern int count,ifar,ifarl;

/t ACTIVATES ROTATIOI % COBBBAMD •/

if (((strc1p(input,BDROTZ) :: 0)) ll (count::O)) { printf{"ROT Ztest\n"); ldrot&( inrl); count++; }

120

!••***************! t orgf(input) I* ACTIVATES !ODILIKG ORIGII CO!!!AND */

char input11; { extern int count;

extern double fTar,fvarl,fTar2,fvar3; if (((strc1p(input,!DORG) :: 0)) ll (count::O))

{ printf("!DORG testl.2f,l.2f,l.2f,\n" ,fTarl, fTar2, fTar3); ldorg(fTarl, fTar2, fvar3); count++; }

} Is*******************!

ssolidf(input) char input11; { extern int count;

extern double fTar2,fTar3,rotnu1; extern int iTar,iTarl; extern double •xlist; extern double *'list;

/I &CTIVATIS SVIPT SOLID CO!!!AND */

if (((strc1p(input,SSOLID) :: 0)) ll (count::O)) { printf("ssolid test\n");

ssolid (iTarl, iTar2,xlist,,list,rotnu1); count++; }

121

r THIS SIT Of fILIS RIADS IM TBI COMBAHD LIST JOB VIIMING, PLAN AND ILIYATION•/ linclude <fcntl.b> linclude <s1s\t1pes.b> linclude <s1s\stat.b> linclude <io.b> linclude <stdio.b> linclude "std.b" linclude "co11ands.b"

I UtUUUUUUUU/ getfile() /l BICIYIS COBBAID LIST roe VIIMIMG t/ { e1tern int •a1lv, va12v, va1lv, va12v; e1tern int shade, planon, wdow; clears(O); cleari(O); vwport(0,639,0,479); 11zsend(); shade=l; planon=O; setupnrs(); if(wdoa::l) vaport(va1l• 1 va12v,va1lv,va12v); getfileO(); getfilel () ; }

./t•••••••••••••••/ (e1tf ileO ()

e1ter11 int raltdisk,wdoa; e1ter11 int count,planon; e1tern double 1, ,, z; e1tern int •ectotal,total;

/tSTORIS I T Z COBSOB LOCATION LOCATION t/ I* SITS SHADING OK •/ !• SITS YIIMIIG 01 t/

!• SITS OP YIINIIG YARIABLIS t/ /t If MIIDONS ARI 01 t/ !• SIT SKALL PIRSPICTIYI YIIN •/

/t RIADS II COKBAID LIST FILI t/ I* RISITS SCBlll WITH COBSOB t/

extern int sscouat,ssau1,total,ssct,ttot; e1tern double 1listzzs; e1tern double 1listzzs; e1tera double •1ptr; e1tern double •1ptr; static char inpottt; static char strltt; FILI tfl; char stringu;

if(raadisk::O) /t SITS rILI TO RIAD RAKDISI OB DISI•/ fl : fopen("co11and.d", "r");

if(raadisk==l) fl: fopen("d:coaaand.d","r");

yptr:ylist; xptr=xlist; .ectotal:O; Ytot:O; ssct:O; total:O; sscount:O; while (fgets(input,LIK,fl)!:NOLL)

{ strcpy(strl,input); fit(input,6); ssolidr(input,strl); if(sscount::O)

}

{ strcpy(string,lstrlc); toi(string); cou1t:O; func2(input); }

} /* HD */ '''**********************!

ssolidr(input,strl)

char inputu; char strlu;

122

I* DlrIMIS POIITIR FOR VICTOR LIST II SWIPT SOLIDS •/

I* RISITS YICTOR TOTAL */

I* SIT COKKAID TOTAL *I

I* RIADS FILI TO IND •/

I* COPYS STRIIG TO STRl */ I* TAllS rIBST 6 CHARACTIRS */ I* Ir SWIPT SOLID SKIDS TO SS FOICTIOI •/ I* If SS rIIISHID TBll BIGII *I

I* COPYS STRIIG DILITIIG FIRST SII CBARACTIRS */ I* SIPARATIS IOKBIR CBARACTIRS */

I* STRIIG COKKAID KATCBIBG roBCTIOI •/

I* RIADS SSOLID COKKAID AKD IIICUTIS */

extern int sscount,ssnu1 1 tot1l,ssct,Ytot; e1tern int vdov; e1tern int count,planou; e1tern double 11 y, 1; extern double deptbl,depth2,deptb3,rotnu1,ftar, ftarl,ftar2,ftar3; e1tern int itar, itarl, itar2; e1tern int teetotal, total; int ct : O; e1tern double 1list11s; e1tern double ylistzzs; e1tern double •1ptr; e1tern double ayptr; static char string4t;

123

if (((strc1p(input,SSOLID) :: OJJ::(,tot!:OJ::tsscount::-1)) {

I* TIST roe SSOLID COKKAND •/

strcpy(string,lstrls); toi( string);

if (,ectotal::O) { ssnu1:harl; nctotal:inr2; ftot:inr2; }

if((sscount::-l)ll(ssnu1::l)) {

/I TAllS STRIKG rROK 6 CBARACTIBS BACI•/ I* DIYIDIS STRIKG INTO GROUPS t/

I* ASSIGIS VICTOR TOTAL NOKBIB •/

!• TISTS roR SSOLID ROTATI •/

rotnu1:f,arl; /a ASSIGKS ROTATIOK AKGLI t/ ssolid(ssnu1,•ectotal,1list,1list,rotnu1); /t IIIOTIS SSOLID COKKAID a/ fectotal:O; /t RISITS ALL YALOIS ASSOCIATID NITB SSOLID a/ rotnUl=O.O; ftot:O; ssct:O; total:O; sscount:-1; }

if((sscount::-l)ll(ssnu1::Q)) { depthl :furl; depth2 =har2; depth3 :fnr3;

I* ASSIGIS DIPTR YALUI */

ssolid(ssnu1,,ectotal,1list,1list,depthl,depth2,depth3);

nctotal:O; rotnU1=0.0; ftot:O; ssct:O; total:O; SSCOQD t: -1 ; }

/t IIICUTIS IITRUDID SSOLID COKKAND •/ /a llSITS YALOIS a/

if((total<ftot)ll(sscount>O))/tlllCOTIS OITIL YICTOR TOTAL lllCOTID IS GRIATIR THAI TOTAL */ { distuet=harl; ylist11ct=f•ar2; total:ssct; ssct++ ; if(total==•tot-1)

{ sscount=-2; 1ptr:1lis t; yptr=1list; •tot:O; }

I* ASSIGIS TO I VICTOR LIST */ /t ASSIGIS YALUI TO Y VICTOR LIST t/

/•COOITS IOKBIR or TIKIS VICTORS RAYi BllN IIICOTID •/

I• TISTS rot rIIAL VICTOR •/

I* ASSIGIS LIST TO POllTll YALDI t/

124

sscounttt; I* COOMTS MO!BIR or PASSIS *I

} ·/*****************!

getfilel() { extern double orgx,orgy,orgz, vinxl, vinx2, vinyl, viny2; extern int planon, vdov; extern int Yvx , YiJ, 'vz; extern double Yvptx,,vpty,,vptz, x, J, z,sx,sy,sz; extern int Yvxl, Yvx2, fiJl, YVJ2; extern int vv1lv, Yvxz,, Yvylv, fVJ2'; extern double disy, dist,dish; x:O.O; /t SIT ITZ TO ZIRO *I y:O.O; z:O.O; 1diden(); I* BISITS KODILIIG !ATRII */ 11zretarn(); I* RITURIS PBIYIOOS I T Z VALUI */

I* TRAISLATIS CURSOR LOCATIOI •/ 1dtran(1, y, z); virefr(2, 0); /t SITS TO MIRIFAKI t/ vindov(vinxl, vinx2, vinyl, vin12); if(vdov::l)

/t SITS NIIDON SIZI t/ /t TIST fOR KULTIPLI MIIDOMS */

{ dispi(O); /t DISPAYS SHADID l!AGI */ cplao(); /t DRAMS PLAI */ celeYat(); /t DRAMS ILIYATIOl */ fvrotx(fv1); /* IOTATIS YllM I AIIS */ Yvroty(Yvy); /* ROTATIS YllM T AIIS */ fvrotz(,vz); /S ROTATIS YIIM Y AIIS *I fiport(fVIlf, fVI2f, fVJlY, fVJ2f); /t SITS PIRSPICTIYI YIIM */ projct(50J; /* SITS PROJICTIOI AIGLI •/ disth(dish); /*SITS BITBIR CLIPPIIG l/ disty(disy); /*SITS TOI CLIPPING *I distao(dist); /*SITS YIINIIG DISTAICI */ flrpt(,vptx,,vpty,,vptz); /t SITS YIIMIIG RIFIRllCI POIIT */ plaooo:O; /* YALOI TO PIRSPICTIYI YIIM t/ vindovs(); /t DRAMS CURSOR TO MIIDOMS *I virefr(2, 0); I* SITS TO NIRI FRA!I */ linfun(O); I* SITS RIPLACI LIMI TTPI */ color(250); /*SITS COLOR *I IOfe(vioxl,vinyl); /t DRAMS BORDIRS t/ rect(vin12, vioy2); }

if (11do11::0) { Yiport(Yllll, Yil2,YllJ1,YVJ2); projct(50); Yarpt(,apt1,,11pty,,aptz); planon:O; 1dorg(org1,org1,org1); rcntxa(); rcntya(); rcntza(); 1dscal(s1,s1,s1); dispi(O); cursor(); color(2SO); 10'e(11inxl,1in1l); rect(ainx2, viny2); }

clrun(251); } , .................. , rcntxa() { extern int rcntx,rcnty,rcntz; extern int rx,r1,rx,10rc; extern double x,1,1,1f 11f,1f; if (rcntx::l)

{ if((rcnt1==0)ll(rcnt1::0)) ldrotl(n); if((rc1t1::2)ll(rcnt1::Q))

{ ldrotx(rx); ldrot1( rr); }

if((rcnt1==2lll(rcnt1::3)) { ldrotl(n); ldrot1(r1); ldrotz(n); }

if((rcnti::2)ll(rcnty::0)) { ldrotJ(n); ldrotl(n); }

125

I* TIST FOR SIMGLI SCRllM *I

I* SITS FULL VIIVIIG VIIDOV */ I* SIT PROJICTIOI AMGLI •/ I* SITS RIFIRllCI POIIT */ I* SIT TO PIRSPICTIVK *I I* SITS !ODILIIG ORIGIN *I I* TIST ROTATIOI ORDKR */

I• SCALIS *I I* DISPAYS SCRlll *I I* DRAMS CURSOR *I I* DRAWS BORDIR */

I* !All !110 LIST *I

I* TRI fOLLONIIG f OICTIOIS CBICI ROTATIOI ORDKR */ !• AID lllCOTI ROT&TIOI fOICTIOMS */

)

if((rcntz::2)ll(rcnty::3)) {

)

1drot1(n); 1drotz ( rz) ; 1droty(ry); )

''**************••••! rcntya() { extern int rcntx,rcnty,rcntz; extern int rz,ry,rx,1org; extern doable x,y,z,xf,yf,zf; if ( rcn ty:: 1 )

} )

{ if((rcntx::O)ll(rcntz::O))

1droty( ry); if((rcntx::2)ll(rcntz::O))

{ ldroty(rJ); ldrotx(n); }

if((rcntx::2)ll(rcntz::3)) { ldroty( ry); lldrotx( n); lldrotl(n); }

if((rcntz::2)ll(rcatx::O)) { lldroty( ry); ldroh(n); }

if((rcntz::2)ll(rcntx::3)) {

}

lldroty( ry); lldrotz( u); ldrotx(u);

126

!• roe y ROTATIOI VALOIS */

''*******************/ rcntza() { extern int rcntx,rcnt1,rcntz; extern int rz,r1,rx,1org; extern double 1,1,z,xf,Jf,zf; if {rcntz::l)

}

{ if((rcntx::O)ll(rcnt1::0} )

ldrotz{n); if{(rcntx::2)11(rcnt1::0) )

{ ldrotz{n); adrotx(n); }

if((rcntx::2)11(rcnt1::3) ) { ldrotz(u); ldrotx(n); 1drot1{ r1); }

if((rcnt1::2)11(rcntx::O) ) { ldrotz(rz); ldrot1(r1); }

if((rcnt1::2)11(rcntx::3) ) { ldrotz{n); ldrot1( rJ); ldrotx(n); }

'···············••/

127

I* roR y ROT!TIOI Y!LOIS •/

cplan() /t SAii AS GITfILI llCIPT A PLAI flll IS SIT t/ { extern int 1do1; extern int count,planon; extern double orgx,org1,org1,s1,s1,s1,x, 1, z; extern double deptbl,deptb2,deptb3,rotnu1,fYar, fyarl,fYar2,fYar3; extern int iYar, iYarl, iYar2; extern int Yectotal; extern int sscount,ssnu1,total,ssct,Ytot; static char inputte;

static char strlce; intct:O; extern int Y1xlp, Y1x2p, Yu1lp, Yu12p; extern int ralldisi,,11; extern double vinxl, vinx2, vinyl, vin12;

char string co; extern double xlistzzs; extern double ylistzzs; extern double Sxptr; extern double •1ptr; rILI *fl; int ret; 1ptr=1 list; xptr:xlist; Yectotal:O; Ytot:O; ssct:O; total:O; sscount:O;

if (ra1disi::O) fl: fopen("co11and.d 0

,0 r0

);

if(ralldisi==ll fl: fopen("d:co11and.d 0

,0 r");

ret : O; x1zsend(); setupnrs(); planon:l; dispat(2,0); if(vdo1::l)

{ Yuport(Yuxlp, Yux2p, Yuylp, Yu12p);

liDfun(O); 10Ye(uinxl,uin1l); rect(uinx2, uin12J; }

if(11do11::0) clears( 0);

LIHUI (0); vindo1(1inxl, 1in12, 1in1l 1 1in12); niden(); projct(O); nroty ( "'); nroti(270);

128

}

dispat(2,l); while (fgets(input,Ll!,fl)!=NOLL)

{ strcpr(strl,input); fit(input,6); ssolidr(input,strl); if(sscount::O)

}

{ strcp1(string,lstrlc); tok( string); count=O; funcp(input); ct++; }

fclose( fl); 1:0.0; 1:0.0; z:O.O; adiden(); 1yzretarn(); ldtran( 1,1 ,z l; planon:l; 1dorg(org1,ore1,orgz); rcntn(); rcntra(); rcntza(); 1dscal(s1,s1,s1); dispat(2,0); if (11do11::0)

{

clran(251); setscrn(); }

fttllllltlttltllllt/ fancp(inpat) char input11; { nrptf ( inpat); lutintf( input); colorf( inpat); ldidenf( inpat); ldtranf( input); solidf( input); rotlf (input); scalf(input);

129

/t fOCTIOIS OSID BY PLll fOICTIOI !lY Bl ILI!lllTID t/

rotyf( input); rotzf (input); orgf(input); solbegf( input); solendf( input); solbopf( input); solrunf( input); clbegf (input); clendf (input); clrunf (input);

} /uuuuuuuu/

130

cele•at() I* SAKI AS PLAI ARD GITfILI IICIPT AM ILIYATIOI YIIW IS SIT*/ { extern int 11do11; extern int count,planon; extern double sx,sy,sz,x, y, i,org1,orgy,orgz ; extern double depthl,depth2,depth3,rotnu1,ffar, f•arl,f•ar2,fYar3; extern int itar, i•arl, i•ar2; extern int •ectotal; extern int sscount,ssnu1,total,ssct,•tot; static char input••; static char strl••; int ct : O; extern int •axle, •11x2e, •arle, •1112e; extern int ra1disi,•111; extern double 11inxl, 11in12, vinyl, 11in12;

char stringu; extern double xlistzzs; extern double ylistzzs; extern double •1ptr; extern double •yptr; rILI •fl; int ret; yptr:y list; 1ptr=1list; •ectotal:O; •tot:O; ssct:O; total:O; sscount:O;

if(radisi==OJ fl : fopen("co11and.d","r");

if( radisi::l) fl : fopen("d:co11and.d", "r");

11zsend(); setuptars(); plaaoa:2; if(wdo11==l)

{ t11port(t111le, tv12e, tvyle, Y1112e); }

if(11do11::0) clears(O);

11indov(vin1l, vin12, vinyl, 11in12); linfun( 0); color(250); aove(vin1l,11in1lJ; rect(vin12, viny2); dispat(2,0); niden(); pro jct( 0); nrotx(O); nro tr ( ny) ; start:

11hile (fgets(input,LIB,fl)!:IULL) { strcpy(strl,input); fit(input,6); ssolidr(input,strl); if(sscount::O)

}

{ strcpy(string,lstrlcl; tok( string); couat:O; fuacp ( iapu t) ; ct++; }

fclose( fl); if(ratdisk::O)

fl: fopea("co11and.d","r"); if(ratdisk==ll

fl : fopea("d:co11aad.d", "r"); 1:0.0; y:0.0; z:O.O; ldidea(); 11uetura( J; ldtraa(1,y,z); planoa:2;

131

1dorg(org1,orgy,orgz ); rcnt1a(); rcntya(); rcntza(); 1dscal(s1,s1,s1); dispat(2,0); if(wdov::O)

{

)

cl run( 251); setscrn(); }

·Atttttttaaaaaaaaaaa/ ·faaaattttttaaaaaaaaa/

132

funcellinoutl I* COR8AMDS OSID BY ILIYATIOK FOICTIOM s/ char inout11: f nrotf( inout l: lutintf{inoutl: colorf( input); ltdidenf(input); ldtranf (input); solidf(input); rotlf( input); scalf (in out l; rotyf( input); rotd(input); orgf( input); solbegf (input); solendf(input); solbopf(input); solrunf (input); clbegf (input); clendf( input); clrunf(input);

133

* TBISK FOHCTIOKS IHCLODI THI KAIH KIKO AND SUB MINUS COLOR; SHADING; FACITIHG; *I * KODILIKG; TRAHSLOCIKCT */

linclude •teys.h" linclude "std.h" linclude <fcntl.h> linclude <sys\types.h> linclude <sys\stat.h> linclude <io.h> linclude <stdio.h>

J••·················••! 1ain1enu() { extern int 11do11; int key; int cnt; if(11do11::0)

cursor(); if(11do11::l)

llindo11s(); cnt:O; Hindisp(); IOYe(75.0, 465.0); color(32); rectr(75.0, 15.0); ke1=1etche(); 11hile(keJ ! : QS)

{ slli tch( key) f

case CS: cnt=t toto out: break:

case SS: cnt:l; goto oat; break;

case BS: cnt=2: a:oto oat: break:

case OS: cnt:O: roto out: hrP.ilk:

r.il~P. KS: rntn nut: hrP.;ik:

CUP. ,9 : cue LARI :

I* VARIBLI FOi NIIDON SILICT t/ I* RIADS II lit YALOI */ !• FLAG ro1 SOB FUICTIOIS ., I* IRASIS CURSOR */

I* DISPALTS KAii KIND */

I* DRAMS !KIO CURSOR */

I* SITS LOOP */

/t SITS COLOR S/

/t. SIT SOLIDS l/

/t. SITS BODILIIG t./

case FOOR : linfun(2); color( 32); rectr(75.0, 15.0); aoYer(75.0, 0.0); rectr(75.0, 15.0); cnt++; if(cnt> 5)

{ rectr(TS.O, 15.0); IOYe(75.0, 465.0); rectr(75.0, 15.0); cnt:O; }

break;

134

case KARR : /* KOVIS CURSOR TO THI RIGHT *I case no : case SII: linfun(2);

color( 32); rectr(75.0, 15.0); IOYer(-75.0, 0.0); rectr(75.0, 15.0); cnt--; if(cnt<O)

{ rectr(75.0, 15.0); IOYe(450.0, 465.0); rectr(75.0, 15.0); cnt:5; }

break; case SPACI : goto out; case ISC : cnt :99;

goto out; default: ;

} keJ=«etche(); } out: 1ain1en1121cntl: l

·/UUUUUUU/

1aindisp() { clbeg(251); linfun(2); YMPORT(0,639,0,479);

135

I* SIT BIRO DISPLAY AT THI TOP or SCRllM */

I* STARTS COBBAIDLIST *I !• SIT TO XOR •/

aindoa(O.O , 639.0, 0.0, 479.0); TSIZl(l0.0);

I* SITS YIIM PORT */ I* SITS WIIDOM *I I* SITS TIIT SIZI */

TJOST(l, 1); KOYl(5.0, 468.0); COLOR(32); tut( "BUI • ) ; KOVIR(75.0, 0.0); COLOR( 32); tut("D "); COLOR( 255); text(" IBI • ) ; COLOR( 32); BOVIR(50.0,0.0); text("S "); COLOR(255); text(" OLD"); BOYIR(50.0, 0.0); COLOR( 32); text("B "); COLOR( 255); text(" ODL • ) ; BOVIR(50.0,0.0); COLOR(32); teit("O "); COLOR(255); text(" RGI "); BOVIR(50.0, 0.0); COLOR(32); text("Y "); COLOR(255); text(. IIW • ) ; BOVIR(50.0,0.0); COLOR( 32); text("C "); COLOR(255); text(. OLR • ) ; BOVIR(50.0,0.0); COLOR( 32); text("R "); COLOR(255); tut(" BOY "); BOVIR(50.0,0.0); COLOR(32);

I* SITS JOSTifICATIOM *I I* BOVIS TO TOP LKfT CORMIR */ I* SIT COLOR RID */ !• PRIITS "BAii" */

text("N "); COLOR(255); text(. MON • ) ; KOYIR(50.0,0.0); COLOR(32J; text("r • l; COLOR(255); text(. ILi "); KOYIR(50.0,0.0); COLOR(32); text( "I "); COLOR( 255); text(" RAS "); KOYIR(50.0,0.0);

cl end(); clrun(251); }

·/uuuuuuui/ aain1enu2(cnt) int cnt; { extern int vdov;

136

I* KKDS COKKAND LIST i/ I* ROMS COKKAKD LIST it

extern double ainxl, vin12, vinyl, ainy2; extern int vv1l, vv12, vvyl, vay2: int key; rectr(75.0, 15.0); cl run( 251); if(cnt==O)

{ setscrn(); c1odel ();

setscrn( I; goto end;

} if(cnt::l)

{ pri1i the(); goto end; }

if(cnt::2) { 11odeling(); goto end; }

if(cnt::3) {

I* SIT BKIGHT,LKMGTH,NIDTH *I

I* PRIKITIVK roMCTIOIS */

I* KODKLIMG FOMCTIOMS t/

I* 1Yie1(); *I goto end; }

if(cnt::4) { ccolor(); goto end; }

end:; }

.Jnnnnnnn/ 11odeling() { e1tern int 1do1;

137

I* COLOR JOBCTIOIS *I

I* B&II KODiLIBG KIKO JOICTIOIS */

e1tern doable 1in1l, 1in12, 1inJl, 1in12; e1tern int f11l, f112, flJl, ,,,2; int iey; iDt cnt2; cnt2=0; aodeldisp(); IOfe(75.0,465.0); color(32); rectr(75.0, 15.0); ie1=getche(); 1hile(ie1 !: QO)

{ s1itch(keJ)

{ case CS : cnt2:6;

goto oat; breai;

case SS: cnt2:5; goto 011t; break;

case RS : cnt2:0; ioto 011t; breai;

case rs : cnt2:1; goto oat; breai;

case GS : cat2=2; goto out; breai;

case &S : cnt2:3; coto 011t; breai;

case TS : cnt2=4; coto oat; breai;

I* GOTO CilTiRIIG t/

I* GOTO SCALI */

I* GOTO iOT&Ti *I

I* GOTO UCiT *I

I* GOTO GOOR&OD SHADK *I

I* GO TO ABGOL&i SH&DK */

I* GO TO TRAISLOCKICY */

case '10 : case R&RR : case Sil : linfun(2);

color(32); rectr(75.0, 15.0); KOflR(75.0, 0.0); rectr(75.0, 15.0); CDt2++;

case '9

if ( cnt2>6) { rectr(75.0, 15.0); KOfl(75.0, 485.0); rectr(75.0, 15.0); cnt2:0; }

break;

138

I* KOVI CURSOR TO THI RIGHT •/

case L&RR : I* KOVI CURSOR TO THI LIFT s/ case JOOR: liafua(2);

color(32); rectr(75.0, 15.0); KOVIR(-75.0, 0.0); rectr(75.0, 15.0); cnt2--; if(cat2<0)

{ rectr(75.0, 15.0); IOte(525.0, 465.0); rectr(75.0, 15.0); cnt2:8; }

break; case SP&CI : coto out; /* SILICT t/ case ISC : cnt2:99; /* RITORI TO !Aii */

coto out;

default : ;

} ke1:getche(); }

out: 110deling2(cnt2); }

•/****************/ 1odeldisp() /* KODILIIG DISPLAY*/ ( clbeg(253); linfun(2); VWPORT(0,639,0,479); vindou(O.O , 639.0, 0.0, 479.0); TSIZl(l0.0); TJOST( l, 1); KOYl(5.0, 468.0); COLOR(32); text(" KODIL "); KOVIR(75.0, 0.0); COLOR(255); text(" ROTATE "); KOVIR(T5.0, 0.0); text(· rACIT ·); KOYIR(75.0, 0.0); text( "GSHADK "l; KOVKR(75.0, 0.0); text("&SHADK "); KOVIR(75.0, 0.0); text( "TRUSL "); KOYIR(75.0, 0.0); text(" SCALK "); KOVIR(75.0, 0.0); text( "CKITll • l; cl end(); cl run( 253); }

!•••••••••••••••/ 110deling2(cnt2) /* BRAICHIS TO fUICTIOIS */ int cnt2; { extern int rx,r1,rz,rcntx,rcnt1,rcnt1,udou; extern double uinxl, uinx2, 1in1l, vin12; extern int •vxl, •vx2, •111, •112;

rectr(75.0, 15.0); clrun(253); if(cnt2::0)

{ arotate(); }

if(cnt2::1) { 1tesal(); }

139

if(cnt2::2) { 1gouraud(); }

if(cnt2::3) { 1consbade();

} if(cnt2::4)

{ 1translu(); }

if(cnt2==5l { 1scale(); }

if(cnt2::6) { acenter(); }

wndovset(); }

/tt*************/ /UUUUUUt/

1tesal() { extern int tess,vdov; int ke1; int cnt3,fcnt; vadovset();

fcat:O; if(fcnt::O)

{ tessal(4,0); font++; }

if (vdov::O) cursor(); if(11do11::l) vindovs(); c1t3:0; tessaldisp(); IOYe(60.0, 463.0); color(32); rectr(30.0, 15.0); key:getcbe();

140

/t RISKT MIKDOM AKD VIIM WINDOW */

/t CATIVATK lACKTIMG roKCTIOKS t/

11hile(ke1 ! : QS) { slli tch ( ke1 l

{ case '10 case RA!li : case SII: linfun(2);

case f9

color( 32); rectr(30.0, 15.0); 10Yer(60.0, 0.0); rectr(30.0, 15.0); cnt3++; if(cnt3>8)

{ rectr(30.0, 15.0); IOfe(60.0, 463.0); rectr(30.0, 15.0); cnt3:0; }

break;

case LUR : case FOOR: linfun(2);

color( 32); rectr(30.0, 15.0); IOYer(-60.0, 0.0); rectr(30.0, 15.0); cntl--; if(cnt3<0)

{ rectr(30.0, 15.0); IOfe(540.0, 463.0); rectr(30.0, 15.0); cnt3:8; }

break; case · ·: color(32);

linfun(2); rectr(30.0, 15.0); goto out;

case KSC : color(32); linfun( 2); rectr(30.0, 15.0); cnt3:99;

default:; }

goto out;

141

11ndo11set(); setscrn(); tesscurs( cnt3); setscrn( l;

VMPORT(0,639,0,479); 11indo11(0.0 , 639.0, 0.0, 479.0); key:getche();

out: 1tesal2( cnt3); 11ndo11set(}; setscrn(); }

tessaldisp() { clbeg(253); linfun(2}; VNPORT(0,639,0,479); 11indo11(0.0 , 639.0, 0.0, 479.0}; TSIZl(lO.OJ; TJOST( 1. 1); !OVl(3.0, 465.0); COLOR(32); tut( "rACIT"}; !OVIR(60.0, 0.0); tut("90"); !0Vli(60.0, 0.0); tut("60"); !OVIR(60.0, 0.0); COLOR( 255); tut("45"); !OVIR(60.0, 0.0); tut( "30"); !0Yli(60.0, 0.0); teit("20"}; !0Vli(60.0, 0.0); text( "15 ·); !0Vli(60.0, 0.0); tut("lO"); !OVIR(60.0,0.0); text(T); !0Yli(60.0,0.0); text("IIT" l; clend(); clrun(253); }

142

·/••**************/ tesscurs(cnt3) int cat3; { e1tern int tess,vdov; e1tern double vin1l, vin12, 1in1l, vin12; e1tern int fill, vv12, vvyl, vv12; char cb3; if(cnt3::0)

{ tessal( 4, 0); }

if(cntl::l) { tessa l( 4, 1 ) ; }

if ( cnt3::2) { tessal ( 4, 2); }

if ( cnt3::3) { tessal( 4, 3); }

if(cnt3::4) { tessal(4,4); }

U(cnt3::5) { tessa 1( 4 , 5 ) ; }

if(cnt3::6) { tessal( 4,6); }

if(cat3::7) { tessal ( 4, T) ; }

143

'*****************/ 1tesal2(cnt3)

144

int. cnt3; I• SKID TO rILI BR!KCH rOICTIOKS ., { e1tern int tess,vdov; e1tern double vin1l, vin12, vin1l, vin12; e1tern int •v1l, •v12, ,,,1, ,,,2; char ch3; clrun(253); if(cnt3::0)

{ 14(); }

if{cnt3::1) { 16(); }

if(cnt3::2) { 18(); }

if(cnt3::3) { 112(); }

if(cnt3==4) { 118(); }

if(cnt3::5) { 124(); }

if(cnt.3::6) { 138();

} if ( cnt3::7)

{ 160(); }

if(idov::O) {

}

1indo1(1in1l, 1in12, 1in1l, 1ia12); VMPORT(•11l, •112, ,,,1, •112);

if(wdow::l) {

}

window(-640.0, 640.0, -479.0, 479.0); fvport(O, 319, 0, 239); } printf("\ncount => Xd",cnt3); , ................... ,

!4() { extern int shad,tess,ra1disk; nu •cl; if(raadisk::O)

cl: fopen( 0 co11and.d 0, "a");

if(raadisk::l) cl: fopen("d:co11and.d 0

, "a"); fprintf(cl, "dispat 0, 0\n"); fprintf(cl, "dispat 4, 0\n"); fclose(cl); shad:O; tess:O; dispat(O, 0); tessal( 4, 0); }

/:tUUUUUUUlU/ !6() { extern int tess,ra1disk,sbad; FILI •cl; if(raadisk==O)

cl: fopen( 0 co11and.d 0, "a");

if(raadisk::l) cl : fopen("d:co11and.d 0

, "a"); fprintf(cl, "dispat 0, 0\n"); fprintf(cl, "dispat 4, l\n"); fclose( cl); dispat(O, 0); shad:O; tess=l; tessal( 4, 1); }

145

/l JILi AID SIT 0 IACIT LIVIL s/

I* JILi AID SIT l JACIT LIYIL •/

f S*****************f !8() { e1tern int sbad,tess,ra1disi; rILI •cl; if(r11disi::O)

cl: fopen("co11and.d", "a"); if(raldisi==ll

cl : fopen("d:co11and.d", "a"); fprintf(cl,"dispat 4, 2\n"}; fprintf(cl,"dispat 0, 0\n"}; fclose( cl); tess=2;

}

shad:O; dispat(O, 0); tessal( 4, 2};

'******************! !12() { e1tern int tess; nu •ct; e1tern int ra1disi; if(r11disi::O)

cl : fopen("co11and.d", "a"); if(r11disi::l)

cl : fopen("d:co11and.d", "a"); fprintf(cl,"dispat 4, 3\n"); fclose( cl); tess:3; tessal( 4, 3}; }

'******************/ !18() { extern int tess; JILi •cl; e1tern int ra1disi; if(r11disi::O)

cl : fopen("co11and.d", "a"); if(raldisi==ll

cl: fopen("d:co11and.d", "a"); fprintf(cl,"dispat 4, 4\n"}; fclose(cl); tess:4; tessal( 4, 4}; }

146

!• rILI !HD SIT 2 rACIT LIYIL */

I* rILI AID SIT 3 FACIT LIYIL l/

I* FILI AID SIT 4 F!CIT LIYIL */

/ttttttttttttttt•••/ M24() { extern int tess; FILI tcl; extern int ra1disi; if(radisi::O)

cl : fopen("co11and.d", "a'); if(raldisi==l)

cl : fopen("d:co11and.d", 'a"); fprintf(cl, "dispat 4, 5\n"); f close( cl); tess=5; tessal( 4, 5) ; }

; .................. ; ft36() { extern int tess; FILI •cl; extern int raldisi; if ( raldisi::O)

cl : fopen("co11and.d", 'a"); if{radisi::l)

cl : fopen('d:co11and.d", 'a'); tessal(4, 6); fprintf(cl, "dispat 4, 6\n"); !close( cl); tess:6; }

;, ................. ; 860() { extern int tess; rIU tcl; extern int raldisi; if(radisi::O)

cl : fopen("co11and.d", 'a"); if(raldisi::l)

cl : fopen("d:co11and.d", 'a'); tessal(4, 7); fprintf(cl, "dispat 4, 7\n"); fclose(cl); tess:7; }

147

I* FILI AND SIT 5 f ACIT LIVIL t/

/t FILI AMD SIT 6 FACIT LIVIL t/

I• rILI AID SIT 7 r&CIT LIYIL •/

!••*************/ 1gouraud() { extern int shad; extern int ra1disk; rILI •cl; shad:l; dispat( 0, 1); if(raadisk::O)

cl : fopen("co11and.d", "a"); if(raadisk==ll

cl : fopen("d:co11and.d", "a"); fprintf(cl, "dispat 0, 1\n"); fclose( cl); }

/UOUUUUU/ 1conshade() {

148

I* f ILK AID SIT GOUBAUD SHADING *I

extern int shad; /* FILK AID SKT CONSTANT SHADING *I extern int raadisk; FILI *cl; shad:O; dispat(O, 0); if(raadisk::O)

cl : fopen("co11and.d", "a"); if(raadisk==ll

cl : fopea("d:co11and.d", "a"); fprintf(cl, "dispat 0, 0\n"); fclose( cl); }

/uuuuiu/ 1transla() /*SIT TRAISLUCKICT LlfKL */ { extern int tess,1do1; extern doable 1inxl, vinx2, 1inJl, 1in12; extern int Yvxl, YIX2, YVJl, YIJ2; ht keJ; int cnt3; cnt3=0; transldisp() ; IOYe(60.0, 463.0); color(32); rectr(20.0, 15.0); key:getche(); 1~ile(ke1 !: QS)

{

slfitch(tey) { case RARR case 110 : case Sii : linfu1(2);

color(32); rectr(20.0, 15.0); 1oter(30.0, 0.0); rectr(20.0, 15.0); cnt3++; if(cnt3>16)

case LAH case 19 :

{ rectr(20.0, 15.0); IOJe(30.0, 463.0); rectr(20.0, 15.0); cntl:O; }

break;

case JOOR : linfun(2); color(32); rectr(20.0, 15.0); aoter(-30.0, 0.0); rectr(20.0, 15.0); cntl--; if(cnt3<0)

{ rectr(20.0, 15.0); IOY8(540.0, 463.0); rectr(20.0, 15.0); cntl:8; }

break; case SPACI: color(32);

linfaa(2); rectr(20.0, 15.0); goto oat;

case KSC: linfun(2); cnt3:99; goto oat;

defaalt:; }

tey:getche(); } oat: 1transl ( cnt3); }

149

rectr(20.0, 15.0);

150

transldisp() /'TRANSLUCENCY KIND DISPLAY t/ { clbeg(253); linfun( 2); 9WPORT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); TSIZl(lO. 0); TJUST(l,1); K091(3.0, 465.0J; COLOR(32); text( "TRUSL.); K091R(60.0, 0.0); text(" 0 "); KOVIR(30.0, O.OJ; tut("l"); KOVIR(30.0, 0.0); COLOR( 255); teit("2"); KOVIR(30.0, 0.0); text( "3"); KOVIR(JO.O, 0.0); teit("4"); KOVIR(30.0, 0.0); teit(T); KOVIR(30.0, 0.0); text("6"); KOVIR(30.0,0.0); text( •7•); KOVIR(30.0,0.0); text("8"); KOVIR(30.0, 0.0); COLOR(255); text("9 ·); KOVIR(JO.O, 0.0); tut( "10"); KOVIR(30.0, 0.0); text("ll"); KOVIR(30.0, 0.0); text("12"); KOVIR(30.0, 0.0); text( ·13·); KOVIR(30.0,0.0); text("14"); KOYIR(J0.0,0.0); text("15"); KOVIR(30.0,0.0); text("llT"); clend(); clrun(253); }

151

/****************! 1transl(cntll I* TRANSLDCIMCY BRANCH FDMCTIOMS *I int cnt3; { extern int tess,vdov; extern double vin1l, vi1112, 1i111l, vi1112; extern int •v1l, •v12, YVJl, •v12; char ch3; clrun(253); if(cnt3::0)

{ trlO(); }

if(cnt3::1) { trll (); }

if(cnt3::2) { tr 12(); }

if(cnt3::3) { trl3(); }

if(cnt3::4) { trl4(); }

if(cnt3::5) { trl5(); }

if(cnt3::6) { trl6(); }

if(cnt3::7) { tr 17 (); }

if(cnt3::8) { trl8(); }

if(cnt3::9) { tr 19(); }

if ( cnt3==10) { trllO(); )

if ( cnt3::11) { trl 11 (); }

if(cnt3==12l { trl12(); }

if(cnt3==13) { trl13(); }

if ( cnt3::14) { trl14(); }

if(cnt3==15) { trl15(); }

11ndo11set(); }

It••••*************/ tr 10() {

152

e1tern int tess,raadisi; /•TRAISLOCllCY LIVIL 0 SIT */ FILI •cl; if(ratdisi::O)

cl: fopen("co11and.d·, ·a·); if ( ra1disi==l)

cl : fopen(·d:co11and.d., ·a·); fprintf(cl,.dispat 1, 0\n·); fclose(cl); dispat{l, 0); }

!••***************!

153

trll() /tTRAKSLOCIHCY LIY!L 1 SIT•/ { eitern int tess,ra1disk; FILI •cl; if(rudisk==O)

cl : fopen("co11and.d", "a"); if(rudisk==ll

cl : fopen("d:co11and.d", "a"); fprintf(cl, "dispat l, 1\n"); fclose( ell; dispat(l, l); }

'******************/ tr 12() { /*TRAISLOCllCY LIVIL 2 SIT */ eitern int tess,raldisk; rILI •cl; if(rudisk::O)

cl : fopen("co11and.d", "a"); if ( rudisk::l)

cl: fopen("d:co11and.d", "a"); fprintf(cl, "dispat 1, 2\n"); fclose(cl); dispat(l, 2); }

'*****************/ trl3() { eitern int tess; rILI •cl; eitern int ra1disk; if(raldisk::O)

cl : fopen("co11and.d", "a"); if(nldisk==l)

cl : fopen("d:co11and.d", "a"); fprintf(cl,"dispat 1, 3\n"); fclose( cl); dispat(l, 3); } , ................. ,

/tTRAISLOCIKCY LIVIL 3 SIT t/

tr14{) { extern int tess; ¥ILK *cl; extern int ra1disi; if(ra1disi::O)

cl: fopen{·co11and.d·, ·a·); if(ra1disi::l)

cl: fopen(·d:co11and.d·, ·a·); fprintf(cl, ·dispat l, 4\n·); fclose{ cl); tess:4; dispat(l, 4); }

'················••! trl5() { extern int tess; nu •cl; extern int ra1disi; if(ra1disi::O)

cl : fopen(·co11and.d., ·a·); if(ra1disi::l)

cl : fopen(·d:co11and.d., ·a·); fprintf(cl, ·dispat 1, 5\n·); !close( cl); dispat(l, 5); }

'················••!

154

/*TR!KSLUCXKCY LKVKL 4 SKT */

/•TRAISLUCKICY LKVIL 5 SKT */

trl6() !•TRAISLOCllCT LIYIL 6 SKT */ { extern int tess; nu •cl; extern int raldisi; if( ra1disi::O)

cl: fopen{·co11and.d·, ·a·); if { raldisi==l)

cl : fopen("d:co11and.d·, ·a"); dispat{l, 6); fprintf(cl, "dispat l, 6\n"); fclose( cl); }

155

'******************/ tr 17 () /tTBANSLDCIMCY LIYIL 7 SIT */ { extern int tess; fILI •cl; extern int ra1disk; if(ra1disk==O)

cl : fopen("co11and.d", "a"); if ( raadisk==l)

cl: fopen("d:co11and.d", "a"); dispat(l, 7); fprintf(cl, "dispat 1, 7\n"); fclose( cl); }

'l•••••••••••••••••/ trl8() { /•TB&NSLDCllCY LIYIL 8 SIT */ extern int tess; FILI tel; extern int ra1disk; if(raadisk::O)

cl : fopen("co1aand.d", "a"); if(raadisk::l)

cl : fopen("d:co11and.d", "a"); dispat(l, 8); fprintf(cl,"dispat 1, 8\n"); fclose( cl); }

•t••••••t••••••••••/ tr 19 () { extern int tess; FILI •cl; extern int raltdist; if(raadisk==O)

cl : fopea("co11and.d", "a"); if( raadisk::l)

cl: fopen("d:co11and.d", "a"); dispat(l, 9); fprintf(cl,"dispat 1, 9\n"); fclose(cl); }

/tTBAMSLDCllCY LIYIL 9 SIT t/

''******************/ trll 0()

156

{ /•TRAISLUCIKCY LIVIL 10 SIT */ extern int tess; rILK •cl; extern int raadisi; if(raadisi::O)

cl : fopen("co11and.d", "a"); if(raadisi::l)

cl: fopen("d:co11and.d", "a"); dispat(l, 10); fprintf(cl,"dispat 1,10\n"); fclose(cl); }

'**••••••••••••••••! trlll() { /•TRAKSLUCllCY LKVKL 11 SIT */ extern int tess; FILI •cl; extern int raadisi; if(raadisi::O)

cl : fopen("co11and.d", "a"); if(raadisi==ll

cl : fopen("d:co11and.d", ·a·); dispat(l, 11); fprintf(cl, "dispat 1,11\n"); fclose(cl); }

'················••! trl12() /tTRAISLUCKKCY LIVIL 12 SIT•/ { extern int tess; FILI *cl; e1tern int ra1disi; if(raadisi::O)

cl : fopen("co11and.d", "a"); if ( raadisi:: 1)

cl : fopen("d:coaaand.d", "a"); dispat(l, 12); fprintf(cl,"dispat 1,12\n"); fclose(cl); }

'*****************! trlll() {

157

e1tern int tess; /tTRAISLUCllCT LIYIL 13 SIT t/ nu •cl; e1tern int ratdist; if (raadist::O)

cl : fopen("co11and.d 0, "a");

if(raadist::l) cl : fopen("d:co11and.d 0

, "a"); dispat(l, 13); fprintf(cl, "dispat 1,13\n"); fclose(cl); } , ................. , trll4() /lTRAISLUCllCT LIVIL 14 SIT*/ { e1tern int tess; nu •cl; e1tern int ratdist; if(raldist::O)

cl : fopen("co11and.d 0, "a");

if ( ratdist:: l) cl : fopen("d:co11and.d 0

, ·a·); dispat(l, 14); fprintf(cl, "dispat 1,14\0°); fclose( cl); }

I lUUUUUUUU/ trll5() /lTRAISLOCllCT LXYIL 15 SKT t/ { extern int tess; nu •cl; e1tern int ratdist; if(raadist::O)

cl : fopen("co11and.d 0, "1°);

if(raadist::l) cl : fopen("d:co11and.d 0 , ·a·);

dispat(l, 15); fprintf(cl, 0 dispat 1,15\n°); fclose( cl); l

158

'***************************/ ccolor() I* SIT COLOR FUNCTION */ { extern int wdoir; extern double irinxl, irinx2, irinJl, irin12; extern int Yirxl, YiI2, YiJl, YWJ2; int colnu1; int ieJ; int cnt; colnu1:0; cnt:O; colordisp(); IOYe(70.Q, 463.0); color(32); rectr(70.0, 15.0); ke1:getcbe(); irbile(keJ !: QS)

{ svitcb(keJ)

{ case SP&CI: goto out; case NS: cnt:O;

goto oat; case RS: cnt:l;

goto oat; case TS: cnt:2;

coto oat; case GS: cnt:J;

coto oat; case BS: cnt:4;

coto oat; case SS: cnt:5;

coto out; case PS: cnt:6;

goto oat; case R&Ri : case FlO : case SII: linfan(2);

color( 32); rectr(70.0, 15.0); IOYer(70.0, 0.0); rectr(70.0, 15.0); cnt++;

case LARR: case 19 :

if(cnt>6) { rectr(70.0, 15.0); 10te(70.0, 463.0); rectr(70.0, 15.0J; cnt:O; }

break;

case FODR : linfun(2); color(32); rectr(70.0, 15.0); aoter(-70.0, 0.0); rectr(70.0, 15.0); cnt--; if(cnt<O)

{ rectr(70.0, 15.0); IOfe(490.Q, 463.0); rectr(70.0, 15.0); cnt:6; }

break; case ISC :

linfun(2); cnt=99; goto out;

default: ; }

te,.:getche();

out: ccolor2(cnt); }

159

'*******************! colordisp() /*SIT COLOR !KKU •I { cl beg( 252); VWPORT(0,639,0,479); vindov(0.0 , 639.0, 0.0, 479.0); TSIZK(l0.0); TJUST(l, l); KOYK(2.0, 465.0); COLOR( 32); text( "COLOR"); KOYKR(70.0, 0.0); color(224); text(. WBITr); KOYKR(70.0, 0.0); color(32); text(. no·); KOVKR(70.0, 0.0); COLOR(l28 l; text( "ULLOM"); !OVKR(70.0, 0.0); COLOR(64); text( • GRUN" l; KOVIR(70.0,0.0); COLOR(96); text(" BLOK"); !OVKR(70.0, 0.0); color( 218); text(" SlY"); !OVKR(70.0, 0.0); COLOR( 185); text(" PORPLK"); clend(); clrun(252);

160

/1ii11t11111ii1/ /I COLOR BRAICB FOICTIOIS *I

ccolor2{cnt) int cnt; { extern int 11do11; extern double 11inxl, 11inx2, 11in1l, 11in12; extern int YllXl, YllX2, Y1111, J1112; int colnu1; rectr(70.0, 15.0); cl run( 252); if(cnt::O)

{ c11hite(); }

if(cnt::l) { cred(); )

if(cnt::2) { c1ello11( l; )

if(cnt::3) { cgreen(); }

iflcnt::4) { cbloe( l: l

if(cnt::Sl {

cshl l: l

i fl r.nt::6 l (

r.oorolP.f l: l

if fvdov::Ol {

11indo11l1inxl. 11inx2, 11ia,1. 11in,21 YMPOIT(Yvxl, Y1112, ,,,1, J112); }

if(11do11::l) { Yvport(O, 319, 0, 239); )

} ·;uuuuutuuu/

161

cred() {

eitern int col.ra1disk: rILI •cl: color{ 281: col:28: if(raadisk==OI

cl : fno~nl"r.n11and.d". ·~·1:

I fl r;i1dhk::l l cl: fopen("d:co11and.d", "a"I:

fprintf(cl,"color 28 \n"); fclose( cl); }

JJ••·············••! cgreen() f eitern int col,ratdisk; fILI tel; color(59); col=59; if(ratdisk::O)

cl : fopen("co11and.d", "a"); if(ratdisk==l l

cl : fopen("d:co11and.d", "a"); fprintf(cl,"color 59 \n"); fclose(cl); }

J••···············•••/ cblue() { eitern int col,ratdisk; fILI •cl; color(92); col=92; if(ra1disk::O)

cl : fopen("co11and.d", "a"); if(ratdisk==ll

cl : fopen("d:co11and.d", "a"); fprintf(cl,"color 92 \n"); fclose( cl l; }

162

I* SIT AND FILI RID */

I* SIT AID f ILi GRiii *I

I* SIT AID fILI BLOK */

cyellow() { extern int col,raldisk; rn1 •cl; color( 128); col=128; if(raadisk::O)

cl : fopen("co11and.d", ·a·); if(raadisk==ll

cl : fopen("d:co11and.d", ·a·); fprintf(cl,"color 128\n"); fclose( cl); }

!•••••••••*********/ cpurple() { extern int col,ra1disk; rILI •cl; color( 156); col:158; if(ra1disk::O)

cl : fopen("co11and.d", "a'); if ( raldisk:: 1)

cl : fopen("d:co11and.d", 'a"); fprintf(cl,"color 156\n"); fclose( cl); }

1•••••••••••••••••1 csb() { extern int col,ra1disk; rILI •cl; color( 188); col=188; if(raadisk::O)

cl : fopen("co11and.d", ·a·); if ( raadisk:: 1)

cl : fopen("d:co11and.d", "a"); fprintf(cl,'color 188\n'); fclose( cl l; }

j.UUlUlUUUlU/

163

I* SIT AID FILI YILLON */

I* SIT AID JILi PURPLI •/

I* SIT AID JILi SIT •/

cvhite() { e1tern int col,ra1disi; flLI •cl; color(224); col=224; if(ra1disi::O)

cl : fopen("co11and.d 0, "a");

if(raldisi==l) cl : fopen("d:co11and.d", "a");

fprintf(cl, "color 224\n"); f close{ cl) ; }

·.ti••·················•••!

164

/i SIT AND FILI WBITI t/

165

TBISI FDNCTIOMS IMCLDDI ROTATION !AIM !IMO; SCALING rDMCTIONS; ROTATION ORDER FOHCTIONS */

linclude "std.h" linclude <fcntl.h> linclude <sys\types.h> linclude <sys\stat.h> linclude < io. h> linclude <stdio.h> linclude "keys.h"

•/t*************/ arotate() { extern int vdov,1enur;

I* !All BOTATIOM !l!O SILKCT */

extern double vinxl, vinx2, vinyl, viny2; extern int •vxl, •vx2, YVJl, •v12; char ch2; int cnt2; 1enur=l; cnt2:0; clbeg(253); linfun(2); fNPORT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); arotdisp(); IOYe(75.0,462.0); color(32); rectr(75.0, 15.0); ch2:getche(); vhile(ch2 != ISC)

{ svi tch ( ch2)

{ case ·s· : linfun(2);

color(32); rectr(75.0, 15.0); !OflR(75.0, 0.0); rectr(75.0, 15.0); cnt2++; if(cnt2>3)

{ rectr(75.0, 15.0); !Ofl(7S.0, 462.0); rectr(75.0, 15.0); cat2:0; }

break;

case ·4· : linfun(2); color(32); rectr(75.0, 15.0J; KOVIR(-75.0, 0.0); rectr(75.0, 15.0); cnt2--; if(cnt2<0)

{ rectr(T5.0, 15.0); IOYe(300.0, 462.0); rectr(75.0, 15.0); cnt2=3; }

break; case SPACI: goto out; case ·i·:cnt2:0;

goto out; case '( :cnt2=1;

goto out; case 'z' :cnt2:2;

goto out; case ·c· :cnt2:3;

goto out; default: ; }

ch2:getche(); }

out: 1rotate2(cnt2); 1enur=O; }

f***************I uotdisp() { TSIZl(l0.0); TJOST(l,l); KOVl(5.0, 465.0); COLOR( 32); teit(• ROTATI.); !OVIR(75.0, 0.0); COLOR(255J; tut(•I ROT·); !OVIR(75.0, 0.0); text("T ROT • ) ; !OVIR(75.0, 0.0); text("% ROT "); !OVIR(75.0, 0.0); text(• CORS "); clend(); clrun(253); }

166

I* BRANCHES TO I ROTATION MIKO •/

I* BRAICHIS TO Y ROTATION KIMO */

I* BRAICHIS TO Z ROT!TIOI MllU *I

I* KAii !!NU ROTIOI DISPLAY *I

'/*****************/ 1rotate2(cnt2) int cnt2; { e1tern int r1,ry,rz,rcnt1,rcnt1,rcnt1,vdov; e1tern doable vin1l, vin12, vinyl, viny2; e1tern int vv1l, vv12, vvyl, vvy2; char ch2; rectr(75.0, 15.0); clran(253); if (cnt2::0)

{ filterx(); 1rotl(); }

if(cnt2==1) { filtery(); 1roty(); }

if(cnt2::2) { filten(); 1rotz(); }

if(cnt2==3) { carsrot(); }

if (11do11::Q) { 11indo11(11in1l, vin12, vinyl, viny2); YVPOIT(v11l, vv12, ,,,1, vvy2); }

if(vdov==l) { vindov(1in1l, 1in12, 1iayl, 1in12); ••port(O, 319, 0, 239); }

printf("\ncount => %d",cnt2); }

167

I* ROT&TIOI BB&ICB TO fOMCTIOI ROOTIMI */

168

Ir••••••••••••••! cnrsrot() I* A TKST fDICTIOI fOR BKAL TIMK ROTATION*/ { int ch2; extern double x,y,z,orgx,orgy,orgz; extern int rx,rxt, ry, rz, speed,vdov; extern doable vinxl, vinx2, vinyl, viny2; extern int •1xl, •1x2, •1yl, •1y2; extern int ryt, rzt; if(1do11::0)

{ 1indo1(11inxl, 11inx2, vinyl, 1iny2); •vport(•1xl, '1x2, •vyl, '1y2); }

if(1do1::l) { 11indo1(1in1l, 1in12, vinyl, viny2); •vport(O, 319, 0, 239); }

if (1do11::0) cursor();

if(vdov::l) 1indo1s();

1dorg(org1,orgy,org1); printf("\nORIGI S.2f,S.2f,S.2f",orgx,orgy,orgz); ch2:getche(); 1bile(ch2 !: KSC)

{ S1itch(ch2)

{ case '6' :cursor();

ldroh( 5); cursor(); nt:ntt5; printf("COiSOR TIST Sd",r1t); break;

case · 4 • : cursor(); adrotx( -5); cursor(); nt:nt-5; printf("COiSOi TIST Sd",r1t); breai;

case T :cursor(); adroty(5); cursor(); ryt:ryt+5; printf("CURSOR TIST ld",rxt); breai;

case '2' :cursor(); idrotr(-5); cursor(); rrt=rrt-5;

169

printf("CORSOR TIST Sd",rxt); break;

case ·o· :cursor(); 1drotz(5); cursor(); rzt=rzt+5; printf("CORSOR TIST Sd",rxt); break;

case ·. · :cursor(); 1drotz ( -5); cursor(); rzt:rzt-5; printf("CORSOR TIST Sd",rxt); break;

default: ; }

printf("\nORIGM S.2f,S.2f,S.2f",orgx,orgy,orgz); cb2=getcbe(); }

rx=nt; ry:ryt; rz=rzt; }

Atttttttttttttttt/ fil ten() { extern double x,y,z,org1,or11,orgz; extern int rcntx,rcnty, rcnt1, rx, ry, rz; if ((rcnt1!:0)ll((rcnty!:O)::(rcnt1!:0)))

{ 1dorg(orgx,orgy,org1); if(rcntx::l)

{ if((rcnty::2)ll(rcntz::O))

{ ldroty(360-ry); ldrotx( 360-n); ry:O; rx:O; rz:O; rcaty:O; rcntx=l; rcat1:0; }

if((rcnty::2)ll(rcntz::3)) { adrotz( 360-rz); 1droty( 360-ry); 1drot1(360-n); ry:O; n:O; n:O; rcnty:O; rcntz:O; rcntx:l; }

if((rcntz::2)ll(rcnty::0)) { 1droh(360-rz); adrotx(360-n); ry:O; n:O; rz:O; rcnty:O; rcntz:O; rcntx:l; }

if((rcnt1::2)ll(rcnty::3)) {

}

ldrotz(360-ry); ldrotz( 360-rz); ldrotx( 360-n); ry:O; n:O; rz:O; rc11ty:O; rc11tz:O; rcatx:l; }

if(rcntx::2) { if((rcnty::l)ll(rcntz::O))

{ 1drotx(360-n); n:O; rz:O; rcnty:l; rc11t1:2; }

170

if((rcnt1==1lll(rcntz::3)) { 1drotz(360-rz); rz:O; 1drot1(360-n); n:O; rcnt1=l; rcntz:O; rcnt1:2; }

} filten2();

} filten3();

1 •••••••••••••••••• , filten2() { extern double 1,1,z; extern int rcnt1,rcnt1, rcntz, r1, r1 1 rz; if(rcntx::J)

{ if((rcnt1==l)ll(rcnt1::2))

{ ldrotx(360-n); n:O; rcnt1=l; rcnti:2; rcntx:3; }

if((rcnt1::l)ll(rcnt1==2)) { ldrotx( 360-n); n:O; rcnt1=2; rcnt&=l; rcntJ:3; }

171

/***************! filten3() { extern double x,y,z; extern int rcntx,rcnty, rcntz, rx, rJ, rz; if((rcntx::O)ll(ry::Q)&!(rz::O))

rcntx=l; if((rcnty::l)&!(rcntz==O))

rcntx:2; if((rcnty::2) ll(rcntz::l))

rcntx:3; if((rcntz::l) ll(rcnty::O))

rcntx:2; if((rcntz::2)ll(rcnty::l))

rcntx:l; printf("TIST TIST TIST rcnt1: ld",rcnt1); }

/S*************/ f il tery() { extern int rcnt1,rcnty, rcntz, rx, ry, rz; eztern double 1, y, z,org1,orgy,orgz; if ((rcnt1!=0lll((rcnt1!:0): :frcntz!:O)))

{ 1dorg(org1,orgy,orgz); if(rcnty::l)

{ if((rcnt1::2)ll(rcntz::O))

{ ldrotl( 360-n); 1droty( 360-ry); ry:O; n:O; rcnty: 1; rcntx:O; }

if((rcnt1::2)ll(rcntz::3)) { ldroh(360-n); ldrotx( 360-n); ldroty(360-ry); ry:O; n:O; n:O; rcnty:l; rcnh:O; rcnt1:0; }

172

} '***************/ '•

if((rcntz::2)ll(rcntx::0)) { adrotz(360-rz); 1droty(360-ry); rz:O; ry:l; rcntr=l: rcnh=O: )

if((rcntz::2)l&(rcntx::3))

}

{ 1drotI(360-n); 1drotz(360-rz); 1droty(360-ry); ry:l; n:O; rz:O; rcnty:l; rcntz:O; rcntx:O: }

if(rcnty::2) { if((rcntx::l)ll(rcntz::O))

{ rcnh=l; rcnty:2; }

if((rc1t1::l)ll(rcnt1::3)) { adrot1(360-n); n:O; adroty(360-ry); ry:O; rcntx:l; rcnh=O; rcnty:2; }

} filtery2();

} filtery3();

173

fil tery2() { e1tern int rcnt1,rcntJ, rcnti, r1, rJ, rz; e1tern double 11 J, z; if(rcnty::J)

{

}

if((rcnt1::l)ll(rcntz::2)) { 1droty(360-ry); ry:O; rcnti: 1; rcntz:2; rcnty:3; }

if((rcntz::l)ll(rcnt1::2)) {

}

1drot1( 360-rJ); ry:O; rcntz:l; rcnh:2; rcnty:3; }

luunuuuu/ filtery3() { e1tern int rcnt1,rc1ty, rcntz, r1, ry, rz; e1tern double 1, y, 1; if((rcnty::O)ll(r1::0)ll(r1::0))

rcnty:l; if((rcnt1==l)ll(rcnt1::0))

rcnty:2; if((rcnt1::2)ll(rcnt1::l))

rcaty:J; if((rc1tz==l)ll(rcnt1::0))

rcnty:2; if((rcntz::2)ll(rcnt1::l))

rcaty:3;

174

!•••**************/ filterz() { extern int rcntx,rcnty, rcnt1, rx, ry, r1; extern double x, y, z,orgx,orgy,orgz; if ((rcntz!:O)ll((rcntx!:O)::(rcnty!:O)))

{ 1dorc(orgx,orgy,orgz); if(rcnt1::l)

{ if((rcntx::2)ll(rcnty::0))

{ 1drotx( 360-n); adrotz{360-n); rz:O; n=O; rcntz:l; rcnti:O; }

if({rcntx==2)ll(rcnty::3)) { adroty(360-ry); 1drot1{360-n); 1drotz{360-n); ry:O; n:O; rz:O; rcnty:O; rcntz: 1; rcnti:O; }

if((rcnty::2)ll(rcntx::O)) { ldrot1( 360-ry); adrotz( 360-n); rz:O; ry:O; rcntz:l; rcnty:O; }

175

if((rcnt1::2)ll(rcnt1::3)) {

}

1drot1( 360-rx); 1drot1(360-r1J; 1drotz ( 360-rz); r1=0; u:O; rz:O; rcnt1=0; rcntz:l; rcntl:O; )

if(rcntz::2) { if((rcnt1::l)ll(rcnt1==0J)

{ 1drotz(360-n); rz:O; rcnt1:l; rcntz:2; )

if((rcnt1::l)ll(rcnt1::3)) { adrotJ ( 360-rJ) ; r1:0; 1drotz ( 360-n); rz:O; rcntx:l; rcntJ=O; rcntz:2; }

} filten2();

} filterz3();

} /aaaaaaaaaiaaaaaaaa/

176

fil teu2() { e1tern int rcnt1,rcnt1, rcntz, rx, r1, rz; e1tern doable x, J, z; if(rcntz::3)

}

{ if((rcntx::l)ll(rcnt1==2))

{ ldrotz(360-n); n:O; rcntl=l; rcnt1=2; rcntz:3; }

if((rcnt1==l)ll(rcnt1::2)) { ldrotz( 360-rz); n:O; rcnt1=l; rcntI=2; rcntz:3; }

IJ•••••••••••••••! ,, fil terz3() { e1tern int rcnt1,rcnt1, rcatz, r1, r1, rz; e1tern doable 1, J, z; if((rcntz::O)ll(r1::0)ll(r1::0))

rcntz:l; if((rcnt1==l)ll(rcnt1::0))

rcntz=2; if((rcnt1==2)ll(rcnt1::l))

rcntz:3; if((rcnt1::l)ll(rcnt1==0))

rcatz:2; if((rcnt1::2)ll(rcnt1::l))

rcntz:3; }

~··············••!

177

1scale(l f extern int idoi: extern double winxl. win12. vin1l. vin12; extern double Yill, Yw12, Yw1l, Yw12; char cb3; int cnt3; cnt3:0; cl beg( 253); linfun(2); VWPORT(0,639,0,479); window(O.O , 639.0, 0.0, 479.0); scaledisp(); IOYe(0.0, 415.0); color(32); rectr(60.0, 15.0); cb3=getcbe(); vbile(cb3 !: ·n·)

{ svitcb(cb3)

{ case ·2· : linfun(2);

color(32); rectr(60.0, 15.0); toYer(0.0, -25.0); rectr(SO.O, 15.0); cnt3tt; if(cnt3>7)

{ rectr(SO.O, 15.0); IOYe(0.0, 415.0); rectr(SO.O, 15.0); cnt3:0; }

break; case '8' : linfun(2);

color(32); rectr(60.0, 15.0); IOYer(0.0, 25.0); rectr(60.0, 15.0); cnt3--; if(cnt3<0)

{ rectr{60.0, 15.0); IOYe(O.O, 240.0); rectr(60.0, 15.0); cnt3:7; }

break;

178

default: goto out ; } printf("count:: Xd\n" ,cntJ); chJ:getche( l;

out: 1scale2 ( cn tJ l; }

!•***************! scaledisp() { TSIZK(l0.0); TJDST(l,l); KOVK(2.0, 468.0); COLOR(255); text("SCALK "); KOVKR(O.O, -50.0); te1t("I Y Z "); KOVKR(O.O, -25.0); text( ·1 urs· l; KOVKR(O.O, -25.0); COLOR(255); text("Y AIIS"); MOVKR(O.O, -25.0); text( ·z urs· l; KOVKR(O.O, -25.0J; teit("I Y "); KOVKR(O.O, -25.0); teit("I Z"); KOVKR(O.O, -25.0); text("Y Z"); KOVKR(O.O, -25.0); text(" KKTKR "l; cl end(); cl run( 253); }

/:UUUUUUUU/ 1scale2(cnt3) int cnt3; { extern int 1do1; extern double 1in1l, 1in12, vinrl, vinr2; extern int vv1l, Yv12, ,,,1, ,,,2; char ch3; rectr(60.0, 15.0); clrun( 253);

179

if(cnt3::0) { 1scalexrz( l; }

if(cnt3==1l { 1scalexy:r:(); }

if(cnt3::2) { 1scalex(); }

if(cnt3::3) { ascaley(); }

if(cnt3::4) { 1scalez(); )

if(cnt3::5) { 1scalexy( l; }

if(cnt3==6) { ascalen( l; }

if(cnt3::7) { 1scaley:r:(); }

if (vdov::O) { vindov(vinxl, vinx2, vinyl, viny2); VNPORT(tvxl, tvx2, tvyl, tvy2); }

if(vdov::l) { tvport(O, 319, 0, 239); }

printf("\ncount => ld",cnt3); } , ................. ,

180

1scalexJz() { extern double x,J,z,orgx,orgJ,orgz; extern int raldisi; extern double s1,sJ,sz; float s1l,sJl,szl; FILI *cl; char s; if(s1!=1.0)

{ ldorg(org1,org1,orgz); ldscal((l.O/s1),(l.O/s1),(l.O/sx)); }

printf("\nlMTIR SCALI RATIO"); while(scanf("Sf",ls1l) !:l)

{

181

printf("PLIASI OSI MOKIRIC IIPOT; TRY AGAIM.\n"); scanf (·sis·); }

while(getchar()!:'\n'); printf("\nTKST TKST s1: X.2f", s1l); sJ=sll; sz:s1l; 51:511; ldorg(org1,orgy,org1); ldscal(s1,sJ,sz); printf("\nsx: S.Zf, SJ: X.2f, sz =X.Zf",s1, SJ, sz);

if(ra1disi::O) cl : fopen("co11and.d", "a");

if ( raldisi==l) cl : fopen("d:co11and.d 0

, "a"); fprintf(cl, "\nldorg X.2f, S.2f, S.2f\n" ,org1,orgJ,orgz); fprintf(cl, "\nldscal S.Zf, S.Zf, S.2f\n" ,s1,sJ, sz);

fclose(cl); I }

-/*****************/

1scalex() { extern int ra1disk; rILI •cl; float SI,SJ,sz; char s; sx:l.O; sJ=l.O; sz=l.0; printf("\nlKTIR SCALI RATIO"); wbile(scanf("lf",lsx) !=ll

{

182

printf("PLIASI OSI NO!IRIC IMPOT; TRY AGAI!.\n"); scanf("Us"); }

vhile(getchar()!:'\n'); printf("\nTIST TIST s1: l.2f", sx); ldscal(s1, SJ, sz); printf( 0 \ns1: l.2f, SJ: l.2f, sz =l.2f 0 ,s1, sy, sz); if(raldisi::O)

cl: fopen( 0 co11and.d", "a"); if(radisi==ll

cl : fopen("d:co11and.d", "a"); fprintf(cl,"\n1dscal l.2f, l.2f, l.2f\n" ,s1,sJ, sz);

fclose(cl); }

Is••••••••••••••••/ 1scaleJ() { extern int ra1disi; 1ILI *cl; float s1, SJ, sz; 51:1.0; sJ=l. 0; sz:l.O; printf("\nl8TIB SCALI RATIO"); vhile(scanf("lf",lsJ) !:l)

{ printf("PLIASI OSI IU!IBIC IBPUT; TRY &GAIM.\n"); scanf("Us"); }

vhile(getchar()!:'\n'); printf("\nTIST TIST s1: l.2f", SJ); 1dscal(s1 1 SJ, sz); printf("\DSI : l.2f, SJ : l.2f, sz :l.2f" ,SI, SJ, sz); if(radisi::O)

cl : fopen("co11and.d 0, "a");

if( raldisi==l) cl : fopen("d:co11and.d", "a");

fprintf(cl, "\nldscal l.2f, l.2f, l.2f\n" ,s1,sy, sz); fclose( cl l;

'********•••••••••! 1scalez() { e1tern int ra1disl; l!LI •cl; float s1,sy,sz; s1:1.0; sy:l.0; sz:l. 0; printf("\nllTIR SCALI RATIO"); while(scanf("lf",lsz) !=ll

{ printf("PLIASI OSI MO!IRIC IIPOT; TRY AGAil.\n"); scanf("Us"); }

while(getchar()!:'\n'); printf("\nTIST TIST sz: l.2f", sz); 1dscal(s1, sy, sz);

183

printf("\ns1: l.2f, sy: l.2f, sz :l.2f0 ,s1, sy, sz); if(ra1disi::O)

cl: fopen("co11and.d", "a"); if ( ra1disi:: 1)

cl: fopen("d:co11and.d", "a"); fprintf(cl, "\n1dscal l.2f, l.2f, %.2f\n" ,s1,sy, sz);

fclose( cl); }

!*****************! 1scale1y() { e1tern int raldisl; flLI •cl; float s1,sy,s1; 51:1.0; sy:l.O; 51:1.0; printf("\nllTIR SCALI RATIO"); while(scanf("lf",ls1) !:l)

{ printf("PLIASI OSI IO!IBIC IIPOT; TRY AGAil.\n"); scant ( ·s•s • l; }

vhile(getchar()!:'\n'); printf("\nTIST TIST s1: l.2f", s1); printf("\nllTIR SCALI RATIO Y"l;

vhile( scanf ( ·u·, lsJ l ! =1 l { printf('PLllSI OSI MOKIRIC IMPOT; TRY IGAIM.\n"); scanf( "Us·); }

vbile(getcbar()!:·\n·J; printf("\nTIST TIST SJ: l.2£", SJ);

184

printf("\ns1 : l.2f, SJ : l.2f, SI :l.2£" ,SI, SJ, S&); 1dscal(s1, SJ, sa); if(ra1disi::O)

cl : fopen("co11and.d", "a'); if(raldisi==ll

cl : fopen('d:co11and.d", 'a'); fprintf(cl, 0 \n1dscal l.2£, l.2£, l.2f\n" ,s1,sJ, sa);

fclose(cl); }

'************''*''' 1scaleu() { extern int ra1disi; nu •cl; float s1, SJ, u; 51:1.0; sJ=l.O; s1:1. 0; printf('\nllTIR SCALI RATIO I'); 1bile(scanf('lf',ls1) !=1)

{ printf("PLIASI OSI IOKIRIC IIPOT; TRY AGAil.\n'); scanf I 'l•s ·) ; }

1bile(getcbar()!:'\n·J; printf("\nTIST TIST s1: l.2f', s1); printf('\nllTIR SCALI RATIO %'); vbile(scanf("Sf',ls1) !:1)

{ printf('PLIASI OSI IOKIRIC IIPOT; TRY AGAll.\n"); sca1f('S•s"); }

vbile(getcbar()!:'\n'); printf('\nTIST TIST s1 : l.2f', s1); printf("\DSI: l.Zf, SJ: l.2f, SI :S.Zf",s1, SJ, SI); ldscal(s1, SJ, sa); if(raldisi==Ol

cl : fopen('co11and.d', 'a'); if ( raldisi:: 1)

cl: fopen('d:co11and.d', 'a'); fprintf(cl,'\nldscal l.2f, l.2f, l.2f\n",s1,sJ, s1);

fclose( cl);

, ................. , · 1scale1z()

{ extern int ra1disk; nu •cl; float s1,s1,sz: s1:1.0; sr:l.O; sz:l. 0; printf("\nKITKR SCALI RATIO Z"); vbile(scanf("Sf" ,lsz) !=ll

{ printf{"PLKASK DSK MDKKRIC llPDT; TRY AGAil.\o"J; scanf (·sis·); }

vbile(getcbar()!:'\n'); printf{"\nTKST TEST sz: S.2f", sz); printf("\nllTKR SCALI RATIO Y"); vbile(scanf("Sf",ls1l !=1)

{

185

printf("PLKASK DSK IDKKRIC IIPDT; TRY AGAil.\o"); scanf (·us·); }

vbile{getcbar()!:'\n'); printf("\nTIST TIST s1: S.2f", s1); printf("\ns1: S.2f, s1: S.2f, sz :S.2f",s1, s1, sz); tdscal(s1, s1, sz); if(ratdisk::O)

cl : fopen("co11and.d", "a"); if( ratdisk==l)

cl : fopen("d:co11and.d", "a"); fprintf(cl, "\n1dscal S.2f, S.2f, S.2f\n",s1,s1 1 sz);

fclose( cl l; } , ................ ,

186

/.reIS SIT or PDMCTIOMS DIALS MAINLY WITH IIICDTIKG ROTATION FOMCTIOMS •/

linclude "std.b" linclude <fcntl.b> linclude <srs\types.h> linclude <sys\stat.h> linclude <io. b> linclude <stdio.h> linclude 'keys.h'

'************••••! llOtl() { e1tern double org1,orgy,orgz; e1tern int r1,r1cnt1,adov; char ch3; int cntn; int nd; ldorg(org1,orgy,orgz); if( n! :0)

{ nd=360-n; ldrotl(nd); n:O; }

setscreen(); cntn:O; YVPOBT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); ndisp(); IOJe(0.0, 465.0); color(32); rectr(32.0, 15.0); ch3=getche(); YVPORT(0,639,0,479); 1indo1(0.0 , 839.0, 0.0, 479.0);

abile( ch3 ! : · q') { svitcb(cb3)

{ case r : goto out2;

break;

case ·,· : goto oat2; break;

case 'f : left(); break;

/t BRAICBIS TO ROTATE I KIKCOTIOI FOMCTIOIS t/

/t DISPLAYS !110 t/

/t BRAICB TO T AIIS t/

I* BRAICB TO % AIIS t/

/t TBAISLATK LKrT t/

187

case '6' : right(); /t TRAMSLATI RIGHT•/ break;

case CR: linfun(2); /l DRAWS IftAGI t/ color(32); rectr(32.0, 15.0); cpri1(); VMPORT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); linfun(2); color(32); '°'e(O.O, 465.0); '°'er((cntr1t35.0),0.0); rectr(32.0, 15.0); break;

case ·a· : up(); /a TRAISLATI t/ break;

case ·2· : dovn(); !• TRAISLATK t/ break;

case ·o· : forward(); /t TRAISL!TI t/ break;

case T : upleft(); break;

case ·3· : downright(); break;

case ·. · : back(); break;

case T : up(); case r10 : linfun(2);

color(32); rectr(32.0, 15.0); '°'er(35.0, 0.0); rectr(32.0, 15.0); catn++; if(cntn>17)

{ rectr(32.0, 15.0); '°'e(O.O, 465.0); rectr(32.0, 15.0); cntn:O; }

rears( cntn); break;

!• TRUSLA Tl t I

/t TRANSL!TI •/

/t TRAISLATI t/

!• TRUSLATK t/

case ·1·: dovn(); case f9 : linfun(2);

color(32); rectr(32.0, 15.0); IOYer(-35.0, 0.0); rec tr( 32. 0, 15. 0); cntn--; if(cntn<O)

{ rectr(32.0, 15.0); IOYe(595.0, 465.0); rectr(32.0, 15.0); cntn:17; }

rcurs2( catn); break;

case ISC: cntrx=18; color(32);

linfun(2); rectr(32.0, 15.0); coto out ; default: ;

YNPOBT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); ch3:getche(); }

out:

ncntx:cntn; YNPORT(0,639,0,479); 1indo1(0.0 , 639.0, 0.0, 479.0); 1rot12(cntn); out2: if(ch3==·z·)

{

}

ndisp(); linfun(2); '°'e(O.O, 465.0); 10Yer((cntr1•35.0),0.0); color(32); rectr(32.0, 15.0); setscrn( l; f il terz(); uotz();

188

!• TRAMSLATK •/

I* BITDRI TO ~AIK a;

/t BBAICH TO Z AIIS t/

}

if(ch3::'( l { ndisp(); linfun(2); 10Ye(O.O, 465.0); IOJer((cntrx•35.0),0.0); color(32); rectr(32.0, 15.0); setscrn(); filtery(); 1roty(); }

'·············••/ setscreen() { extern doable 1in1l, vin12, vinyl, 1iny2; extern int 1dov,Yv1l, Yvx2, JIJl, y;y2; if (vdov::O)

{ cursor(); }

if(vdov::l)

}

{ 1indovs(); }

189

I* BRANCH TO Y AIIS •/

I* DRAWS CURSOR TO THI SCRllM */

l•*************I rcars(cntn) I* lllCUTIS ROTATIOI AMGLI TO BOARD */ int cntn; { extern int r1,1dov; extern doable x,y,1,org1,orgy,orfx; char ch3;

setscrn(); ldorg(orgx,orgy,orgz); if(n ::360)

n:O; if(cntn::O)

{ n:O; }

I* SITS KODILIIG ORIGII *I

I* fILTIRS CHOICI THll lllCUTIS COKKAMD *I

if(cntrx::l) { rx:O; }

if(cntrx==2) { rx:30; 1drot1(30); }

if(cntrx::3) { n=45; 1drot1(15); }

if ( cntn::4) { n=60; 1drotI( 15); }

if ( cntn::5) { n=90; 1drot1(30); }

if(cntn::6) { n=l20; 1drotI( 30); }

if(cntn::7) { n=l35; 1drotI(15); }

if(cntn::8) { n=150; 1drotI(l5); }

if ( cntn::9) { n=l80; 1drotI(30); }

if(cntn::lO) { rx=210; adrot1(30); }

190

if(cntn::ll) { n=225; 1drot1( 15); }

if(cntn::12) { n:HO; 1drot1(15); }

if(cntn::13) { n=270; 1droh(30); }

if ( cntn::l 4) { n:300; 1droh(30); }

if(cntn::15) { n=315; adroh(15); }

if(cntn::16) { n:330; 1droh(15); }

if(cntn::17) { n:O;; if(n >= 360) n:O; 1droh(30); }

if(n >= 360) n:O;

setscreen ( l; VMPORT(0,639,0,479); iindov(O.O , 639.0, 0.0, 479.0); }

/:uuuuuua/

191

rcurs2 (en trx) int cntn; { extern int vdov ,rx; extern double x,y,z,orgx,orgy,orgz; extern int Yvxl, Yvx2, Yvyl, Yvy2; char chl; setscreen(): 1dorg(orgx,orgy,orgz); if(cntrx==17)

{ n:O; }

if(cntn::O) (

rt:O: l

i fl r.nt.rt::1'

' rt:O: •rlrot.tl-~Ol:

l ; flrnt.rr::?l

( n:30: idrotx(-15); l

if ( cntn::J l { rx=45; idrotx(-15); }

if(cntn::() { n:SO: 1droh(-30l: l

if ( cntn::5) ( rx=90; idrotx(-30); }

if(cntn::6) { n=120; idrotx(-15); }

192

I* ROTATES N!GATIY! */

if(cntn::7) { n=l35; adrotx(-15); }

if(cntn::8) { n=l50; adrotx(-30); }

if(cntn==9l { n=l80; adrotx(-30); }

if(cntn::tO) { n=210; adrotx(-15); }

if(cntn==ll) { n=225; adrotx(-15); }

if(cntn==12) { n=240; adrotx(-30); }

if(cntn==ll) { n=270; adrotl(-30); }

if(cntn::14) { n=300; adrotx(-15); }

if(cntn==15) { n:315; tdrotx(-15); }

193

if(cntrx::16) { n:330; idrotx(-30); }

setscreeD( l; VMPORT(0,639,0,479); aiodoa(O.O , 639.0, 0.0, 479.0); )

/UUUUUUU/

194

rxdisp() !•I ROTATION KKND DISPLAY•/

{ clbeg(253); linfun(2);

VMPORT(0,639,0.479); vindov(O.O , 639.0, 0.0, 479.0); TSIZK(10.0); TJDST(l, l l; KOVK(l.O, 468.0); COLOR(210); text(" I"); KOVKR(35.0, 0.0); color(96); text(" 0"); KOYKR(35.0, 0.0); color(224); text(· 30"); KOYIR(35.0, 0.0); color(218); text(· 45 ·) ; KOVKR(35.0, 0.0); color(224); text(· 60 • J; ROYIR(35.0, 0.0); COLOR(96); text(· 90" J; colorf 224); KOVIR(35.0, 0.0); text("120"); KOVIR(35.0, 0.0); color( 218); text( "135" l; color(224J; KOVIR(35.0, 0.0); text( "150"); ROYIR(35.0, 0.0);

color(96); text( "180"); !OYIR(35.0, 0.0); color(224); text("210"); !OYIR(35.0, 0.0); color(218l; text("225"); color(224); !OYIR(35.0, 0.0); text( "240"); !OYIR(35.0, 0.0); color(96); text( ·210·); !OYIR(35.0, 0.0); color(224); text( "300"); !OYIR(JS.O, 0.0); color(218); text ( • 315.) ; !OVIR(35.0, 0.0); color(224); text("330"); color(96); !OVIR(35.0, 0.0); text( "IIIT"); clend(); clrun(253); }

195

/UUUUUUl/ 1rotx2(cntn) int cntn;

/llSSIGWS VALOI TO RI "I ROTATIOI VARIBLI"•/

{ extern int r1,rcnt1,vdov; extern double vin1l, vin12, vin1l, vinJ2; extern double YVIl, •112, YVJl, YVJ2; char ch3; int nd; cl run( 253); if(cntn::O)

{ entenal1(); }

if(cntn==ll {

}

n:O; rcnti:O;

if(cntn::2) { n:30;

} if(cntn::J)

{ n=45 ; }

if(cntn::4) { n:60 ; }

if(cntn::5) { n:90 ; }

if ( cntn::6) { n=l20 ; }

if(cntn::7) { n=135 ;

} if ( cntu::8)

{ u=lSO ; }

if(cntn::9) { u:l80 ; }

if(cntu::lOJ { n:210 ; }

if ( cntn::ll) { n:225 ; }

if(cntn::12) { n=240 ; }

if(cntu::l3) { u:270 ; }

196

iflcntn::14) { n:JOO ; }

if(cntn==l5) { n=315 ; }

if(cntn::16) { n=330 ; }

setscreen( l; printf("\ncount => Xd" ,cntrx);

} tuuuuiuu/

entenah() { extern double x,y,z,orgx,orgy,orgz; extern int rxt,rcntx; extern int vdov,rx,rx2; int nd; extern double ainxl, ainx2, ainyl, viny2; extern int •vxl, •vx2, •v1l, •a12; FILI •cl; setscreen(); if(n!:O)

{ nd:360-n; ldrotx(nd); }

printf("\nllTIR I ROTATIOK"); ahile(scanf("Xd" ,lrx) !:1)

{

197

I* ALLOWS DSIR TO TYPI II VALOI */

I* IRASIS CORSOR•/ I* RISITS ROTATIOI VALOI */

I* DISPLAYS QOIRT *I I* TISTS FOR IOKIRIC VALOI t/

printf("PLIASI DSI ID!IRIC IIPDT; TRT AGAil.\n"); scanf (·us·); }

vhile(getchar()!:'\n'); if(n>360)

n:O; if(n::J60)

n:O; if(nt >360)

{ nt:nt-360; }

if(n::O) rcntx:O;

/t TIST FOR CARRIAGI RITORI */

1dorg(orgx,orgy,orgz); 1drotx(r1); nt:nt+n;

n2=n; setscreen();

} /'UUUUUUU/

1rot1() { extern int r1,r1cnt1,vdo1;

198

I* SITS !ODILIHG OBIGH *I I* IIICOTIS BOT&TIOM CO!!&HD *I

I* SAKI PBOCIDOBI AS !BOTI()*/

extern double 1,y,z,org1,org1,orgz, 1in1l, 1in12, 1inyl, 1in12; extern int Yv1l, y112, yvyl, YVJ2; char ch3; int entry; int ryd; 1dorg(org1,orgy,org1); if(ry!:O)

{ r1d=360-ry; ldroty( ryd); r1=0; }

setscreen(); cntry:O; rydisp(); IOYe(O.O, 465.0); color( 32); rectr(32.0, 15.0); ch3:getche(); YWPORT(0,639,0,479); 1indo1(0.0 , 639.0, 0.0, 479.0);

1hile(ch3 !: ·q·) { svitch(ch3)

{ case '1' : goto out2;

break;

case ·,· : goto out2; breai;

case ·4· : left(); breai;

case ·5· : right(); breai;

case CR : linfun(2); color(32); rectr(32.0, 15.0); cpri1( l; YWPORT(0,639,0,479);

199

vindov(O.O , 639.0, 0.0, 479.0); linfun(2); color(32); IOYe(0.0, 465.Q); 10Yer((cntr1•35.0),0.0); rectr(32.0, 15.0); break;

case T : up(); break;

case ·2· : dovn(); break;

case ·o· : for1ard(); break;

case ·7· : upleft(); break;

case ·3· : dovnright(); break;

case ·. · : back(); break;

case ISC: cntr1=18; color(32J; linfun(2); rectr(32.0, 15.0); goto out ;

case IIH: up(); case r10 : linfun(2);

color(32); rectr(32.0, 15.0); IOYer(35.0, 0.0); rectr(32.0, 15.0); cntr1++; if ( cntr1> lT)

{ rectr(32.0, 15.0); IO'e(O.O, 465.0); rectr(32.0, 15.0); cntr1:0; }

rcursr( cntrr l; break;

case 011: do1n(); case F9 : linfun(2);

color( 32); rectr(32.0, 15.0); IOYer(-35.0, 0.0); rectr(32.0, 15.0); cntrr--; if(cntr1<0)

{ rectr(32.0, 15.0); IOfe(595.0, 465.0); rectr(32.0, 15.0); cntr1=1T; }

rcurs12(c1tr1); break;

default: ;

YWPOiT(0,639,0,479); 1indo1(0.0 , 639.0, 0.0, 479.0);

printf("count:: Sd\n",cntr1); ch3:getche();

} out: r1c1t1=cntr1; YWPOiT(0,639,0,479); vindo1(0.0 , 639.0, 0.0, 479.0); 1rot12(cntr1); out2: if(cb3::'z')

{

}

r1disp(); linfun(2); IOf8(0.0, 465.0); 10Yer((c1tr1•35.0),0.0); color(32); rectr(l2.0, 15.0); setscrn(); filterz(); 1rotz();

200

if(ch3==·x·) {

}

}

rJdisp(); linfun( 2); IOYe(O.O, 465.0); 10Yer((cntr1•35.0),0.0); color( 32); rectr(32.0, 15.0); setscrn(); filten(); 1rot1();

''**************! rcurs1(cntr1l int entry; { extern int ry,wdov;

201

extern double 1,y,z,org1,org1,orgz,win1l, win12, vinyl, winr2; extern int fill, Yvx2, Yvyl, Yvy2; char ch3; setscreen () ;

ldorg(org1,orgy,orgz); if(rr >=360)

ry:O; if(cntry::O)

{ ry:O; }

if( entry:: l) { ry:O; }

if(cntr1==2l { ry:30; 1droty( 30); }

if ( cntry::J) { ry:45; ldroty(15); }

if(cntrr==4) { ry:60; ldroty( 15); }

if(cntry::5) { ry:90; 1droty( 30); }

if(cntry::6) { ry:120; ldroty( 30 l; }

if(cntry::7) { ry:135; 1droty( 15); }

if(cntry::8) { ry:150; 1droty( 15); }

if(cntry::9) { ry:180; 1droty( 30); }

if(cntry::lO) { ry:210; 1droty(30); }

if( cntry::ll) { ry=225; 1droty( 15); }

if(cntry::12) { ry:240; 1droty( 15); }

if(cntry::13) { ry:270; 1droty( 30); }

202

if ( cntr1==l4) { ry:300; 1drot1(30); }

if(cntr1==15) { rr=315: 1drot1(15); }

if!cntrr==16l ( ry:J30; 1droty(15); }

if(cntry::17) { ry:O; 1drot1(30); }

setscreen(); YVPORT(0,639,0,479); 1indo1(0.0 , 639.0, 0.0, 479.0); }

ftUUUtUUU/ rcurs12(cntr1) int entry; { e1tern int ry,1do1;

203

e1tern double 1,y,1,org1,orgy,org1,1in11, 1in12, vinyl, viny2; e1tern int •111•, •112•, ••Y1•, ••y2t,t11l, •112, •111, •1y2;

char ch3; setscreen(); ldorg(org1,orgy,org1); if ( cntrr==O)

{ ry:O; }

if(cntr1::t) { ry:O;

}

if(cntry::l) { ry:30: 1droty( ·30}; }

if ( cntry::2) { ry:4S; 1droty( ·15); }

if( cntry::3) { ry:SO; ldroty( • 15); }

if(cntry::4) { ry:90; 1droty( ·30 l; }

if(cntry::S) { ry:120; 1droty( ·30); }

if(cntry::S) { ry:13S: 1drotrl·lSl: l

if(cntrr::7) f rr:lSO: 1drotrl · 15 l: l

if(cntry::8) { rJ=180; 1drot1( ·30); }

if(cntry::9) {

ry:210; ldroty( ·30); }

204

if(cntrr==lO) { rr=225; idroty(-15); }

if(cntr1==1l) { rr=240; 1drot1(-15); }

if(cntr1==12) { rr=270; adroty(-30); }

if(cntr1==l3) { ry:300; 1drot1(-30); }

if( cntry::14) { rr=315; 1drot1(-15); }

if(cntr1==15) { rr=330; 1drot1(-15); }

if( cntrr==16) {

rr=O; ldrotr(-30); }

setscree;(); YWPORT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); }

IUUUUUUt/

205

rydisp() { clbeg(253); linfun(2); VWPORT(0,639,0,479); 11indo11(0.0 , 639.0, 0.0, 479.0); TSIZl(l0.0); TJOST( l, 1 l; !Oil(l.O, 468.0); COLOR( 32 l; text(" Y "); !OVKR(35.0, 0.0); color(96); text(" 0"); !OVKR(35.0, 0.0); color(224); text(" 30"); !OVIR(35.0, 0.0); color(218); text(" 45"); !OVIR(35.0, 0.0); color(224); text(" 60 "); !OVIR(35.0, 0.0); COLOR( 96); text(" 90"); color( 224 l; !OVIR(35.0, 0.0); text("l20"); !OVIR(35.0, 0.0); color(218); text("l35"); color(224); !OVIR(35.0, 0.0); text( ·150·); !OVIR(35.0, 0.0); color(96); text(· uo· J; !OVIR(35.0, O.OJ; color(224); tut("210"); !OVIR(35.0, 0.0); color(218); tut( "225"); color(224); !OVIR(35.0, 0.0); tut( ·240·); !OVIR(35.0, 0.0);

206

color(96); text( ·210·); ~OYIR(35.0, 0.0); color( 224 l: text( "300" l; ~OVIR(35.0, O.Ol: color(218); text("315"); MOVIR(35.0, 0.0); color(2241: text(· 330" l: color(96l; MOVIR(35.0, 0.0); text("llIT" l; cl end(); clrun(253l; }

/UUUUUU/ uoty2(cntry) int cntr1; { extern int r1,rcnt1,vdov; extern double vin1l, vin12, vinyl, viny2; extern double •v1l, •v12, •v1l, •vy2; char ch3; int ryd; clrun( 253); if(cntry::O)

{ enternly(); }

if (CD try:: 1 ) { ry:O; rcnty:O; }

if(cntry::2) { r1=30; }

if(cntr1==3) { ry:45 ; }

if (cntry::4) { ry:60 ; }

207

if(cntry::5) { ry:90 ; }

if (cntry::6) { ry:120 ; }

if(cntry::7) { ry:135 ; }

if(c11try::8) { ry:150 ; }

if(cntry::9) { ry:180 ; }

if(cntry::10) { r1=210 ; }

if(cntry::ll) { ry:225 ; }

if(cntry::12) { ry:240 ; }

if(cntry::13) { ry:27D ; }

if ( cntry::14) { ry:300 ; }

if( cntry::lS) { ry:315 ; }

if(c11try::l6) { ry:330 ; }

208

if (11do11::0) { cursor(); }

if(vdov::l) { 11indo11s(); )

printf("\ncount => Sd 0 ,cntr1); }

/11i11a11aaa111/ enternb() { extern double 1,1,1.org1,orf1,org1; extern int r1t,rcnt1; extern int vdo11,r1,r12; int r1d; extern double vin1l, vin12, vin1l, 1in12; e1tern int Y11l, yv12, ,,,1, Y1112; rILI lcl; if (vdo11::0)

{ cursor(); }

if(1dov::t) { 1indo1s(); )

if ( r1! :0) { r1d=360-r1; ldrot1 ( r1d) ; }

printf("\nllTIR Y ROTATIOI"); 1hile(scanf{ 0 Sd 0 ,lr1l !:1)

{

209

printf("PLIASI OSI IOBIRIC IIPOT; TRY AGAil.\n"); scanf ( ·sis·) ; }

vhile(getchar()!:'\n'); printf("\nTIST TIST r1: Sd", r1); if(r1>360)

r1:0; if(r1::360)

r1:0; if (r1t >360)

{ r1t=r1t-360;

}

if(ry::O) rcnty:O;

1dorg(orgx,org1,orgz); 1droty( ry); ryt:ryt+ry; printf("\nrrt: Xd", ryt); ry2:ry; if(11do11::Q)

{ cursor(); }

if(11dov::l) { windovs(); }

fUUUUUUU/ 1roti() { extern int r1,rzcntz,11do1;

210

!• SA!I PROCIDORI AS !ROTI()*/

extern double 1,y,1,org1,orgy,orgz, vinxl, 1in12, 11in1l, 1in12; extern int •1111, •1112, •1111, •1112; char ch3; int cnt3; int nd: 1dorg{orgx,or11.orgz); cnt3:0; if(n! :0)

{ nd:360-n; ldrotz(nd); n:O;

} setscreen(); rzdisp( l; ao•e(O.O, 465.0); color(32); rectr(32.0, 15.0); chJ:getche( l; 11hile(ch3 !: 'q')

{ svitch(ch3)

{

case 1 : roto out2; break;

case J : goto out2; break;

case ·4· : left(); break;

case T : right(); break;

case Ci : linfun(2); color( 32); rectr(32.0, 15.0); cpri1(); YVPORT(0,639,0,479);

211

vindov(O.O , 639.0, 0.0, 479.0); linfun(2); color(32); 10fe(O.O, 465.0); IOYer((cnt3•35.0),0.0); rectr(32.0, 15.0); break;

case '8' : up(); break;

case T : dovn( l; break;

case 'O' : forward(); break;

case T : upright(); break;

case · T • : aplef t() ; break;

case · 1 · : donleft(); break;

case ·3· : do1nright(); break;

case : back(); break;

case ISC: cnt3:18; color(32); linfun(2); rectr(32.0, 15.0); goto out ;

case flO : linfun(2); color(32); rectr(32.0, 15.0); 10Jer(35.0, 0.0); rectr(32.0, 15.0); cntl++; if(cnt3>17)

{ rectr(32.0, 15.0); 10Je(O.O, 465.0); rectr(32.0, 15.0); cat3=0; }

rcursz( cnt3); break;

case f9 : linfun(2); color(32); rectr(32.0, 15.0); 10Jer(-35.0, 0.0); rectr(32.0, 15.0); cnt3--; if(cnt3<0)

{ rectr(32.0, lS.0); IOJe(595.Q, 465.0); rectr(32.0, 15.0); cnt3=1T; )

rcursz2(cnt3); break; default: ;

} YMPORT(0,639,0,479); &indo&(O.O , 639.0, 0.0, 479.0);

ch3:getche(); }

out: ncntz=cnt3; YWPORT(0,639,0,479); iindo&(O.O , 639.0, 0.0, 419.0); uotz2 ( cnt3); out2:

212

if(cbJ::'y') {

rzdisp(); linfun(2); IOYe(0.0, 465.0); 10Yer((cnt3i35.0),0.0); color(32); rectr(32.0, 15.0); setscrn(); f il ter1(); 1rot1();

} if(cbJ::'1') {

}

}

rzdisp(); linfun(2); IOYe(0.0, 465.0); 10Yer((cnt3*35.0),0.0); color(32); rectr(32.0, 15.0); setscrn(); fil ten(); arotl();

/UUUSUUU/ rcursz ( cn t3) int cnt3; { extern int rz,vdov;

213

extern double 1,1,z,orgx,orgy,orgz,vinxl, vinx2, 1in1l, viny2; e1tern int •111, Yv12, YVJl, •112; char ch3; setscreen(); ldorg(org1,orgy,orgz); if(cnt3::0)

{ u:O; }

if(cnt3::1) { rz:O; }

if (cnt3::2) { rz:JO; ldrotz(30); }

if ( cnt3==3) { rz=45; 1drotz(l5}; }

if(cnt3==4l { rz=60; 1drotz( 15}; }

if ( cnt3::5) { rz=90; 1drotz(30); }

if(cnt3::6) { rz=l20: 1drotz ( 30); }

if(cnt3::7) { rz=l35; 1drotz(l5}; }

if(cnt3::8) { rz=150; 1drotz(l5); }

if(cnt3::9) { rz=180; 1drotz(30); }

if(cnt3==10) { n=210; 1drotz(30}; }

if ( cnt3::11) { n:225; 1drotz( 15); }

214

if(cnt3::12) { rz:240; 1drotz( 15); }

if(cnt3==13) { rz:270; 1drotz(30); }

if ( cnt3::14 l { rz:300; 1drotz( 30); }

if(cnt3::15) { rz=315; 1drotz(l 5); }

if(cnt3::16) { rz:330; 1drotz(15); }

if(cnt3::17) { rz:O; 1drotz(30); }

setscreen(); VNPORT(0,639,0,479); 1indo1(0.0 , 639.0, 0.0, 479.0); }

/UtUUUUU/

215

rcursz2(cnt3) int cnt3; { extern int 1do1,rz;

216

extern double 1,1,z,org1,org1,orgz,1in1l, 1in12, 1in1l, 1in12; extern int Y11l, y112, YIJl, v112; char ch3; setscreen(); 1dorg(org1,org1,orgz); if(cnt3::0)

{ rz:O; }

if(cnt3::1) f n:O: tdrnhl-301: )

iffr.nt.3::?.\ (

r7.:30: •drnhl-15\: l

iffr.nt3::3l (

n:45: •drnbl-15\: l

iflcnt3::4l (

ri:RR: idrotzl-301: }

if(cnt3::5) { n:90; 1drotz(-30l: l

iff cnt3::61 f n=l20; ldrot&(-15); }

if(cnt3::7) { n:l35; adroh(-15); }

if(cnt3::8) { rz=150; idrotz(-30); }

if{cnt3::9) { rz=180; idrotz(-30); }

if(cnt3::10) { rz=210; idrotz(-15); }

if(cntJ::ll) { rz=225; idrotz(-15);

} if(cnt3::12)

{ rz:240; idrotz(-30); }

if(cnt3::13) { rz=270; idrotz(-30); l

if( cnt3::14) ( rz:300: 1drotz( -15); )

if( cnt3::15 l { rz:315; adrotz(-15); l

iflcnt3::161 { n:330; idrotzl-30); l

iflcnt3::17l f n:O: l

217

setscreen(); VVPORT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); }

'**************! rzdisp() { cl beg( 253); linfun(2);

VVPORT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0);

TSIZl(lO.OJ; TJUST(l,1); !OVl(l.0, 468.0); COLOR(32); text(" Z "); !OVIR(35.0, 0.0); color(96); text(" 0"); !OVIR(35.0, 0.0); color(224); text(" 30"); !OVIR(35.0, 0.0); color(218); text(" 45"); !OVIR(35.0, 0.0); color(224); text(" 60 "); !OVIR(35.0, 0.0); COLOR(96J; text(" 90"); color( 224); !OVIR(35.0, 0.0); text("120"); !OVIR(35.0, 0.0); color(218); text("135"); color< 224); !OVIR(35.0, 0.0); text("150"); !OVIR(35.0, 0.0); color(96); text("180"); !OVIR(35.0, 0.0); color(224); text("210");

218

MOVEB(35.0, 0.0); color(218J; teit("225"); color(224); MOVIR(35.0, 0.0); textf "240"); MOVIR(35.0, 0.0); color(96); text(· 270"); MOVIR(35.0, 0.0); color(224); text("300"); MOVIR(35.0, 0.0); color( 218); teit("315"); MOYIB(35.0, 0.0); color( 224); text( ·330·); color(96); MOVIR(35.0, 0.0); text( "IIIT"l; cl end(); clrun(253); }

IUUUUUU/ 1roti2( cnt3) int cnt3; { extern int rz,rcntz,vdo1; extern double 1inxl, vinx2, 1inJl, 1in12; extern double Y11l, Y112, YIJl, y1y2; char ch3; int nd; cl run( 253); if(cnt3::0)

{ entenah();

} if(cnt3::1)

{ n:O; rcntz:O; }

if(cnt3::2) { n:30; }

219

if(cntJ::J) { rz:4S ; }

if(cnt3::4) { rz=60 ; }

if(cnt3==5) { rz:90 ; }

if(cnt3::6J { rz=l20 ; }

if(cntJ::7) { rz:135 ; }

if(cntJ::8) { rz:ISO ; }

if(cnt3::9) { rz:180 : }

if(cnt3==10) { rz:210 ; }

if( cnt3==11) { rz:225 ; }

if(cnt3==12) { rz:240 ; }

if(cnt3==13) { rz=270 ; }

if ( cnt3::14) { n:300 ; }

220

if(cnt3::15) { rz:315 ; }

if(cnt3::16) { rz=330 ; }

setscreen(); printf("\ncount => Sd",cnt3); }

/UUUUUUU/ entenah() {

221

e1tern int rzt,rcntz, '111, '112, ,,,1, ,,,2, 1do1,rz,r12; int rzd; e1tern double or11,org1,org1,1in1l, 1in12, 1in1l, 1in12,1,1,z; FILI •cl; setscreen(); if(rz!:O)

{ rzd:360-n; ldrotz(rzd); }

printf("\nllTIR Z ROTATIOI"); 1bile(scanf("Sd",ar1) !=ll

{ printf("PLIASI OSI IOBIRIC IIPOT; TRY AGAil.\n"); scanf("Sts"); }

1bile(1etcbar()!:'\n'); if(n>360)

n:O; if(n::360)

n:O; if(rzt >360)

{ rzt:rzt-360; }

if(rz::OJ rcntz:O;

ldorg(org1,or11,or1zJ; adrot&(rz); rzt:rzt+rz;

rz2:rz; setscreen(); } , .............. ,

222

!•THIS SKT or fONCTIONS DIAL MITH SOLID MINO ACKSS AND DISPLAY */

linclude "std.h" linclude <fcntl.h> linclude <sys\types.h> linclude <srs\stat.h> tinclude <io.h> linclude <stdio.h> I define COMMAND "ssolid.bak" I define COMMENT • • I define LIM 40 I define LARROW 75 I define RARROM 77

!••••••••••*********/ /UUUUUUU/

pri1itife() { extern int vdov; extern int rv1l, rv12, rvyl, rvy2; extern double vin1l, vin12, vinyl, viny2; char chJ; int cnt3; cnt3:0; pri1disp(); 1ore(T5.0, 463.0); color(32); rectr(50.0, 15.0); ch3:getche(); vhile(ch3 !: '11')

{ svitch(ch3J

{ case 'b': cat3:0;

goto out; case 'c': cnt3:1;

goto out; case 't': cnt3:2;

goto out; case ·s·: cnt3:3;

goto out; case ·v·: cnt3:4;

goto out; case 'p': cnt3:5;

goto out; case 'r': cnt3:6;

goto out;

}

case ·,·: cnt3:9; goto out;

case "e': cnt3:7; goto out;

case ·1·: cnt3=8; goto out;

case 1 : goto oat;

case · ': goto out; case T: linfua(2);

color(32); rectr(50.0, 15.0); IOYer(50.0,Q.0); rectr(50.0, 15.0); cntl++; if(cnt3>10)

{ rectr(50.0, 15.0); 10fe(75.0, 463.0); rectr(50.0, 15.0); cnt3:0; }

break; case ·4· : linfun(2);

color(32); rectr(50.0, 15.0); IOter(-50.0, 0.0); rectr(50.0, 15.0); cat3--;

default: ; }

if(c1tl<O) { rectr(50.0, 15.0); IOYe(STS.O, 463.0J; rectr(SO.O, 15.0); c1t3:10; }

break;

printf("coant:: Xd\n" ,cntl); ch3:getche();

oat: pri1itiYe2(cnt3); }

1 •••••••••••••• ,

223

pri1disp() { clbeg(2S3); linfun(2); VWPORT(0,639,0,479); ;indo;(O.O , 639.0, 0.0, 419.0); TSIZI( 10. 0); TJUST(l, 1); !OVl(S.O, 465.0); COLOR( 32); text( "SOLIDS"); !OVIR(75.0, 0.0); COLOR( 255); text( "BLOC"); !OVIR(50.0, 0.0); text( "COL!"); !OViR(50.0, 0.0); COLOR(2S5); text("TUBI • ) ; !OViR(50.0, 0.0); text("SPBR • l; !OVIR(50.0, 0.0); text( ·noo· J; !0Vii(50.0, 0.0); tut( ·pny· J; !OVIR(50.0, 0.0); text("RIBG"); !OVIR(50.0, 0.0); text( ·1nr l; !OVIR(S0.0, 0.0); tut( "LATH"); !OVIR(SO.O, 0.0); tut( "!UTI") i COLOR(32); !OflR(50.0, 0.0); text( ·111r· l; COLOR(255); clend(); clrun(253); }

/tttttttttttttt/

224

priliti,e2(cnt3) int cnt3; { extern int wdow,curs; extern int Y1xl, Y1x2, YiFl, ,,,z; extern double 1inxl, 1in12, 1in1l, 1in12; char cb3; extern int exton; eiton :O; rectr(50.0, 15.0); clrun(253); if(cnt3::0)

{ pblock(); }

if ( cnt3::1) { pc1linder(); }

if(cnt3::2) { ptube(); }

if( cnt3::3) { psphere(); }

if(cnt3::4) { p1edge(); }

if(cnt3::5) { pcone(); }

if(cnt3::6) { ptorus(); }

if(cnt3::7) { curs:8; ICODSbade(); exton:l; SSleDll(); }

225

if(cnt3::8) { curs:8; ICODshade(); exton:O; ss1enu(); }

if(cnt3::9) { curs:9; HnJ(); }

if(11do11::0) { 11indo11(1in1l, 1in12, 1in1l, 1in12); VWPORT(v11l, v112, v11l, v1112); }

if(1do11::l) { 11indo1(-640.0, 640.0, -479.0, 479.0); v1port(O, 319, 0, 239); }

printf("\nlIIT SOILIDS KllO count=> ld",cnt3); }

f Sttttlttllltllll/

,, ................... , pcJ Under( ) { extern int curs; curs=2; printf("\n CORSOR IS A CYLIIDIR Id ",curs); } , ............... ,

HDJ() { extern int curs; curs:8; printf("\n CORSOR IS COKPOSITI Sd ",curs); }

226

, ................ , ptube() { extern int curs; curs:J; printf("\n CORSOR IS A TOBI ld ",curs); }

/J***************/ psphere() { extern int curs; curs:4; printf("\n CORSOR IS A SPBIRI ld ",curs); }

.f S***************I pblock( l { extern int curs; curs:l; printf("\n CORSOR IS A BLOCI ld ",curs); }

/Jlllt••••••••••/ ptorus() { extern int curs; curs:5; printf("\n CORSOR IS A TOUROS ld ",curs); }

/s••*************I pcone() { extern int curs; curs:6; printf("\n CORSOR IS A COii ld ·,curs); }

~····•*********/ p1edge() { extern int curs; curs:7; printf("\n CORSOR IS A MIDGI ld ",curs); }

·f*******************I

227

!•••••••••••••••! ssaenu() { e1tern int e1ton,vdov; e1tern int Yv1l, f&12, f&Jl, f&J2; e1tern double vin1l, vin12, vinyl, viny2; char ch3; int cnt3; cnt3:0; ssdisp(); 10Ye(lOO.O, 463.0); color(32); rectr(l00.0, 15.0); ch3:getche(); vhile(ch3 !: 'n')

{ s1itch(ch3)

{

case · r · : en t3: 0; goto out;

case ·c·: cnt3:1; goto out;

case· ·: goto out; case T

linfun(2); color(32); rectr(lOO.O, 15.0); 10fer(lOO.O,O.O); rectr(lOO.O, 15.0); cnt3++; if(cnt3>2)

{ rectr(lOO.O, 15.0); IOfe(lOO.O, 463.0); rectr(lOO.O, 15.0); cnt3:0; }

break; case T:

linfun(2); color( 32); rectr(lOO.O, 15.0); IOfer(-100.0, 0.0); rectr(l00.0, 15.0); cnt3--;

228

defaalt: ; }

if(cntJ<D)

{ rectr(lOO.O, 15.0); 1ore(JOO.O, 463.0); rectr(lOO.O, 15.0); cnt3=2; }

break;

printf("count:: id\n" ,cntJ); chJ:getche();

} out: ss1enu2(cnt3); }

/UUUUUUU/ ssdisp() { cl beg( 253); linfun(2); VMPORT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); TSIZl(l0.0); TJUST(l, 1); !OYl(5.0, 465.0); COLOR(32); text( "LATH"); !OVIR(l00.0, 0.0); COL0i(255); text(" RICIIU"); !OVIR(S0.0, 0.0); text(" "); !OVIR(S0.0, 0.0); COLOR( 255 l; text( "CRIATI • ) ; COLOR(32); !OVli(lDD.O, 0.0); textl"IIIT"); COLOR I 255 l; cl end(); clrun(253); }

/UUUUUUU/

229

ss1enu2(cnt3) int cnt3; { extern int exton,adoa,curs; extern int firstcall,,vxl, 'vx2, YiJl, YVJ2; extern double ainxl, ain12, vinyl, viny2; char ch3; rectr(lOO.O, 15.0); clrun{253); if(adoa::O)

{ vindoa(vin1l, vinx2, vinyl, viny2); VWPORT(,ill, YVl2, YiJl, Yiy2); }

if(adov::l) { vindoa(-640.0, 640.0, -479.0, 479.0); 'vport(O, 319, 0, 239); }

if(cnt3::0) {

firstcall=O; recissol();

} if(cnt3::1)

{ IOYeline(); cars:8; dispi(O);

}

printf(.\nllIT SSOILIDS KIMO count:> sd·,cnt3); }

/***************/

230

/***************! eil()

e1tern int e1ton,1dov; e1tern int Yv1l, Ya12, YiJl, YiJ2; e1tern double vinxl, vin12, vinyl, viny2; char ch3; int cnt3; cnt3=0; Yievdisp(); IOYe(50.0, 463.0); color( 32); rectr(lOO.O, 15.0); ch3:getche(); vhile(ch3 !: 'n')

{ sii tch( ch3)

{

case ·x·: cntJ:l; goto out;

case ·,·: cnt3:0; goto out;

case "z": cnt3:2; goto out;

case 'd': cnt3:3; goto out;

case ·,·: cnt3:4; goto out;

case ·e·: cnt3:6; goto out;

case ·v·: cnt3=5; goto out;

case ·:goto out; case '6"

linfun( 2); color(32); rectr(lOO.O, 15.0); IOYer(l00.0,0.0); rectr(lOO.O, 15.0); cnt3++;

231

if(cnt3>5) { rectr(lOO.O, 15.0); 10Ye(SO.O, 463.0); rectr(lOO.O, 15.0); cnt3:0; }

break; case '4':

default: }

linfun(2); color(32); rectr(lOO.O, 15.0); aoYer(-100.0, 0.0); rectr(lOO.O, 15.0J; cntl--; if(cnt3<0)

{ rectr(lOO.O, 15.0); IOfe(550.0, 463.Q); rec tr (100. 0, 15. 0); cnt3:5; }

break;

printf("count:: ld\n",cnt3); chl=getcbe();

} out: Yeiva2(cnt3); }

·h*************I

232

Yievdisp() { cl beg( 253); linfun( 2); VMPOBT(0,639,0,479); vindov(O.O , 639.0, 0.0, 479.0); TSIZl(l0.0); TJOST(l, 1 l; ft0Yl(5.0, 465.0); COLOR(32); text( ·vnw • l; ft0VIR(50.0, 0.0); COLOR( 255); text("ROTATI "); COLOR( 32); text(" Y");

ftOVIR(lOO.O, 0.0); COLOB(255);

text("ROTATI "); COLOR(32); text(" I"); ftOVIR(lOO.O, 0.0);

COLOR!255); text!"ROTATI "); COLOB(32); text(" Z"); ftOYIR(lOO.O, 0.0);

COLOR(255); text(" ISTAICI"); COLOB(32); text("D "); COLOB(255); ftOVIR(lOO.O, 0.0); tut(. IIV PT");

COLOR(32); text("i "); ftOYIR(lOO.O, 0.0); COLOR(255); tut(· "); tut(• IRDOV" l; COLOR(32J; text("W "); COLOR( 255); cl end(); clrun(253); } ,,,,,,,,,,,,,,,,,

233

HiH2(cnt3) int cnt3; { e1tern int e1ton,vdo1,curs; e1tern int firstcall,Yv1l, •112, •vyl, Yvy2; e1tern double 1in1l, 1in12, vinyl, viny2; char ch3; rectr{l00.0, 15.0); clrun(253); if(1do1::0)

{ 1indo1{vin1l, 1in12, vinyl, viny2); YMPORT(•11l, yv12, tvyl, Yvy2); }

if(vdov==ll { vindov(-840.0, 640.0, -479.0, 479.0); tvport(O, 319, 0, 239); }

if(cnt3::1) { CHI{); }

if (cntl::O) { cHy(); }

if(cnt3::2) { CHI(); }

if (cnt3::3) {

cdistan(); }

if (cnt3==4l { ctrpt(); }

if(cnt3::5) { c1indo1(); }

if(cnt3::6) {

1aindisp(); }

} ,, ............... ,

234

1••·············1 ll'indoH( l { extern int exton,wdow; extern int •wxl, •wx2, fWJl, •w12; extern double winxl, win12, winyl, viny2; char ch3; int cnt3; cnt3:0; windowdisp(); ao•e(lOO.O, 463.0); color(32); rectr(l00.0, 15.0); ch3:getche(); while(ch3 !: 'n')

{ svitch(ch3)

{

case·,·: cnt3:0; goto oat;

case 'p': cnt3:1; goto oat;

case ·e·: cnt3:2; roto oat;

case ·,·: cnt3:3; goto oat;

case ·o·: cnt3:6;

case

case T

goto oat;

goto oat;

linfan(2); color(32); rectr(l00.0, 15.0); ao•er(l00.0,0.0); rectr(l00.0, 15.0); cnt3++; if(cnt3>3)

{ rectr(lOO.O, 15.0); 1o•e(lOO.O, 463.0); rectr(lOO.O, 15.0); cnt3=0; }

break;

235

case T:

default: }

linfun( 2); color(32); rectr(l00.0, 15.0); 10Yer(-lOO.O, 0.0); rectr(lOO.O, 15.0); cnt3--; if(cnt3<0)

{ rectr(lOO.O, 15.0); IOfe(400.Q, 463.0); rectr(l00.0, 15.0); cnt3:3; }

break;

printf("count:: ld\n" ,cnt3); cb3:getcbe();

} out: vindo112(cnt3); }

/USUUUUUU/

236

11indo11disp() { clbeg(253); linfun(2); 9VPORT(0,639,0,479); 11indo11(0.0 , 639.0, 0.0, 479.0J; TSUl(lO.OJ; TJOST(l,1); M091(5.0, 465.0l: COLOR/321: te1tl 0 VIMDOV "l: MOYJRl100 0. O.Ol: COi.ORi ?.5~ l: t.P.rt.I" TUI "l: r.nr.ORI ~?.\: t:1>1trr1:

MOVJR11nn o. n.nl: COi.ORi ?.5~ l:

t.P.1t:l 0 l.U "l: r.01.n~11?1:

te1t! 0 P"l: BOVIR(lOO.O, 0.0); COL0i(255);

text(" LIVATIOR "); COLOR(32); text("I "); BOVIR(lOO.O, 0.0); COL0i(255);

text(" OLTI • l; COL0i(32J; text("! "); COLOR(2SSJ; BOVIR(lOO.O, 0.0); text(" ");

COLOR(32); text(" "); BOYIB(lOO.O, 0.0); COLOR(255); text(" "); text(··); COLOR(32J; text(" "); COLOR ( 255) ; clend(); clran(253); }

!••••••••••••••••!

237

llindo1112 ( cntJ) int cntJ; { extern int 1do1,planon,exton,1do1,curs; extern int firstcall,,111, Y112, YIJl, f1J2; extern double zoo1Yal, 1in1l, 1in12, 1inJl, 1inJ2; char chJ; rectr(lOO.O, 15.0); clrun(253); if (1do1::0)

{ 1indo1(1in1l, 1in12, 1inJl, 1inJ2); JMPOIT(illl, Yll2, ilJl, 'IJ2); }

if(1do1::l) { 1indo1(-640.0, 640.0, -479.0, 479.0); '1port(O, 319, 0, 239); }

if(cntJ::l) { 1in1l: -284.0•1001Yal;

} if(cntl::O)

{

1in12: 284.0•1001Yal; tinJl:-213.011001ial; 1inJ2=213.0•1001,al; 1do1:0; ''port(Ytll, Yll2, YIJl, YIJ2); 1indo1(1in1l, 1in12, 1inJl, 1inJ2); planon:l;

cplan();

1in1l: -284.0•1001,al; 1in12: 284.0•1001Yal; 1inJl:-213.011001fal; 1inJ2=213.0•1001,al; ilport(flll, Yll2, YIJl, YIJ2); 1indo1(1in1l, 1i112, 1inJl, 1inJ2); 1do1:0; planon:O; 1etfile();

238

if (cut3::2) { 1in1l: -284.0•zooatal;

} if(cnt3::3)

{

if ( cnt3::4) { }

if(cnt3::5) { }

if ( cnt3==6 l {

1aindisp(); }

1in12: 284.0•zooital; 1in11=-213.0•zoo1tal; 1in12=213.0•zoo1tal; t1port(t11l, t112, t1Jl, t1J2); 1indo1(1in1l, 1in12, 1inJl, 1inJ2); 1do1:0; planon:2; celent( l;

1in1l: -213.0•zooatal; 1in12: 213.0•zooital; 1in11=-213.0•zoo1tal; 1in12=213.0•zoo1tal; 1do1 =l; getf ile( l;

printf("\nllIT Yili KllO count=> Id" ,cnt3); }

h•••••••••••••••!

239

/***************/ le1()

extern int e1ton,vdov; extern int rv1l, rv12, •v1l, vv12; extern double vin1l, vin12, vin1l, vin12; char ch3; int cnt3; cnt3=0; f iledisp(); IOYe(lOO.O, 463.0); color(32); rectr(lOO.O, 15.0); cb3:getcbe(); vbile(cb3 !: ·n·)

( svitcb(cb3)

{

case ·r·: cnt3:0; goto out;

case ·s·: cnt3=1; goto out;

case ·e·: cnt3:2; goto out;

case ···: cnt3:3; eoto out;

case ·o·: cnt3:6;

case

case T

goto out;

goto out;

11Dfun(2); color(32); rectr(lOO.O, 15.0); IOYer(l00.0,0.0); rectr(lOO.O, 15.0); cnt3tt; if ( cnt3> 1)

{ rectr(l00.0, 15.0); IOYe(lOO.O, 463.0); rectr(l00.0, 15.0); cat3:0; }

break;

240

case · 4 ·:

default: ; }

linfuo( 2); color(32); rectr(lOO.O, 15.0); soYer(-100.0, 0.0); rectr(lOO.O, 15.0); cnt3--; if(cnt3<0)

{ rectr(lOO.O, 15.0J; IOYe(200.0, 463.Q); rectr(lOO.O, 15.0); cnt3:1; }

break;

printf("count:: ld\n",cnt3); ch3:getche();

} out: filea2( cnt3); }

f.UUUUUUU/

241

filedisp{) { clbeg(253); linfun( 2); VVPORT(0,639,0,479); window(O.O , 639.0, 0.0, 479.0); TSIZl(l0.0); TJOST(l,l); !OYl(5.0, 465.0); COLORl32); text( "rILIS • ) ; !OVIR(l00.0, 0.0); COLOR(255); text(. ICIIVI"); COLOR(32); text("R");

!OYIR(100.0, 0.0); COLOR(255);

text(" IMD • l; COLOR(32J; text("S"); KOYIR(lOO.O, 0.0);

COLOR( 255); teit(" "); COLOR(32); text(" "); !OYIR(lOO.O, 0.0);

COLOR( 255); text(" ·); COLOR(32); teit(" "); COLOR(255); !OYIR(lOO.O, 0.0); teit(" ");

COLOR(32); teit(" "); KOYIR(l00.0, 0.0); COLOR(255); text(" "); text(""); COLOR(32); text(· "); COLOR( 255); clend(); clrun(253); }

/UUUUUUU/

242

file12(cnt3) int cnt3; { extern int wdov,planon.e1ton,vdow,curs; extern int firstcall,vv1l, vv12, vvyl, vvy2; extern doGble zoo1val, vin1l, winx2, vinyl, viny2; char ch3; rectr(lOO.O, 15.0); cl run( 253); if(vdov::O)

{ vindov(vinxl, vin12, vinyl, viny2); VNPORT(vvxl, vvx2, fvyl, vvy2); }

if(vdov::l) { windov(-640.0, 640.0, -479.0, 479.0); nport(O, 319, 0, 239); }

if(cnt3::0) { recifile();

} if(cnt3==1)

{ sendfile(); 1aindisp(); }

if( cnt3::6) {

1aindisp(); }

243

printf("\nlIIT file (sol1.c) BllO coGnt => ld",cnt3); }

'***************/

'******************/ 1 cdistanll

{ extern double returnYal; double nu1; static char string10; extern double dist; printf("\nGIYI DISTANCI :"); tets( strinrl: orintfl" sl: ls",strinrl:

vhil~ls~~nfl"ld".~nn1l 1:11 (

244

printf("PLIASI OSI MOKIRIC INPUT; TRY AGAIM.\n"); scanf("Us");

*I

} vbile(getcbar()!:'\n');

strtoflt(strinr);

dist:returnnl; printf("\nthis is the Distance=> t.lf",dist); if(dist<450.0)

dist:450.0; cleari(O); clears(O); 11isend(); 1diden(); setupf(); distan( dist); getf ile(); }

4********************/

cvindov() {

245

extern double zoo1tal,returntal, vin1l, vin12, vinyl, 1in12; extern int planon; char string10; double nu1;

printf("\n KITIR ZOOK VALUE "); gets(string); I• vhile(scanf("U",hua) !:l)

{ printf("PLKASK OSI BOKKRIC IBPOT; TRY AGAIR.\n"); scanf("Us"); }

vhile(getchar()!:·\n'); a/ printf("string:ls ·,string); strtoflt(string); 1001tal:returnYal; printf("ZOOKVAL l.2f Il:l.2f,I2:l.2f,Yl:l.2f,Y2=l.2f,", zoo1tal,1in1l,vin12,vinJl,vinJ2); vin1l•= zooanl; viu2•= zooanl; vinyU: ZOOHal; vin12•=zoo1nl; setupf();

if(planon::OJ getfile(); if(planon::l) cplan();

if(planon==2l celevat();

}

t•••···············••/

'**************************! CHI() { extern int v111 ; int angle;

printf("\nVHAT ANGLE TO ROTATK OM 'I' ?"); abile(scanf("ld",langle) !=1)

{

246

printf("PLIASI OSI KUBIRIC IKPOT; TRY AGAIK.\n"J; scanf("lts"); }

abile(getchar()!:'\n'); if (angle>=360)

angle:O; n1:angle; setupf(); getf ile(); }

"*************************/ cny() { extern int ny; iat angle; printf("\nVHAT AIGLI TO ROTATK 01 ·y· ?"); ahile(scanf("ld",langle) !:l)

{ printf("PLIASI OSI IOBIRIC IMPOT; TRY AGAIK.\n"); scanf ("lts"); }

abile(getchar()!:'\n'); if(angle>:360)

angle=O; ny:angle; setup! (); getf ile( l; }

~··••ttttttttttttttttttttt/

r.vv7.I l {

extern int nz: int angle: printf("\nNHAT AMGLK TO ROTATI OM ·z· ?"l:

while( scanf ( "%d" ,hnde l ! :1 l {

247

printf("PLKASI OSI MU!KRIC IKPUT; TRY AGAil.\n"J; scanf (·xis·); }

vhile(getchar()!:'\n'); if(angle>=360)

angle:O;

nz:ande: setupf ( l; getf ile( l;

248

I* THISI roMCTIOMS ARI ASSSOCIATID MITH THI LOADID CO!!AMD LIST CO!!AMD •I I* TBIJ ALLON TRI DSIR TO LOAD A JILi AMD fIIM [T JRO! THI CLRDM CO!!AMD•/

linclude "std.h" linclude <fcntl.h> linclude <sys\types.h> linclude <sys\stat.h> linclude <io.h> linclude <stdio.h> linclude "keys.h" , ................ , vievrot() {

I* SIT SILICTABLI fIIVIMG TRAMSJORBATIOMS TO TRI ADDID COBBAMD LIST */

extern double f1ptx,v1pty,,1ptz; extern int t1v,tess,,1x,,1y,v1z,proj; extern double disy,dist,dish.speed,lt1,lty,ltz; int ch2; extern int shade ; liafun(O); shade :O; cb2:getche( l; vhile(cb2 !: ISC)

{ svitcb(cb2)

{ case LS: lighting();

break; /t SITS LIGBTIKG "BOGS" *I

case JS: ltx:O.O; /t SITS LIGBTIMG "BOGS" *I lt1=1.0; ltz:l.O; tn:O; setapnrs(); if(sbade::l)

dispat(0,1); clrun(2); break;

249

case is: lt1:0.0; /* SITS LIGHTING "BOGS" */ lt1:0.0; ltz:l.0; tn:O; setupnrs(); if(shade::l)

dispat(O,l); clrun(2); break;

case FS: entess(); /* BRAICHIS TO FACITIKG COKKAKDS */ break;

case &STRII: /* RISITS YIIMIIG K&TRII *I n1:0; n1:0; nz:O;

setnpnrs(); if (shade::l)

dispat(0, 1); clrun(2); break;

case rs: dis1t:speed; tn:O; setupnrs(); if(shade::l)

dispat(0,1); clrun(2); break;

case F6: dis1-:speed; tn:O; setupnrs(); if(shade::l)

dispat(D,1); cl run( 2); break;

case F9: dish+:speed; tn:O;

setupnrs( l; if(shade::ll

dispat(0,1); clrun(2); break;

I* SITS TOI CLIPPING PLAKI */

I* SITS TOI CLIPPIIG PLAKI t/

I* SITS BITHIR CLIPPIIG PL&IE */

case r10: dish-:speed; tn:O;

setupurs(); if(shade::l)

dispat(0,1); clrun(2); break;

case f7: distt:speed; tn:O;

setupurs(); if(shade::l)

dispat(0,1); clrun(2); break;

case f8: dist-:speed;

setupnrs(); if(shade::l)

dispat(O,l); clrun(2l: break;

case PLDS: speed+:20.0;

break; case ~IIDS: speed-:20.0;

break;

case LARR: Yvptz-:speed; tn:O;

setupnrs(); clrun(2); break;

case RARR: Yvptz+:speed; tn:O;

setupnrs(); clrun(2); break;

case DP: •vpt1+=speed; tn:O;

setupnrs(); clrun( 2); break;

250

I* SITS BITBIR CLIPPING PLANK •/

I* SITS iIIWIMG DISTANCI t/

I* SITS iIIWING DISTAMCI */

I* SITS GRID SPACING DISTAMCI *I

I* SITS GRID SPACING DISTAMCI *I

I* SITS iIIWIMG RlflRllCI POINT I•/

/t SITS iIIWING RIFIRINCI POIIT I*/

I* SITS iIIMIIG RlflRINC POINT Y•/

case DONN: fvpty-:speed; tn:O;

setupnrs(); clruo(2); break;

case INS: Yvptzt:speed; t11y:Q;

setupnrs(); clrun(2); break;

case DIL: Yllptz-:speed; tn:O;

setupnrs(); clruo(2); break;

case Sii :y11yt:30; tn:O;

setupnrs(); clruo(Z); break;

case rooa :yuy-:30; tn:O;

setupnrs(); clrun(2); break;

case KIGHT :tai-:30;

case TWO :

tn:O; setupnrs(); clrun(2); breai;

tn:O; n1t:30; setupnrs(); clrun(2); breai;

case ZKRO :

tn:O; Yu-:30; setupnrs(); clrun(2); break;

251

I* SITS YIIMING RIFIRIKC POIKT Y•/

I* SITS VIINIMG RIFIRINC POINT Z•/

I* SITS VIINIIG RlrlRllC POIKT Zl/

I* SITS VIIMIKG RIFKRKICI ANGLK Y •/

I* SITS VIKNIKG RlrKRIKCI AKGLK Y */

/t SITS YIIMIIG RIFIRllCI AIGLI I •/

I* SITS VIIWIIG RIFIRIKCI ANGLI I */

/t SITS VIINIKG RIFIRllCI AKGLX Z */

/t SITS VIINIIG RKflRllCI AIGLI Z l/

case PlilOD :

case SS :

tn:O; nz+:JO; setupnrs(); clrun(Z); break;

tn:O; setupnrs(); dispat(O,l); clrun(2);

shade:l; dispi(O); breai;

case NS : dispat(2,l); shade:O; break;

case IS : clrun(251); ie1loop(); breai;

case IS:

default: ; }

if(shade::l) dispi( 0);

tnis(l);

tn:O; HJ+:90; Hz:O; nx:O; setupnrs(); projct( 0); clrua(2); breai;

252

!• SITS SHADING 01 •/

I• SITS NIRlfR&!I OK •/

!• llTIRS IMTO !&II llYBOSBD LOOP •/

I• DISPLAYS ILIY&TIOM YIINS •/

priatf("\a DIST: S.lf, YOI: S.lf, HITlll: S.lf",dist,dis1,dish); Priatf("\a SPllD : S.lf, I: S.lf, Y: S.lf, Z: S.lf",speed,,1pt1,f1pt1,,1ptz);

ch2:getche(); }

253

entess() I* SIT r&CITIMG AMGLI •/

extern int tess; extern int faceton; extern int shade; int ch; shade:l; ch:getche();

svitch(ch) { case PLOS:faceton:l;

break;

case !1105: faceton:O; break;

case ZIRO: tess:O; setupnrs(); if(shade::l)

dispat(O,l); clrun(2);

break; case 011: tess:l;

setupnrs(); if(shade::l)

dispat(O,l); clrun(2);

break; case TWO: tess:2;

setupnrs(); if(shade::l)

dhpat(0,1); clrun(2);

break; case TBRll: tess:3;

setu11nrs( l: if(shade::l)

dispat(O,l); clrun(2);

break; case fOOR: tess=4;

setupnrs(); if(shade::l)

dispat( 0, 1); clrun(2);

break;

case FIYI: tess:5; setupvars();

if(sbade::l) dispat(O,l);

clrun(2); break;

case Sii: tess:6; setupnrs();

if(sbade::l) dispat(0,1);

clrun(2); break;

case SIYll: tess:7; setupnrs();

if(sbade::l) dispat(O,l);

clrun(2J; break;

default: ;

254

255

lighting() {

I* SIT LIGHTING ANGLE */

eitern int tn; extern double speed,ltx,lty,ltz; extern int shade; int ch; printf("\n llTKR KMTIR LIGHTIIG YALUKS : "); shade:l; ch:getche(); 11hile(ch !: KSC)

{

svitch(ch) { case IS: ltx*=-1; I* SKTS YIKWIIG BKfKBllCI POINT I*/

tn:O; setupnrs();

dispat(0,1); cl run( 2); break;

case TS: ltyt:-1; /S SITS YIKWIRG ilrKRllCI POIIT I•/ tn:O;

setupnrs(); dispat(O,l);

clrun(2); break;

case ZS: ltza:-1; /* SKTS YIIMIRG RKfKBllCI POINT I*/ tn:O;

setupurs{); dispat(0,1);

clrun(2); break;

case LARR: ltx•:speed; /* SKTS YIKWIIG RKFIBKMCK POIIT I*/ tn:O;

setupurs ( ) ; disp1t(O,l);

cl run( 2); break;

I

ch:getche();

case HARR: lt1-:speed; tn:O;

setupnrs(); dispat(0.1);

clrun(2); break:

case OP: ltr-:speed: tn:O:

setupnrs( l: clrun(2): break;

case DOMM: lt1+=speed; tn:O;

setupnrs( l; clrun(2); break;

case IIS: ltz-:speed; tn:O;

setupurs(); clrun(2); break;

case OIL: ltz+:speed; tn:O;

setupurs(); clrun(2); break;

case PLOS: speed+=20.0;

break; case KIKOS: speed-:20.0;

break;

defualt: ;

} !•llD SWITCH •/ dispi(O);

tnis(l); printf("\nTIST LIGBTIIG ");

256

I* SITS VIKNIMG RlflRIMCI POINT I•/

/t SITS YIIMIKG RlflRIMC POINT Y•/

!• SITS VIINIKG RlflRIKC POINT Y•/

!• SITS VllMIMG RlflRIMC POINT Z•/

!• SITS VIIMIMG RIFIRINC POINT Z•/

/t SITS GRID SPACING DISTAKCI •/

I* SITS GRID SPACING DISTANCE •/

printf("\n SPllD : l.lf, I: l.lf, Y: l.lf, % : l.lf" ,speed,lt1,lt1,ltzJ; } /* WBILI llD •/

}/tllD•/

'·······························••/

257

/*THIS SIT or roMCTIOMS DIAL MITH SENDING AND RICIIYIMG COMMAND LISTS *I lioclude <fcotl.h> linr.ludP. <~Y~\tJDP.~.h>

lioclude <sJs\stat.h> linclude <stdio.h> linclude "std.h" linclude <striog.b> linclude <ctype.h> linclade "co11ands.h" ldefine issign(c) (((c):: ·-· :: '+') ? (1) : (0)) ldef ine YKS 1 ldef ioe MO 0 ldef ioe !AILIM 81 ldef ine NHITI 255 ldef ine LIK 40 ldefine CO!ftAMD "file.b" ldefine COftftlKT "test"

******* **********/ setapf() I* TRIS FOICTIOI CRIATXS A SXTOP COKftAID LIST */ { e1tern int '''· '''· y1z; e1tern int cl, cli, t110, t11l, tvyO, tvyl, t1eO,t1el ; e1tern int tvv, YVIl, Y112, YVJl, Yvy2, proj, ltenl, lteo2; e1tern int ltnu1, lt1a1, displ, disp2, col,raadist; e1tern doable 1,y,1, speed,dist; e1tern double a1b, lt1, lty,ltz, Yvpt1, flpty, Yvptz; e1tern doable 1ia1l,via12,viayl,vioy2,dish,disy; FILI •sl; FILI ts2; if(raadist::O)

sl : fopea("setap.d", "v"); if(raadisi==ll

sl : fopen("d:setup.d", "1"); fprintf(sl, "ca \n");

/t OPllS SITOP.D •

fprintf(sl, "clears ld \a",cl); /t CLEARS SCRIKI */ fpriatf(sl, "cleari lei \n",cliJ; /* CLIARS BorrKR */ fpriatf(sl, "tvpos lei, lei, ld, ld, lei, lei \a", t110, t11l, tvyO, tvyl, tveO, tvel);

I* SIT TIIT NIIDOW t/ fpriatf(sl,"t1Yis ld \a" ,t1Y); /*SIT TIIT WINDON VISIBLI */ fpriatf(sl,"displa 0 \a"); I* SIT TO GRAPHICS DISPLAY*/ fprintf(sl,"y1port ld, lei, ld, ld \a",y11l,Yv12,Y1yl,Y1y2); I* SIT YIIVPORT */ fprintf(sl,"1iado1 l.lf, l.lf, l.lf, l.lf \n", 1ia1l,via12,1iayl,1iny2);

fpriatf(sl, "projct ld \a" ,proj); fpriatf(st, "distan l.lf\n",dist); fprintf(sl. "disth l.lf\n" ,dish); forintf(sl. "disty l.lf\n".disrl: fprintf(sl, "cliph 1\n");

I* SIT NIIDOW */ I* SIT PROJICTIOI &MGLI */ /t SIT DIST&MCI */ /t SIT HITHIR CLIPPING•/ /t SIT YOI CLIPPING t/ /t IMABLI HITHER PLAMI t/

258

fprintf(sl, ·clipy 1\o"); /t llABLI YOM PLANK t/ fprintf(sl,"liten ld, ld \o" ,lteol,lteo2); /t INABLI LIGHT SOURCI t/ fprintf(sl, "light ld, l.2f, ld, l.lf, l.lf, l.lf\n",ltnu1, a1b, lt1a1, ltx, lty, ltz);

fprintf(sl,"dispat 0 1\n");

/t SIT LIGHT DIRICTIOM t/ /t SIT SHADING t/

fprintf(sl,"dispat 4 5\n"); /t SIT FACETING t/ fprintf(sl, "dispat 1 0\n"); /t SIT SHADING t/ fprintf(sl,"yviden\n"); /t RISIT VNINDON t/ fprintf(sl, ·,vrpt l.lf, l.lf, l.lf\n", YvptJ, Yvpty, Yvptz); /t SIT VIEN RIFKRINCI POINT*/ fprintf(sl, "yvrotx ld\n" ,Ywx); /t SIT VNIIDON ROTATIOI t/ fprintf(sl,"Yvroty ld\o" ,YiJ); fprintf(sl, "yvrotz ld\n",yvz); fpriotf(sl, "lutint 6\n"); /t SIT LUT t/ fprintf(sl,"color 224\n"); fprintf(sl,"1diden\n"J; /t RISIT KODKLIIG KATRII t/ fclose(sl); }

:t•••··································••/ :tttttt•••••••/ readflist() { extern int ra1disk; static char inputae; FILI •fl; char ct:O; displa(l);

if (ra1disk::O)

/t READS rILI LIST •/

if( ( fl : fopen("filelist.i" ,"r") ) !: IULL) if (raadisk::l)

if( { fl : fopen("d:filelist.i","r") ) !: IULL)

while (fgets( input, LIK, fl)!: KULL) {

)

printf(input); /t PRIITS STRIIG FROK FILI*/ ct++;

if(ct::25) { ct:O; printf("\n\n-------- PRISS All lKT TO COITIIU! -------\n\n"); getche(); }

fclose(fl); /t CLOSES FILI t/ }

259

-/*******************/ sendfile() /a SllD CO!!&ID.D TO JILi a/ { e1tern int itar,itarl,itar2,itar3,itar4,itar5,itar6; e1tern int ra1disk; e1tern double ftar,ftarl,ftar2,ftar3,ftar4,ftar5,ftar6; e1tern char sign; static char iaputte; rILI •f2; rILI •fl; rILI af3; char naez o; char co1110; char rsp; int du; int tester; static char filtar12; top: tester:O; printf("\nNB&T IS THI rILI MAKI TO SIMD?"); gets (nae); printf("Addr=l5u char:'lc':lld\n", /* TISTS K&!I a/

lna1e1, na1et, na1e1); if (Daiei< 97)

{ printf("\nB&D IA!I TRI AG&II ?"); strcp1(na1e,CO!!AID); tester:!; }

if (tester::!) goto top;

strcp1(filtar,na1e); if(( fl : fopen(filtar, "r")) !:IOLL) /* CBIClS fOR llISTIIG fILI */

{ fclose( f3); printf("ls IIISTS -- do 1ou vish tooter •rite { 1/n}? ",filtar); rsp:getche(); if(rsp :: .,. )

{ te1pc( filnr); goto !able; }

else goto end; }

lable: sizfnr( fil nr l: printf("\nAMY COBBllTS ABOOT TRI rILI ?"); gets(co11); printf("Addr:l5u char:·sc·=l3d\n",

lco11e, co110, co111); if (co110< 97)

{ strcprfna1e.COBBllTl: }

fl : fopen("filelist.i","a"); fprintf(fl,"Ss ·ls · \n",filYar,co11); fclose (fl l; f2: fopen(fil•ar,"v");

260

/t ADDS COBBllTS TO rILI t/

if(ra1disi::OJ /t OPIMS rILI t/ f3 : fopen("co11and.d", "r");

if ( radisi::l) f3 : fopen("d:co11and.d", "r");

while (fgets(input,LI!,f3)!:KOLL) /t NRITIS COBBAID.D TO rILI •/ { fprintf(f2. ·ss· ,input); }

fprintf(f2, "1diden\n"); /t CLOSES rILI a/ fclose( fl l; fclose(f2); end:; }

/t••···············••/ /tttSSUtStSUUUUUU/ sizfyar(filYar) /t BAllS ALL STRIIGS 12 CBARACTIRS t/ char filnrn; {

}

strcat(filYar,SPACIS); fit(filnr,12);

/t••··················••/ ·A••••••••••••••••••••••/

sendfap(input) char iaputu; { static char strlt•; char stringu; strcp1(strl,input); fit(input,6); strcp1(striug,lstrl1); toi( striu); func2C input); }

261

~****************! te1pc(fihar) I* CRIATIS A TKBPORART rILI roR COBPARIMG rILK MARKS•/ char fiharu; { char tstring2:" ·; char •token; char •token2; char rsp; rILI lf4; rILI *fl; static char frar21; static char strl11; static char *input41; f4:foDenf"filelist.i"."r"l: fl:fooP.nl"tP.10. i". "v"l: vhilP. ffeP.tslinout.LT".f4l!:NOLLl

f strcpy(strl.inputl: strcpy(ftar.filtarl; strcat(ftar,SPACIS); fit(har,12); fit( strl.12); token :strtok(strl,string2); token2 :strtok(ftar,string2); if((strc1p(token,token2) !:0))

fprintf(fl,"ls",input); printf("\nls---ls",token,token2); }

fclose( f4 l; f close( fl l: f4:fopen("filelist.i"."1"l: fl:fooenl"te10.i"."r"l: while I he ts I in out. LJR. f1l ! :Mur.r. l

forintfff4."ls".inout\: fclose!f4l: fr.losP.lf!\: l

262

/1111111111111111111/ recifile() I* RICIYIS l JILi fRO! THI DISI I/ { e1ter1 int vdov,iYar,iYarl,iYar2,iYar3,iYar4,iYar5,iYar6; e1tern int ra1disi; e1tern double fYar,fvarl,fYar2,fYar3,fYar4,fYar5,fvar6; e1tern char sign; extern double 111,z; static char input41; int rnu1; JILi 1f2; JILi •fl; JILi •fl; static char na1e12; char fiharu; r1u1:0;

if(nu1::l) goto label;

printf("\nNB&T IS TBI JILi ll!I TO BICIIYI ?"); gets ( naae) ; cleari(O); if((f3: fope1(1a1e,·r·))::IOLL)

{

}

printf("\nfILI IOT fOOID:"); fclose( f3); goto end;

f2: fopen(1a1e,·r·); label: if(rnu1::l)

f2 :fope1("co11a1d.i", ·r·); r1u1=0; if(raldisi==O)

fl: fopen("co11and.d","1"); if (raldisi::l)

fl: fopen("d:co11aad.d","1");

vhile (fgets(input,LI!,f2)!:10LL) !•THIS WOULD Bl QOICIIR If IT W&S P&SSID THROUGH II GITJILll/ { fpriatf(fl, ·is· ,input); printf("\n RICIIYIIG is· ,input); }

fclose( fl); fclose(f2); reset(); getfile(); end:; }/* end aaiD */

'*****************/ fit(string,size) char stringu; int size; { if (strlen(string) > size)

*(string t size) : '\0'; ,, ..................... , tok( s tringl l char string! u; {

char •string2 :· ,·;

263

I* SIPARATIS A STRING or MDKBIRS */

char •Yarl,•Yar2,•Yar3,•Yar4,•Yar5,•Yar6; e1tern int iYar,iYarl,iYar2,iYar3,iYar4,iYar5,iYar6; e1tern double fyar,fYarl,fYar2,fYar3,fYar4,fYar5,f9ar6; e1tern char sign; char *token; token :strtok(stringl,string2); nrl=token; coDYert(nrl); if (sign :: Tl

{ inrl=inr; }

if (sign :: T) { harl=har; }

token =strtok(KDLL,string2); nr2=token; couert( ur2); if (sign :: T)

{ har2:har; }

if (sign :: T) { har2:fnr;

} token =strtok(KDLL.string2); nr3:token: coDYert!nrll: if (sign :: Tl

{ har3=inr;

}

if (sign :: T} { fnr3:fnr;

} token :strtok(MOLL,string2); nr4=token; couert(nr4); if (sign :: 'i')

{ har3:inr;

} if (sign :: Tl

{ har4:har;

} token :strtok(MOLL,string2); nr5:toten; couert( nr5 l; if (sign :: Tl

{ inr5=inr; }

if (sign :: 'f') { har5=har; }

token :strtok(IOLL,string2); nr6:token; couert( nr6); if (sign :: 'i')

{ inr6:inr; }

if (sign :: 'f') { har6:har; }

} riununnnuunuauu/

264

linclude <1ath.h> ldefine CBHO~ 10 coDYert(nu1ber) char nu1ber21; {

265

I* SEPARATES DIGITS AND CHARACTERS */

extern int i'ar,i,arl,i,ar2,i,ar3,i,ar4,i,ar5,iYar6,,count; extern double fyar,fYarl,f,ar2,fYar3,fYar4,fyar5,fYar6; extern char sign; char ch; I* static char nu1bers1zc1111;•/ int value; double valf; int digit : Y!S; int DUI :0; &bile (( ch: nu1ber111++) != "\0" ll digit:: YIS)

if (!isdigit(ch) ll !isspace(ch)) digit :80;

if (digit :: YIS)

else

{ value: atoi(nu1ber); ivar:value; sign : T; }

{ lalf :atof{nu1ber);

har:nlf; sigu : T;

}

,/*******************/

266

/******************/ strtoflt(nu1ber) /l CHANGES A STRING TO ro&TIMG POIIT */ char nu1bert o;

{ char ch; double nlue; int digit : YKS; int count :O; static char 1inus:·-·; static char plus11:"t"; e1tern double return,al: 1hile( (ch: nu1berco11l++) !: '\0' ll digit ::YIS) if( !issign(cb) ll !isdigit(chl ll !isspace(chl l

digit : MO; if ( digit :: YIS)

{

}

printf("st3 Is", nu1ber); 'alue: atof(nu1ber); printf("final l.2f", Yalue); }

else printf{"\n MOT IOKBIR "l:

returnYal:yalue; , .................. , strtoint(nu1ber) char nuaberSJ u;

{ char ch; int nlue; int digit : TIS; int count :O; e1tern int retarnYali; 1hile( (ch : nu1berco11l++) !: '\0' ll digit ::YIS) if( !issiin(ch) ll !isdiiit(cb) ll !isspace(ch) )

diiit : 10;

if( digit :: TIS) {

}

Yalue: atoi(nu1ber); printf("\nTbe nu1ber 1as l.2f", Yalue); }

else printf("\n IOT IO!Bli ");

returnYali=Yalue;

267

/t TBISI fOHCTIOHS ARI RILATID TO CURSOR SBAPI AND fILI IHAGI t/

linclude "std.h" linclude <fcntl.h> linclude <s1s\types.h> linclude <s1s\stat.h> linclude <io.h> linclude <stdio.h> , .......................... , cursor() { e1tern int 1enur,vdo1,col,curs,planon.curson: e1tern double 1,1,z,org1,org1,org1,org1d,orgyd,orgzd; e1tern double height,1idth,length; e1ter1 int tess,9111, 9112, 91Jl, 9112; extern double 1in1t, 1in12, 1inyt, 1in12: char striagu; vindov(1in1t, 1in12, 1inyt, 1in12l; /t WIKDOW SITOP t/ if (vdov::O} Yvport(Yvxl, 9112, Y1yl, Yvy2); color(l88l; linfun(2); dispat(2,0); /t WIRIJRAKI t/ if(curs!=Ol /t TIST MO roR CROSSBAIR ONLY t/

{ I09er3(org1d,orgyd,org1d); /t TRAISLATIS JROB CINTROID t/ KOVIR3 (-(5.0), 0.0,0.0); /t DRAWS CROSS BAIR t/ DRAWR3 ((10.0),0.0,0.0); BOVIR3 (-5.0, (-5.0 ). 0.0); DRAWR3 (0.0,10.0,0.0); color( 88); BOYIR3 (0.0,-5.0,-5.0); DllWl3 (0.0,0.0,10.0); BOVl13 (0.0,0.0,-5.0); 109er3(-org1d,-orgyd,-orgzd); /t TRAISLATIS TO CllTROID t/ } color(32); linfun(2);

if (curs::O) /t TIST JOR CROSS BAIR ONLY t/ { cursO(); }

if (curs==l) f cursbloct(); /*DRAWS BLOC( t/ linfun(O); color(col); }

if (curs::2) {

268

color(32); I* SIT IOR 01 */ linfun(2); /*DRAMS COLOBI */ colu1n(O, 1idth/2.0, height); linfun(O); /*SIT RIPLACI DRAMIKG OK *I color( col) ; }

if (curs::3) { color(32); linfun(2); /* DRAMS TOBI */ tube(6,lencth/2.0,1idth/2.0, height); linfun(O); color( col); }

if (curs::4) { color(32); linfun(2); sphere(2, beicbt/2.0); /* DRAWS SPRIRI t/ linfun(O); color(col); }

if ( curs::5) { color(32); linfun(2); torus(3, length/2.0, 1idth/2.0); I* DRAWS TOROS */ linfun(O); color(col); }

if (curs::6) { color(32); linfun(2); cone(l,iidth/2.0,length, heicbt); /*DRAWS COii •/ linfun( 0); color( col); }

if (curs::T) { color(32); lillfun(2); 1edge(5, 1idth, beigbt,length); /* DRAWS NIDGI t/ linfun(O); color( col); }

if (curs::8) {

}

dispat( 4, tess l; color(32J; linfun(2); 1dorg(orgx,orgy,orgz); clrun(l); linfuo(O); color( col); dispat( 4, tess); }

269

I* DRAWS CO!!AND LIST 1 */

;'*******************! I* THKSK FUBCTIOI PIRFOR! THK SA!I FUNCTIONS AS CURSOR , BUT CHANGE TBK BACK LINKS •!

cursorpl() /* SO THI IOR !ODI WILL IOT CAUSE THI! TO DISAPPEAR */ { extern int 1do1,col,tess,curs,planon,curson; extern double x,y,z; extern double height,vidth,length; color(32); linfun(2); dispat(2,0); planon:l; if(curs::O)

{ cursO(); }

if (curs::l) { cursbloci(); linfun(O); color( col); }

if (curs::2) { dispat(4,tess); cone(l, 0.0, iidth/2.0, height); linfun{O); color( col); }

if (curs::3) { dispat(4,tess); cone(l, length/2.0, vidth/2.0, height); linfun( 0); color(col); linfun(O); color( col); )

if ( curs::4) { dispat( 4, tess); cone(l, 0.0, vidth/2.0, height); linfun(O); color( col); }

if (curs::5) { dispat( 4, tess); toras(3, length/2.0, width/2.0); linfan(O); color( col); )

if ( curs::6) { dispat(4,tess); cone(l,width/2.0,length/2.0, height); linfun(O); color( col); }

if (cars::7) { di spat( 4, tess); wedge(5, vidth, height,length); linfun(O); color(col); }

270

271

, ••••••••••••••••••• , I* THISI rDICTIOI PIRJORK THI SAKI rUKCTIOKS AS CORSOR I BOT CHANG THI BACI LINKS *I /t SO THI IOR KODI WILL NOT CAUSI THI! TO DISAPPIAR

/'UUUUtUUUUUUUUUUlU/ cursorel() { extern int 1do1,col,tess,cars,planoa,carson; extern double x,1,z,orgxd,org1d,orgzd; extern double beigbt,1idtb,lengtb; color(32); linfan(2); dispat(2,0); dispat(l,1); 10Yerl(org1d,org1d,orgzd);

BOYIRl (-(5.0), 0.0,0.0); DRAVRl ((10.0),0.0,0.0); BOYIRl (-5.0, (-5.0 ), 0.0); DRAVRl (0.0,10.0,0.0); color( 88); BOYIR3 (0.0,-5.0,-5.0);

DRAVR3 (0.0,0.0,10.0); BOYIRl (0.0,0.0,-5.0);

10Yer3(-or11d,-org1d,-orgzd);

color(32);

if (cars::l) { 10Yerl((1idtb/2.0),(-beight/2.0), (-length/2.0)); dravr3((-lidtb), 0.0, 0.0); dravr3(0.0,height, 0.0); dra1rl(1idtb,O.O,O.O); dravr3(0.0,-heicht, 0.0); 10Yerl(-1idth/2.0,height/2.0 ,length/2.0); linfan(O); color( col); }

272

if (curs==2) { ao•er3((vidth/2.0),(-height/2.0), (-length/2.0)); draar3( (-width), 0.0, 0.0); dravr3(0.0,height, 0.0); dra1r3(1idth,O.O,O.O); dra1r3(0.0,-height, 0.0); ao•er3(-vidth/2.0,height/2.0 ,length/2.0); linfun(O); color( col); }

if ( curs==3) { 10•er3((1idth/2.0),(-heicht/2.0), (-length/2.0)); dra1r3((-1idth), 0.0, 0.0); dra1r3(0.0,height, 0.0); dra1r3(1idth,O.O,O.O); draar3(0.0,-height, 0.0); 1o•er3(-1idth/2.0,heigbt/2.0 ,length/2.0); linfun(O); color(col); }

if (cors==4) { dispat(4,tess); toros(3,0.0, height/2.0); linfun(O); color( col); }

if (cors::5) { dispat(4,tess); toros(3, leagtb/2.0, vidtb/2.0); linfua(O); color( col); }

if ( cors==6) { dispat(4,tess); coae(l,1idtb/2.0,length/2.0, height); linfun(O); color( col); }

if (curs::7) { dispat(4,tess); wedge(5, width, height.length); linfun(O); color( col); }

if (curs::8) {

}

dispat( 4, tess); clrun(l); linfun( 0); color( col); } , ................................ ,

cursO( l { extern int col,curs,planon; extern double x,1,z; extern double height,1idth,length; I* KOVl3 (-(width/2.0), 0.0,0.0); DRAN3 ((width/2.0),0.0,0.0); BOVl3 (0.0, (heifht/2.0), 0.0); DRAN3 (0.0,(-(height/2.0)),0.0); KOYl3 (0.0, 0.0, length/2.0); DRAN3 (0.0, 0.0, -(length/2.0)); *I

KOYl3 (-(10.0/2.0), 0.0,0.0); DRAV3 ((10.0/2.0),0.0,0.0); BOYl3 (0.0, (10.0 /2.0), 0.0); DRAN3 (0.0,(-(10.0/2.0)),0.0); BOYl3 (0.0, 0.0, 10.0/2.0); DRAV3 (0.0, 0.0, -(10.0/2.0));

I0,83(0.0,0.0,0.0); linfun(O); color( col); }

273

I* DRAMS CURSOR t/

274

I* TBISI rONCTIOI TRAHSLATI TBI CURSOR POSITION •/

left() { extern double orgxd,orgx,orgr,orgz,x,1,1; extern double orxt,orgJt,orgzt,speed,orgspace; extern int curs,orgi,vdov,exton;

setscrn(); /*DRAMS CURSOR t/ if(org•==ll orgxd:orgxd-speed; /* TRANSLATIS KODILING ORIGIN rROK CINTROID•/

if(orgy::O) {

orgx: orgx-speed; x: x-speed; adtran(- speed, 0.0, 0.0);

}

setscrn(); } , .........................• ,

I* TRAISLATIS KODILING ORIGIN •/ /t DICRIASIS I VALOI BY GRID SIZI *I

!• DRAMS CURSOR •/

right() /* TRAISLATIS TO THI RIGHT *I { extern double orgxd, x,r,z, orgx,org1,org1 ; extern double speed; extern int exton,vdov,orc•; setscrn();

if(org•==ll orgxd:orgxdtspeed;

if(orgy::O) { orgx:ortx+speed; x: x+speed; adtran(speed, 0.0, 0.0); }

setscrn();

} , ................................ ,

up() { extern double x,1 11, org1,or11,orgz; extern double speed; extern int vdov,orgy; extern int planon; extern double orgxd,orgJd,orgzd; setscrn(); if(planon !: 1)

}

{ if(orgy::l)

org1d=org1dtspeed; if (orgy::O)

{ orn=orn•speed;

1t: speed; ldtran(0.0,speed,0.0); }

setscrn(); }

'•********************/ down() { extern double x,1 11 1 orgx,or(7,orgz; extern double speed; extern int vdov,orgy; extern int planon; extern double orgxd,org1d,orczd;

if(planon ! : 1) { setscrn(); if(orgy::l)

orc1d:or11d-speed; if (orgy::O)

{

}

or11=or11-speed; 1-: speed; adtran(O.O,-speed,0.0);

setscrn(); }

275

I* TBAHSLATIS DP */

I* TRAISLATIS DOMI */

upleft() { e1tern double 1,7,z, org1,orgy,orgz; e1tern double speed; e1tern int 1dov,org•; e1tern int planon; e1tern double org1d,orgyd,orgzd;

if(planon !: 1) {

}

setscrn(); if( org•==l)

{ orgyd:orgyd+speed; org1:org1-speed; }

if (org,::0) { if(org•==O) orgy:orgy+speed; org1:org1-speed; y+:speed; 1-:speed; tdtran(-speed, speed, 0.0); }

setscrn( l; }

·/***************'*****! upright() { e1tern double 1,1,z, org1,or(7 1orgz; e1tern double speed; e1tern int vdov,orr•: e1ter1 int planon; e1tern double or11d,or1rd.or11d;

if(planon !: ll { setscrn(); if(org•==ll

{ org1d:or11d+speed; orgyd:orgyd+speed; }

276

!• TRABSLAT!S OPL!fT */

I* TRAISLAT!S UPRIGHT •/

if(org,::0) {

orgy=orgy+speed; orgx:orgx+speed; 1+:speed; x+:speed; 1dtran(speed, speed, 0.0);

) setscrn(); )

/:UlUUUllllllllSSSSS/ do11nright() { extern double x,y,z, orgx,org1,orgz; extern double speed; extern int 11do11,org'; extern int planon; extern double orgxd,org1d,orgzd;

if(planon ! : 1) { setscrn(); if ( or(l::l l

{ orgxd:orgxd+speed; org1d=orgyd-speed; }

if(org,::0) { orgy:orgy-speed; orgx:orgx+speed; y-:speed; x+:speed; 1dtran(speed,-speed, 0.0); }

setscrn(); }

}

!••·····················••!

277

I* TRANSLATKS DOWNRIGHT *I

dovnleft() f extern double 1,y,z, orgx,orgy,orgz: extern double speed; extern int vdov,org•: extern int planon; extern double orgxd,orgyd,orgzd;

if ( p la non ! : 1 ) {

}

setscrn(); if(org,::t)

{ orgxd:orgxd-speed; orgyd:orgyd-speed; }

if(org,::0) { orgy:orgy-speed; orgx:orgx-speed; y-:speed; x-:speed; ldtran(-speed,-speed, 0.0); }

setscrn(); }

/l••··················••/ forward() { extern double x,y,z, orgx,orgy,orgz; extern double speed; extern int 1do1,org•; extern int planon; extern double orgxd,orgyd,orfzd; if(planon !: 2)

{ setscrn(); if{org•==ll

orgzd:orgzd+speed; if(org•==OJ

{ orgz:orgz+speed; z: z+speed; ldtran(O.O, 0.0,speed); }

setscrn (); }

278

I* TRAMSLATIS DOWMLIFT *I

I* TRAISLATIS FORWARD *I

, ...................... , back()

I* TR&ISL&TIS lORM&RD *I

extern double x,y,z, orfx,orgy,orgz; extern double speed; extern int vdov,orff; extern int planon; e1tern double orixd.ori1d.orizd:

ifrplanon !: 21 ( setscrn! I: if{org,::1)

orgzd:orgzd-speed; if(org,::0)

{ orgz:orfz-speed; z-:speed; 1dtran(O.Q, 0.0,-speed);

} setscrn(); l

l /**********''*''***'/

279

I* TRAISL&TIS JORM&RD *I /I TR&MSL&TIS JORM&RD *I

280

/t TBISI POMCTIOM WILL DRAW A BLOCK SO TBAT THI IOR !ODI MILL MOT IRASI BACK LIMIS */

linclude "std.h" linclude <fcntl.h> linclude <sys\types.h> linclude <s1s\stat.h> linclude <io.h> linclude <stdio.h>

''**'*******'********************/ cursbloci() { e1tern int vdo1,col,curs,planon,curson,r1,r1,rz; e1tern double 1,1,z; extern double height,vidth,length; if(planon::O)

{ bloci(4,vidth,height,lengtb); }

if(planon::1::planon::2) /t Ir BLOCI IS DRAW II PLAI OR KLIVATIOI THI BLOC( !OST Bl R KDRAWI t/ { if(((r1::0J::fr1::0))ll(rz::O)) /t If 10 AIGLK IS GIVIM *I

{ 1over3((1idth/2.0),(-height/2.0), (-length/2.0)); dravr3(0.0, (height), 0.0); dravr3((-vidth), 0.0, 0.0); dravr3(0.0,( -height),0.0); dra1r3(0.0, 0.0, length); dra1r3(1idth,O.O,O.O); dra1r3(0.0, 0.0, -length); aover3(-vidth/2.0,height/2.0 ,length/2.0);

} if(planon::l)

{ cursblocip(); /t Ir PLAI IS OM t/

} if(planon::2)

{ cursblocie(); /t Ir ILIYATIOI 01 t/ }

} /*if planon lor 2 t/ }/t1aint/

281

, ..........•............... , carsblocie() /l DRAMS BLOC( IM ILIVATIOK *I

{ extern int vdov,col,curs,planon,curson,rx,ry,rz; extern double x,y,z; extern double height,vidth,length;

if(n<90) {

1o•er3((vidth/2.0),(-height/2.0), (-length/2.0)); dravr3(0.0, (height), 0.0); IOYer3((-vidth), 0.0, 0.0); dravr3(0.0,( -height),0.0); 10Yer3((vidth), 0.0, 0.0); 10nr3((-vidth), 0.0, 0.0); dravr3(0.0, 0.0, length); 10fer3(vidth,0.0,0.0); dravr3(0.0, 0.0, -length); 10Jer3(-vidth/2.0, height/2.0, length/2.0); bloci(4,vidth,height,length);

} if(n>270)

{ IOYerl((vidth/2.0),(-height/2.0), (-length/2.0));

dravr3(0.0, 0.0, length); dravr3(0.0, (height), 0.0); IOYer3((-lidthl. 0.0, 0.0); dravr3(0.0,( -height),0.0); dravr3(0.0, 0.0, -length); IOYer3(vidth,O.O, 0.0); 10Yer3(-vidth/2.0, height/2.0, length/2.0); bloci(4,vidth,height,length);

} carsblocie2();

!•••**********************'' carsblocke2()

{ extern int vdov,col,cars,planon,curson,rx,ry,ri; extern doable 1,y,i; extern double height,vidth,length;

if ( ( n::90):: ( n::270)) { 10Yerl((1idth/2.0),(-heigbt/2.0), (-length/2.0)); dravr3(0.0,0.0,(length)); dravr3(-vidtb,O.O, 0.0);

drair3(0.0,0.0,-lengtb); drair3(iidtb,O.O, 0.0);

282

1over3(-iidtb/2.0, height/2.0, length/2.0l; block(4,width,beight,lengtb);

} if((r1>90)ll(r1<180))

{ 10•er3((vidth/2.0),(-height/2.0), (-lengtb/2.0)); dravr3(0.0, 0.0, length); 10•er3(-vidth,O.O, 0.0); drair3(0.0, 0.0, -length); 10•er3(0.0, 0.0, length); dravr3(0.0,( height),0.0); 10•er3(vidth,0.0, 0.0); dravr3(0.0,( -beight),0.0); 10•er3(0.0,0.0, -length); 10•er3(-1idth/2.0, height/2.0, length/2.0); block(4,vidth,height,lengtb); }

if(r1==180) {

}

10fer3((iidth/2.0),(-heigbt/2.0), (-lengtb/2.0)); dra&r3(0.0,( heigbt),0.0); dra&r3(-&idtb,0.0, 0.0); dra&r3(0.0,(-heigbt),0.0); dra&r3(1idth,O.O, 0.0); 10•er3(-widtb/2.0, beigbt/2.0, lengtb/2.0); block(4,&idth,height,lengtb);

if((rx>180)l&(rx<270)) {

IOfer3((iidtb/2.0),(-beight/2.0), (-lengtb/2.0)); drair3(0.0, (height), 0.0); 1o•er3((-1idth), 0.0, 0.0); dra&r3(0.0,( -beight),0.0); dra&r3(0.0, 0.0, length); 1o•er3(1idtb,O.O, 0.0); dravr3(0.0, 0.0, -length); 10•er3(-1idth/2.0, height/2.0, lengtb/2.0); block(4,&idth,beight,length); }

283

:****************/ cursblocip()

{

e1tern int rcnt1,rcntz ;

I* DRAWS FOR BLOC( II PLAI t/

e1tern int 1do1,col,curs,planon,curson,r1,rJ,rz; extern double 1,y,z; extern double hei«iht.1idth,lenith; if(r1!:0 ll rz::O)

f cursbloch( l: }

I* CBICIS fOR I BOTATIOI *I

if(rz!:O ll rx::O) { carsblocb();

} if(rz!:O ll rx!:Oll r1!:0)

{ cursblochJz();

} if((rz!:O ll rx!:O)llr1::0)

{ if{rcntl<rcntz)

carsblocku(); if(rcntl>rcntz)

cursblocku( l;

I* CBIClS fOR Y ROTATIOI *I

I* CBICIS fOR Z ROTATIOI •/

nanuuusuuuauun/ cursbloch() I* lllCOTIS I AIIS BLOCI t/

f extern int 1do1,col,curs,planon,curson,rx,r1,r1; extern doable x,1,z; extern double hei1ht,1idth,len1th; extern int rcnt1,rcntz ;

if(n<90) { 10ter3((1idth/2.0),(-heiiht/2.0), (-length/2.0)); dravr3(0.0, (height), 0.0); 10ter3((-1idth), 0.0, 0.0); dravr3(0.0,( -height),0.0); aoter3(0.0,( height),0.0J; dra1r3(0.0, 0.0, length); 10ter3(1idth,O.O, 0.0); dravr3(0.0, 0.0, -length); 10ter3(0.0,( -heicht),0.0);

}

284

1over3(-vidth/2.0, height/2.0, length/2.0); block(4,vidth,heigbt,lengtb); }

if((rx::90l::frx==270)) {

1over3((vidth/2.0),(- height/2.0), (-lengtb/2.0)); dravr3(0.0,(beight),0.0); dravr3(-vidth,0.0, 0.0); dravr3(0.0,(-height),0.0); dravr3(vidth,0.0, O.OJ; IOter3(-vidth/2.0, height/2.0, length/2.0); block(4,vidth,height,length); }

if((rx>90)ll(rx<180)) {

IOter3((vidth/2.0),(-height/2.0), (-length/2.0)); 10ter3(0.0, (height), 0.0); dravr3(0.0, 0.0, length); IOter3(-vidth,0.0,0.0); dravr3(0.0, 0.0, -length); 10ter3(0.0,0.0, length); dravr3(0.0,( -height),0.0); 10ter3(vidth,O.O, 0.0); dravr3(0.0,(height),0.0); 1oter3(0.0,-height, -length); IOterJ(-vidth/2.0, height/2.0, length/2.0); block(4,vidth,height,length); }

cursblockxl();

/11a1111111a1111111111111tt/ carsblockxl()

{ extern int vdov,col,curs,planon,carson,rx,r1,rz; extern doable x,1,z; extern double height,vidtb,length; extern int rcntx,rcntz

if(rx::180) { 10ter3((1idth/2.0),(-height/2.0), (-length/2.0)J; dravr3(0.0,0.0,(length)); dra1rl(-1idth,O.O, 0.0); dravr3(0.0,0.0,-length); dravr3(vidth,O.O, 0.0); 1oter3(-vidth/2.0, height/2.0,leacth/2.0); block(4,vidth,height,length); }

}

285

if((r1>l80)ll(r1<270))

if(r1>2TO) {

{ 10Terl((1idth/2.0),(-height/2.0), (-length/2.0)); dravr3(0.0,0.0, length); IOTer3(-vidth,0.0, 0.0); dravr3(0.0, 0.0, -length); aoTer3(0.0, 0.0,length); dravrl(0.0,( height),0.0); IOTerl(vidth,0.0, 0.0); dravr3(0.0,(-height),0.D); IOTer3(0.0,0.0, -length); 10Terl(-1idth/2.0, height/2.0, length/2.0); block(4,1idth,height,length); }

IOTer3((vidth/2.0),(-height/2.0), (-length/2.0)); 10Ter3(0.0,( height),0.0); dra1r3(0.0, 0.0, length); dravr3(0.0, (-height), 0.0); 10Ter3((-1idth), 0.0, 0.0); dravrl(0.0,( height),0.0); dravr3(0.0, 0.0, -length); 10Terl(1idth,O.O, 0.0); IOTer3(0.0,( -height),0.0); 10Ter3(-1idth/2.0, height/2.0, length/2.0); block(4,1idth,height,length); }

'**************************/ cursblockz() I• DR&VS BLOC( roR z &llS ROT&TIOI •/

{ e1ter1 i1t 1do1,col,curs,pla1on,curson,r1,r1,rz; extern double 1,1,z; extern double heicht,vidth,lentth; extern int rcnt1,rcntz ; if (rz < 90 :: (rz >180)ll(r&< 210))

{ IOTerl((vidth/2.0),(-height/2.0), (-length/2.0)); dra1r3(0.0, (height), 0.0); dra1rl(-1idtb,O.O, 0.0); 10fer3(0.0, 0.0, lencth); dra1r3(1idth,O.O, 0.0); dra1r3(0.0,( -heicht),0.0); IOfer3(0.0, 0.0, -length); 10ferl(-1idtb/2.0, bei&bt/2.0, length/2.0); block(4,1idth,heicht,lencth);

286

if (rz==90 : : rz::270 ) {

}

10,er3((vidth/2.0),(-height/2.0), (-length/2.0)); dravr3(0.0, 0.0,length); dravr3(0.0,height, 0.0); dravr3(0.0, 0.0,-length); dravr3(0.0,-height, 0.0); IOYer3(-width/2.0, height/2.0, length/2.0); block(4,width,height,length);

if ((rz > 90 ll rz < 180):: (rz >270 ll rz c 360)) { 10Yer3((1idth/2.0),(-height/2.0), (-length/2.0)); drawr3(0.0, (height), 0.0); IOYer3(0.0, 0.0, length); dra1r3(0.0, -height, 0.0); dra1r3(-1idth,O.O, 0.0); 10,er3(0.0, 0.0,-length); drawr3(width,O.O, 0.0); IOYer3(-vidth/2.0, heigbt/2.0, length/2.0); block(4,width,height,length); }

if(rz::l80) { IOYer3((width/2.0),(-height/2.0), (-lengtb/2.0)); dravr3(0.0, (height), 0.0); drawr3((-width), 0.0, 0.0); dra1r3(0.0,( -height),0.0); drawr3(0.0, 0.0, length); drawr3(width,0.0,0.0); dravr3(0.0, 0.0, -length); IOYer3(-vidth/2.0,height/2.0 ,length/2.0); }

'**************•••••••••••••/ cursblockxz() I* TKST FOK A CO!BIIATIOK or I z ROTATIOK */ { extern int 1do1,col,curs,planon,curson,rx,r1,rz; extern double x,y,z; extern double height,vidth,length; extern int rcntx,rcntz ;

if( ((rz<90) ::( rz>90ll rz<l80) :: (r1>180 ll rz<270J: :(rz>270))ll((rxc90) : :( rx>90ll rx<180) :: (r x>180 llrx<270J:: (r1>270)) )

{ block(4,width,height,length); }

287

if( ((r1<90) :: (r1>90ll r1<180) : : (rx>l80 llr1<270) : : (rx>270))ll (rz::90 : : rz::270)) { ao•er3((vidth/2.0),(-height/2.0), (-length/2.0)); dravr3(0.0,height, 0.0); dravr3(0.0,0.0,length); dravr3(0.0,-height, 0.0); dravr3(0.0,0.0,-length); 1o•er3(-vidtb/2.0, height/2.0, length/2.0); }

if( (rx<90 : : (rx>180 llrx<270))ll ra::l80) { 1o•er3((vidth/2.0),(-height/2.0), (-lengtb/2.0)); dravr3(-vidth, 0.0, 0.0); dravr3(0.0,beight,lengtb); dravr3(vidtb, 0.0, 0.0); dravr3(0.0,-beigbt,-length); ao•er3(0.0,height,0.0); dravr3(-vidth,0.0,0.0); 1o•er3(0.0,-height,lengtb); dravr3(aidtb,0.0,0.0); 1o•er3(0.0,0.0,-lengtb); 1o•er3(-aidth/2.0, beight/2.0, length/2.0); }

if(((rx>90llrx<l80) :: rx>270)ll rz::180) { 10fer3((aidtb/2.0),(-height/2.0), (-lengtb/2.0)); 1o•er3(0.0,heigbt,0.0); dravr3(-vidtb, 0.0, 0.0); draar3(0.0,-height,length); draar3(vidth, 0.0, 0.0); dravr3(0.0,height,-length); 1o•er3(0.0,-height,0.0); dravr3(-aidth,0.0,0.0); 10•er3(0.0,height,length); draar3(aidth,0.0,0.0); 10•er3(0.0,-beigbt,-length); 1o•er3(-aidth/2.0, height/2.0, lengtb/2.0); }

carsblockxa2();

288

!***************************/ cursblockxz2()

{ extern int vdov,col,curs,planon,curson,rx,ry,rz; extern double x,y,z; extern double height,vidth,length; extern int rcntx,rcntz ; if((rx==90: :rx::270l ll (rz==90 : : rz==270 ))

{ tofer3((vidth/2.0),(-height/2.0), (-length/2.D)); dravr3(0.0,height, 0.0); dravr3(0.0,D.0,lengtb); dravr3(0.0,-height, 0.0); dravr3(0.0,0.0,-length); 1o•er3(-vidth/2.0, height/2.0, length/2.0); }

if((r1::9o::rx==2TO) ll (rz==lBO )) f 1o•er3((vidth/2.0),(-height/2.0J, (-length/2.0)); dravr3(0.0,height,0.0); dravrJ(-vidth,0.0,0.0); dravr3(0.0,-height, 0.0); dravrJ(vidth,0.0,0.0); ao•erJ(-vidth/2.0, height/2.0, length/2.0); }

if((r1==90) ll ((rz>90 ll rz<lBOJ:: (rz>270 ll rz<360 lll { 1o•er3((vidth/2.0),(-height/2.0), (-length/2.0)); 1o•er3(0.0,height, 0.0); dravr3(-vidth,O.O,lengtb); ao•er3(0.0,-height, 0.0); dravr3(vidth,0.0, -length); ao•er3(-vidth/2.0, height/2.0, length/2.0); block(4,1idth,height,length); }

if((r1::90) ll (rz<90 :: (rz>l80 ll rz<270))) { 10•er3((1idth/2.0),(-height/2.0), (-length/2.0)); 1o•er3(0.0,height, 0.0); draar3(-vidth,0.0,0.0); 1o•er3(0.0,-height, 0.0); draar3(vidth,0.0, 0.0); draar3(0.0,0.0,length); ao•er3(0.0,height, 0.0); draar3(0.0,0.0,-length); 10•er3(0.0,-height, 0.0); tofer3(-vidth/2.0, heigbt/2.0, lengtb/2.0); block(4,vidth,height,length);

} corsblock1z3();

289

'~*****************/ cursblocixz3()

{ extern int 1do1,col,curs,planon,curson,rx,r'.rz; extern double x.1.z; extern double height,1idtb,length; extern int rcntx,rcntz ; if((rx::l80) ll (rz<90 :: !rz>l80 ll rz<2T0lll

{ 1oter3((1idth/2.0l,(-heifht/2.0J, (-lentth/2.0l); 1oter3(0.0,height,0.0l; dra1r3(-1idth,-height,O.O); 1oter3(0.0,0.0,length); dra1r3(1idth,height,O.O); 10ter3(0.0,-heigbt,-lengtb); IOter3(-vidth/2.0, heigbt/2.0, lengtb/2.0); bloci(4,vidth,heigbt,length); }

if ( rx::l80 ll ((r1>90 ll rz<l80) :: rz>2TO) ) {

10ter3((1idth/2.0),(-height/2.0), (-length/2.0)); dra1r3(-1idth,height,O.O); IOter3(0.0,0.0,length); dra1r3(1idth,-height,O.O); IOter3(0.0,0.0,-length); 10ter3(-1idth/2.0, beight/2.0, length/2.0); bloci(4 11idth,height,length); }

if(rx==l80 ll (rz::90 :: rz==2T0)) { 10ter3((1idth/2.0),(-heicht/2.0), (-length/2.0)); dravr3(0.0,heicht,0.0J; dr11r3(0.0,0.0,len1th); dravr3(0.0,-height,0.0); dravr3(0.0,0.0,-length); 10ter3(-vidth/2.0, height/2.0, length/2.0); }

if(rx==180 ll r1::180) { 10ter3((1idth/2.0),(-height/2.0}, (-length/2.0}); dra1r3(-1idth,O.O,O.OJ; dra1r3(0.0,0.0,lengthJ; dra1r3(1idth,O.O,O.O}; dra1r3(0.0,0.0,-length); 10ter3(-1idth/2.0, height/2.0. length/2.0); }

cursblocixz4f l: l

?.90

, .................. , ~or~hln~kr~(ll

• P.ltP.rn int 1do1,col,curs.planon.curson.rx.ry.rz: extern double x,y,z; extern double heirht.1idth.lenrth: extern int rcntx.rcntz : ifllrx::270) ll ((rz>90 ll rz<l80l:: (rz>270 ll rz<360 Ill

f 10Yer3111idth/2.0l.f-heieht/2.0I. (-leneth/2.011: IOYer3(0.0,height, 0.0); dra1r3(-vidth,0.0,0.0); IOYer3(0.0,-height, 0.0); dra1r3(1idtb,O.O, 0.0); dravr3(0.0,0.0,length); IOYer3(0.0,height, 0.0); dra1r3(0.0,0.0,-length); IOYer3(0.0,-height, 0.0); 10Yer3(-1idth/2.0, heigbt/2.0, length/2.0); block(4,1idth,height,length); }

if((r1::270) ll (rz<90 :: (rz>180 ll rz<270))) { 10Yer3((1idth/2.0),(-height/2.0), (-length/2.0)); 10Yer3(0.0,height, 0.0); dravr3(-1idth,O.O,length); IOYer3(0.0,-height, 0.0); dra1r3(1idth,O.O, -length); 10Yer3(-vidth/2.0, height/2.0, length/2.0); block(4,1idth,height,length); }

!**************************!

291

cursblociu() {

/I JILTIR FOR Z I ROTATION I/

e1tern int 1do1,col,curs,planon,curson,r1,r1,rz; e1tern double 1,y,z; e1tern double height,1idth,length; e1tern int rcnt1,rcntz ; if( ((rz<90) ::1 n>90H n<180l :: (rz>180 H rz<270J::!rz>270J)H((n<90) ::( n>90H n<l80) :: (r

1>180 &lr1<270l:: (r1>270)) ) { bloci(4,1idtb,beigbt,lengtb); }

if( ((rz<90l :: (rz>90&& rz<1801 :: (rz>180 &&rz<270) ::rrz>270)lll {r1::90 :: r1::270)) [ 10ferl((1idtb/2.0),(-height/2.0), (-lengtb/2.0)); dra1rl(O.O,beight, 0.0); dra1rl(-1idth,O.O,O.O); dra1r3(0.0,-beigbt, 0.0); dra1rl(1idth,O.O,O.O); 10fer3(-1idth/2.0, heigbt/2.0, length/2.0); }

if(( rz<90 :: (rz>180 && rz<270)) &l r1::180) { 1oferl((1idth/2.0),(-heigbt/2.0), (-lengtb/2.0)); dra1rl(-1idtb,beigbt, 0.0); dra1r3(0.0,0.0,lenfth); dra1r3(1idth,-beigbt,O.O); dra1r3(0.0,0.0,-lengtb); 10ferl(-1idtb/2.0, heigbt/2.0, lenfth/2.0); }

if( (rz>90ll (rz<180 :: rz>270)) ll r1::180) { 10fer3((1idth/2.0),(-beight/2.D), (-lenftb/2.0)); 1ofer3(0.0, beigbt, 0.0); dra1r3(-1idth,-beigbt, 0.0); dra1rl(O.O,O.O,lenftb); dra1rl(1idtb,heigbt,O.O); dra1r3(0.0,0.0,-lenfth); 10,erl(O.O, -heifht, 0.0); 10fer3(-1idtb/2.0, heigbt/2.0, length/2.0); }

cursbloctz190(); }

flllllllllllt•••••••••••••••/

292

cursblocin90() {

I* JILTIR JOR Z 1:90 ROT&TIOM *I

e1tern int 1do1,col,curs,planon,curson,r1,r1,rz; e1tern double 1,1,z; e1tern double height,1idth,length; e1tern int rcnt1,rcntz ; if(rz::90ll(r1<90l:(r1>l80llr1<270)) )

{ 1oterl((1idth/2.0),(-height/2.0), (-length/2.0)); 1oterl(-1idth,O.O, 0.0); dra1r3(1idth, 0.0,length); 10ter3(0.0,heigbt,0.0); dra1r3(-1idth,O.O,-length); 10terl(1idth, -height, 0.0); 1oterl(-1idth/2.0, height/2.0, length/2.0); bloci(4,vidth,height,length); }

if(rz::90ll((r1>90llr1<l80l::! r1>2T0)) ) { 10ter3((1idth/2.0),(-height/2.0), (-length/2.0)); dra1r3(-1idth, 0.0,length); 10ter3(0.0,height,0.0); dra1r3(1idth,O.O,-length); 10ter3(0.0, -height, 0.0); 10terl(-1idth/2.0, height/2.0, length/2.0); bloci(4,1idth,height,length); }

if((rz==9o::rz==2TO)ll(r1==90::r1::2TO) ) { 10terl((1idth/2.0),(-height/2.0), (-length/2.0)); dra1rl(-1idth, 0.0,0.0); dravrl(0.0,height,0.0); dra1r3(1idtb, 0.0,0.0); dravr3(0.0,-height,0.0); 1oterl(-1idth/2.0, heifht/2.0, lengtb/2.0); }

if((rz==9o::rz==270)ll(r1==180) ) { 10terl((1idth/2.0),(-height/2.0), (-length/2.0)); dra1r3(0.0,0.0,lengtb); dravr3(0.0,height,0.0); dra1r3(0.0,0.0,-lengtb); dravr3(0.0,-height,0.0); IOter3(-vidth/2.0, height/2.0, length/2.0); }

cursblociz1270(); }

/:tUUUUUtUUU/

cursblockz1270() { extern int 1do1,col,curs,planon,curson,r1,r1,rz; e1tern double 1,1,z; e1tern double height,1idth,length; e1tern int rcntx,rcntz ;

if(rz==270ll((r1>90llr1<l80)::f r1>270)) ) {

293

10Yer3((1idth/2.0),(-heigbt/2.0), (-lengtb/2.0)); IOYerJ(-1idth,O.O, 0.0); dra1r3(1idth, 0.0,lengtb); IOYer3(0.0,heigbt,D.0); dra1r3(-1idth,D.D,-lengtb); aoter3(1idtb, -height, 0.0); 10Yer3(-1idth/2.0, beight/2.0, length/2.D); block(4,1idth,height 1 length); }

if(rz==270ll(r1<90::(r1>l80llr1<270)) ) { aoYer3((1idth/2.0),(-beigbt/2.0), (-length/2.0)); dra1r3(-1idth, 0.0,length); 10Yer3(0.0,heigbt,0.0); dra1r3(1idth,O.O,-length); 10Yer3(0.0, -height, D.0); 10Yer3(-1idtb/2.0, beight/2.0, lengtb/2.0); block(4,1idtb,beigbt,lengtb); }

cursblociz1180(); }

t:nnnnnnnnn/ cursblockul80() { e1tern int 1do1,col,curs,planon,curson1r1,r1,r1; e1tern double 1,1,z; e1tern double beigbt,1idtb,lengtb; e1tern int rcat1,rcnt1 ; if(rz::lBOll(r1<90::fr1>l80llr1<270)) )

{ 10Yer3((1idtb/2.0),(-heigbt/2.0), (-lengtb/2.0)); IOYer3(0.0,beigbt,0.0); dra1r3( 0.0,-beicht,lenctb); aoter3(-1idth,O.O,O.O); dra1r3( 0.0,heicht,-lencth); 1oter3(1idtb,-hei1ht10.0,0.0); ao•er3(-1idth/2.0, heicht/2.0, length/2.0); bloci(4,1idth,beigbt,len1tb); }

}

if(rz::l80ll((r1>90llr1<l80l::f r1>270)) ) {

294

1oter3((vidtb/2.0),(-beigbt/2.0), (-lengtb/2.0)); dravrl( 0.0,beigbt,lengtb); 1oter3(-vidtb,0.0,0.0); dravr3( 0.0,-beigbt,-length); 1oter3(vidtb,0.0,0.0); 1oter3(-vidtb/2.0, beight/2.0, lengtb/2.0); block(4,vidtb,heifbt,lenctb); }

if(ra::l80ll(r1::90::r1::270) ) { aoter3((vidth/2.0),(-beigbt/2.0), (-length/2.0)); dravr3( 0.0,height,0.0); dravr3(-vidth,0.0,0.0); dravrl( 0.0,-beigbt,0.0); dravr3(vidtb,0.0,0.0); 1oter3(-vidtb/2.0, beigbt/2.0, length/2.0); }

if(rz::l80llr1::180 ) { 1oter3((vidtb/2.0),(-beigbt/2.0), (-lengtb/2.0)); dravr3( -vidth,0.0,0.0); dra1r3(0.0,0.0,length); dra1r3(vidth, 0.0,0.0); dra1r3(0.0,0.0,-len1th); aoterl(-•idtb/2.0, heigbt/2.0, length/2.0); }

fllllltlllltllSlllll/

cursblockxyz() {

I* rr I y z ROTATIOK SET */

extern int 1do1,col,curs,planon,carson,rx,ry,r1; e1tern double x,y,z; extern double height,vidth,length; e1tern int rcntx,rcntz ; if((rx::9o: :r1==270)llrz::l80 )

{

295

toYer3((vidth/2.0),(-height/2.0), (-length/2.0)); dravr3( 0.0,height,0.0); dravr3(-vidth,0.0,0.0); dravr3( 0.0,-height,0.0); dravr3(vidth,0.0,0.0); toYer3(-vidth/2.0, height/2.0, length/2.0); }

if((rx==SO: :r1==270)ll(r1==90: :rz::270)) { toYer3((vidth/2.0),(-height/2.0), (-length/2.0)); dravr3( -vidth,height,0.0); 10Yer3(0.0,0.0,lengtb); dravr3(vidth,-height,0.0); 10Yer3( 0.0,0.0,-length); 10Yer3(-vidth/2.0, height/2.0, length/2.0); }

block(4,vidth,height,length); }

* THISI FDMCTIOM CRIATI SMIPT SOLIDS */ linclude 0 std.b 0

linclude <fcntl.b> linclude <sys\types.b> linclude <sys\stat.b> linclude <io.h> linclude <stdio.h> linclude "keys.b" ldef ine SSOLID "ssolid" ldefine CO!!AMD "ssolid.bak" ldef ine CO!!IKT • • ldef ine LI! 40

11t•••·························1 1oteline() { extern double x, y, z,xd, yd, zd,speed; extern int exton,vectotal; double nx,ny,nz,xl,yl,hl, bl, hl,h2, ly2, h2; extern int curs,firstcall; int ch; int outf ,run,def ,cnt; ULI •fl; 1center(); clears(O); def:O; cnt:O; tectotal=O; curs:O; f irstcall :0; color( 29);

296

aove3(0.0,500.0,0.0); I* DRAWS QUADRAITS t/ draa3(0.0,-500.0,0.0); 1ove3(500.0,0.0,0.0); draa3(-500.0,0.0,0.0); adiden(); I* RISIT !ODILIIG !ATRII t/ fl:fopen("points.d", "v");

top:

DI :Q.0 ; DY :0.0 ; nz: 0.0 ;

outf:O; run:O;

ch : getche(); outf :0; run:O; lil:x; lyl:y; hl=z;

I* CALCULATIS DllllRllCI or POllTS */

h2=hl-1; 112=1Jl-1; h2=hl-z; linfun(2); while( run::O)

{ switch( ch)

{

case ·+· : speed++; break;

case - : speed--; break;

case ·4· : left(); break;

case T : right(); break;

case '8' : up(); break;

case ·2· : down(); break;

case ·7· : upleft(); break;

case ·g· : upright(); break;

case ·3· : downright(); break;

case ·1· : downleft(); break;

case CR : ron=l; ootf:l;

297

I* TRAKSLATIS CURSOR */

fprintf(fl,"\n l.2f, l.2f",x,y); printf("\nPIIMT aaa l.2f, l.2f *** ·,1,1); if(Yectotal::Q)

{ 11:1; 11=1; }

cnt++; Yectotal tt;

break; case ISC : ron=2;

outf:l; break;

default :run=l; def: 1;

} /* svitch *I

}

if(def==l) goto tdef;

if(outf::l) goto out;

298

112:111-1; /* CALCULATIS POINT DIFFIRIKCI •/ ly2:1y1-y; lz2=lzl-z; nx : -h2; DJ :-1J2 ; u:-h2 ; linfun(2); if(•ectotal>O) dravr3(112,ly2,lz2); /* DRAWS Liii */ priatf ( "\11 : S.2f J : S.2f & : S.2f grid : S.2f " , 1, J, z. speed); ch : getche( l;

out: linfua(2); if ( ( nc total> 1 l : : I cat! : 0 l l

{ if(cnt!=ll { 1over3(n1,n1.az); dravr3(112,ly2,lz2); } cat++;

orintf(

I* DRAWS LIKI */

" -1 : l.2f -y : S.2f -1 : 1.2f grid :S.2f " , 112, ly2, 112,speed); tdef: def:O;

/lPRIITS f ALOIS a/

if(run::l) goto top; fprintf (fl, "\n vectotal ++; f close (fl l ; ifleiton::Ol 1 ;it.hP.l l: if I P.tt.nn:: 1 l

P.tt.rnrll l:

S.2f, S.2f",1l,Jl); /a COOIT YICTOR MU!BIB */

/t. UTT TO !.ATRR it

/t. RITT TO RITRnnR .,

/tltl*******************' lathe() { extern double flar, fvarl,flar2; extern int exton,ra1disk; static char input41; int ct : O; JILi Jfl; JILi *f2; char stringu; float rot; double txptr: double xlist125; double typtr: double 1list12s; double nrl1; double nr21; extern int ssnu1, •ectotal; extern double rotnu1: fl : fopenf"points.d". "r"l: f2: fopen("ssolid.d","v"); ssnu1=l: rotnu1:360.0; printf{"\n TIST VlcTOTAL: ld • ,•ectotal);

/t COISTBDCT A TDRKKD SOLID •/

fprintf{f2,"ssolid l, ld,",•ectotal); I* BIGII SSOLID COBBAID •/ printf("\nKITKR BOTATIOI AIGLK"); vhile(scanf("lf",lrot) !:l)

f printf!"PLKASI DSI IDBIRIC llPDT; TRT AGAil.\n"); scanf ("Us"); }

vhile(getchar()!:'\n'); printf("\nTIST TIST ROTATIOI: S.2f",rot);

rotnu1:rot; vhile (fgets(input,LIK,fl)!:IDLL)

fprintf(f2, ·is· ,input); forintfff2."\n: 1.2f • .rotnu1l: fclose(f2l: fclose( fl); creatssll: ietssoll l: l

/~····················••! 'extrud() {

extern double fYar, fyarl,fYar2,depthl,depth2,depth3; extern int ra1disk; static char inputt1; int ct : O;

FILI *fl; FILI lf2; char stringu; double •xptr; double xlist12s; double •yptr; double y list12 s; double nrl 1; double .ar21; float ht; extern int ssnu1, Yectotal; extern double rotnu1;

fl: fopen("points.d","r"); f2: fopen("ssolid.d","w"); ssnu1=0; rotnu1:360.0; depthl:O.O; deptb2=0.0; depth3=100.0; printf("\n TIST YlcTOTAL: Xd ·,,ectotal); fprintf(f2, "ssolid 0, Xd, ·,,ectotall;

while (fgets(input,LI!,fl)!:MOLL) fprintf(f2, ·is· ,input);

printf("\nllTIR BIIGBT"); wbile(scanf("Xf",lbt) !:l) {

300

printf("PLIASI OSI IU!IRIC IIPOT; TRY AGAIM.\n"); scanf (·xis·); }

while(getchar{)!:'\n');

}

printf("\nTIST TIST ROTATIOM : X.2f" ,bt); depth3=bt; fprintf(f2,"\n, %.2f,%.2f,l.2f",deptb1,deptb2,depth3); fclose(f2); fclose( fl l; creatss(); getssol();

/***********************!

!••••*************/ getssol() { extern int vdov,exton; extern int count,planon; extern double deptbl,deptb2,deptb3, x, y, z; extern double rotnu1,f,ar, fvarl,fvar2,f,ar3; extern int ivar, ivarl, i'ar2; extern int ssnu1,,ectotal;

static char inputco; static char strlc1; int ct : O;

char stringu; e1tern double xlistzzs; extern double 1list22s; extern double •xptr; extern double typtr; int sscount,total,ssct,,tot; rILK •fl;

1ptr=1 list: 1ptr:xlist;

'tot:O; ssct:O; total:O; sscount:O; .ectotal:O;

fl : fopenf"ssolid.d" ,"r");

301

while (fgets(input,LIK.fl)!:KOLL) /t RICIVIS COBBAIDS •/ { strcpy(strl.input); fit(input.Sl: if (((strc1p(input,SSOLIDl :: Oll::r,tot!=Ol::rsscount==-lll

f strcpy(string,lstrlc); toi( string); if (vectotal::O) /t TIST fOR LAST VICTOR t/

f ssnua=i nrl; nctotal=inr2; vtot:inr2; }

I* ASSIGIS VICTOR TOTALS */

Jtiiiiiiiiiiiiiii/

302

if(sscount==-ll { !• READS DEPTH *I depthl:fnrl; depth2=fnr2; depth3:fvar3; rotnu1:fnrl: clbeg{l); /* SETS SSOLID COMMAND TO COMMAND LIST */

if (exton::O) ssolid(ssnu1,Tectotal,1list,ylist,rotnu1);

if(e1ton::l) ssolid(ssnu1,Tectotal,1list,ylist,deptbl,depth2,depth3); clend( l; Tectotal:O; rotnu1:0. 0; Ttot:O; ssct:O; total:O; sscount=-1; }

if((total<Ttot)ll{sscount>O)) { distuet=harl; 1listuet=har2; total=ssct; ssctt+ if(total::ytot-1)

{

sscounttt;

sscount:-2; iptr=llist; Jptr=ylist; Ttot:O; }

I* ADDS VECTORS TO LIST */

I* ASSIGI TO POIKTER */

303

creatss() { e1tern int i•ar,i•arl,i•ar2,i•ar3,i•ar4,i•ar5,i•ar6,dsp; e1tern int ra1disi; extern double f•ar,fvarl,f•ar2,f•ar3,f•ar4,f•ar5,f•ar6; extern char sign; static char input40; FILK •f2; FILK ifl; nu HJ; char naeu; char co1110; char rsp; int dex; int cnt,tester; static char fil•ar1z; cnt:O; top: tester=O; printf("\nWB&T IS THI l&!I OF OBJICT ?"); gets( na1e l; printf(" char: Sc =X3d\n",

na1e1, na1e1); printf("STRIIG::lc,lc,lc,lc,Sc,ic·,

na1e1, na1e1, na1ez ,na1e1, na1e4, na1es ); printf("\nl&!i::Ss",na1e);

if ( Dilet < 97) { printf("\nB&D IA!I TRY !GAii ?"); strcpr(na1e,CO!!AID); tester:l; if(cnt>3)

}

{ tester=O; nae•= 97; }

if (tester::!) goto top;

strcpJ(fil•ar,na1e); if(( f3: fopen(fil•ar,"r")) !:IOLL)

{ fcloser f3 l: printf ( "ls llISTS -- do rou wish to o•er write { r/n}? ",fil•ar); rsp:getche( I;

if(rsp :: "() {

l lable:

te1pc ( fi har l ; goto lable; } else

i?oto end;

sizhar( fihar); printf!.\n!8Y CO!!IMTS ABOUT THI FILI ?·l: gets(co11); printf(.Addr=X5u char:'Xc':XJd\n·,

lco111, co111, co111); if (co110< 97)

f strcoJ(na1e.COK!IKTl; )

fl: fooen!"objectlist.i·,"a"l: fprintf(fl."Xs · Xs · \n",filYar,co11); f close (fl l; f2 : fopen(fil,ar, "v"); if(raadisi::O)

f3: fopen("ssolid.d",·r·); if(raadisi::l) f3: fopen("d:ssolid.d·,·r"); vhile (fgets(input,Ll!,f3)!:ROLL)

{ fprintf(f2, "Xs",input); }

fclose( fl l: !close( f2 l:

end:; } ,, ................... ,

304

305

recissol( l { extern int wdow,i•ar,ivarl,ivar2,i•ar3,iYar4,ivar5,ivar6,dsp,rnu1; e1tern int ratdisk; extern double fvar,fvarl,fvar2,f•ar3,fvar4,f•ar5,fvar6; extern char sign; e1tern double x,y,z; static char inputct; FILI •f2; FILI *fl; fILK HJ; int tester; static char na1e12; char f iharzt; int cnt; cnt:O; top: printf("\n~HAT IS TBK OBJECT TO RICIIYI ?");

gets(nHe); printf(" char: le :13d\n",

DHet, nHel); printf("STRING::Sc,lc,lc,lc,lc,lc",

na1et, na1e1, na1e2 ,na1es, na1ec, names ); if ( nHel < 97 )

{ printf("\nBAD IA!I TRY AGAII ?"); strcpy(na1e,CO!!AID); tester: 1; cnt++; if(cnt>3)

{

}

tester:O; printf(" IA!l::Ss",na1e); }

if (tester::l) goto top;

if((f3: fopen(na1e,"r"))::IDLLl { printf("\nOBJKCT IOT JOUID:"); fclose(f3); goto ead; }

f2 : fopen(na1e, "r"); if(ratdisi::O)

fl: fopen("ssolid.d","w"); if(ra1disi::l)

fl : fopen("d:ssolid.d", "w");

while (fgets(input,Ll!,f2)!=MOLL) fprintf(fl, ·is",input);

!close( fl); fclose( f2); getssol(); end:; }/* end main */

/****************!

306

307

I* TBKSI fUMCTIOMS ARI SPKCIALIZKD fUHCTIOMS; RKKOVK;KITRACT; SUBTRACT ; LOAD COKMAMD LIST */ linclude <fcntl.h> linclude <s1s\types.h> linclude <sJs\stat.h> linclude <io.h> linclude <stdio.h> linclude "std.h" linclude <s1s\t1pes.h> linclude <io.h> linclude <string.h> linclude "keJs.h" linclude • c2. h • char sign; int iYar,iYarl,iYar2,iYar3,ivar4,ivar5,iYar6,count, clcount; double fYar,fYarl,fvar2,fYar3,fYar4,fYar5,fvar6; double xcon, Jeon, zcon;

/tttttststttttttttttttt/ re1obj ()

{ /tBKGI!t/ extern int proj, dish,Yvx, VVJ, Yvz; extern int 'vxlY, Yvx2Y, YVJlY, 'VJ2v; extern int ra1disi ,vdov; extern int count,planon; extern double vvptx,YvptJ,,vptz; extern double vinxl, viax2, vinJl, vinJ2; /t SITS WIIDOW SIZK t/ extern double height,length, width, x,1,z; extern double depth1,depth2,depth3,rotnu1,ffar, fyarl,ffar2,fYar3; extern int iYar, i'arl, ifar2; extern int fectotal,total; extern int sscount,ssnu1,total,ssct,,tot; static char inputtt; static char strltt; int ct : O; extern int fali; lILI tfl; rILK tf2; nu *fl; char stringu; int locator :0; extern double pxl, pJl, p1l; extern double px2, PJ2, p12; extern double px3, pJ3, pz3; extern double px4, pJ4, pz4; extern double px5, pJ5, pz5; extern double px6, pJ6, p16; extern double px7, pJ7, pz7; extern double p18,pJ8, pz8;

308

xyzsend(); nli:O; cleari(O); clrun{249); defpnts();

I* STORIS IYZ COORDINATIS •/

I* Dlf IllS THI PIRI!KTKR POIITS t/ I* SWIPT SOLID RISIT VALOIS t/

Yectotal:O; Ytot:O; ssct:O; total=O; sscount:O;

if ( raadisk==l) { /* OPll f ILIS */ f2: fopen("d:co11and.i",·v·); fl : fopen("d:co11and.d","r"); }

if ( ra.disk==O) { f2: fopen("co11and.i","a"); fl : fopen("co11and.d","r"); }

disoat( 0. 1l: 1indo1(1in1l. 1in12. 1in,1. 1inY2l: ti SKTS VT•nov ~T7.K it i fl 1do1:: 1l

(

nrohlntl: nrohlnfl: nrot.:itl HT. l : 1indo1l1in1l. 1in1?.. 11inYl. 11inf?.l: fllOOrtlflJlf. fllJ?.f. flflf. flf?.Yl: projctforojl: disth( dish); vvrpt(Yvpt1,Y1pty,tvpt1); }

'* SKTS VT•nov ST7.K S/

vhile (fgets(input,LI!,fl)!:IULL) /t READS II FILI *I { strcpy(strl,input); /*STORKS lST 6 CHABACTIBS */ fit(input,6); ssolidr(input,strl); /s TISTS fOR SSOLID CO!!&ID *I

if((strc1p(SSOLID,input)::OJ: :!strc1p(BLAll,input)::OJ) { fprintf(f2,"ts",str1); I* PBIITS SSOLID CO!!AID s/ }

if(sscount::O)

!•

{ strcpy(string,lstrlc); tok(string); if(strc1p(LOC!TE,input)::O)

f printpts();t/

nli:O; fil terpts(); }

309

!• TISTS roR IND or SSOLID CO!!ANDl/

/S TAIES LAST CHARACTERS PROK STRING l/ I* SEPARATES IOKBERS */ I* TESTS LOCATIOR•/

if ((•ali ::OJ::(strc1p(!DTR!l,input)::O)) {

/l PRIKTS COKKAKDS THAT PASS */

}

printf("\n•Ssl",strl); count:O; func2( input); fprintf(f2, "Ss",strl); }

}/l NBILE HD t/ fclose(fl); fclose(f2);

dispi(O); if (raadisk::l)

{ f2: fopen("d:co11and.i 0

,0 r");

fl: fopen("d:co11and.d 0,

0 v0);

} if (raadisk::O)

{ f2: fopen( 0 co11and.i 0

, "r"); fl: fopen("co11and.d 0

,0 1°);

} 1hile (fgets(input,LI!,f2}!:10LL)

fprintf(fl, ·is· ,input); fclose( fl); fclose( f2);

getfilel(); } /s llDS/ , ....................... ,

/* CLOSES f ILE •/

/l SllD flLI TO CO!!&ID.D s/

!• RESITS SCREEK l/

/.tttttttttttttttttttttt/ estract( l

TKR

{ /tBIGIMt/ estern int proj, disb,vvs, vvr, vvz; extern int vvxlv, vv12Y, vvrlY, vvr2v; extern int ra1disk ,vdov; extern int count,planon; extern double vvptx,vvptr,vvptz;

310

/t SAKI PROCISS AS RIKOYI llCIPT OBJICT IN THI PKRI~I

/t ARI STORKDt/

extern double vinxl, vinx2, vinrl, vinr2; /* SITS NIMDOW SIZI t/ extern double beigbt,lengtb, vidtb, x,r,z; extern double deptb1,deptb2,deptb3,rotnu1,fvar, fvarl,fvar2,fvar3; extern int ivar, ivarl, ivar2; extern int vectotal,total; estern int sscount,ssnu1,total,ssct,vtot; static char inputce; static char strlco; int ct : O; extern int vali; PILI tfl; PILI tf2; JILi tf3; char stringu; int locator :O; extern double pxl, prl, pzl; extern double px2, pr2, pz2; extern double px3, pr3, pz3; estern double px4, pr4. pz4; extern double PIS. PJS. pzS; extern double px6. or6. oz6: extern double 017. 017. 017: estern double p18,py8, pz8; srzsend(); vali:O; cleari(O); clrun(249); defpnts(); tectotal:O; Ytot:O; ssct:O; total:O; sscount:O;

if (ra1disi:::l) { f2: fopen("d:co11and.i" ,"v"); fl: fopen("d:co11and.d 0

, "r"); }

if ( raldisi:: :0) { f2: fopen("co11and.i 0 ,"v"); fl: fopeo("co11and.d", "r"); }

dispat( 0, 1); vindov(vinxl, vinx2. vin1l. vin12l; if(11do11==ll

{ nrotx(vu); nroty( HJ); nrotz ( nz);

311

/t SITS WIMDOW SIZK •I

11indov(vin1l, vin12, vinJl, vinJ2); /t SITS WIMDOW SIZI t/ vvport(VillY, Vil2Y, YiJlY, YAJ2Y); }

while (fgets(input,LIK,fl)!:IULLJ { strcpy(strl,inpat); fit(ioput,6); ssolidr(iopnt,strl);

if((strc1p(SSOLID,input)::O): :(strc1p(BLlKl,input)::O)) { fprintf(f2, "ls",strl); l

if(sscount::Q) { strcp1(strin1.lstrlsl; toi:(string); if(strc1p(LOCATl,input)::O)

{ nli:O; f il terpts (); }

if ((vali ::lJ::!strc1p(KDTRll,input)::OJ) /* DiffKRllCI BIRK t/ {

printf("\ntlst",strl); count:O; /t STORKS AID ROIS COKKlMDS •! func2( input); fprintf(f2,"1s",strl); }

} } /t WHILE HD t/

fclose( fl); fclose( f2 l;

dispi!O); if ( radisk==l)

{ f2: fopen("d:co11and.i", "r"); fl: fopen("d:co11aod.d", "v"); }

if ( radisk::O l { f2: fopeo("co11aod.i","r"); fl: fopen("co11and.d", "w"); J

while (fgets(ioput,LIK,f2)!:KOLL) fprintf(fl, "ls" ,input);

fclose( fl); fclose( f2);

l!etf ile 11 l:

l/t UDt/ •....................... ,

312

!• MOT OSID roR TISTIMG OMLY•/ printpts(l

{ e1tern double p1l, pyl, pzl; extern double px2, py2, pz2; extern double px3, py3, pz3; extern double px4, py4, pz4; e1tern double p15, py5, pz5; extern double p16, py6, pz6; extern double p17, py7, pz7; extern double p18,py8, pz8;

FILI •sl; e1tern double fyar, fvarl,fYar2,fYar3; sl : fopen("pts.i" ,"a");

313

fprintf(sl, • S.lf < S.lf * S.lf > S.lf • l.lf > S.lf\n",pxl,fvarl,pyl,fvar2,pzl,fvar3); fprintf(sl, • S.lf < S.lf • S.lf > S.lf • S.lf < l.lf\n ",px2,fYarl,py2,fvar2,pz2,fvar3); fprintf(sl, • S.lf > S.lf • S.lf > S.lf l l.lf < l.lf\n ·,px3,fvarl,py3,fvar2,pz3,fvar3); fprintf(sl," S.lf > S.lf * l.lf > S.lf • l.lf > S.lf\n • ,px4,fvarl,py4,fvar2,pz4,fvar3); fprintf(sl," S.lf < S.lf * S.lf < l.lf • S.lf > S.lf\n ·,p15,fvarl,py5,fvar2,pz5.fvar3); fprintf(sl, • S.lf < l.lf * S.lf < S.lf l S.lf < l.lf\n ·,px6,fvarl,py6,fYar2,pz6,fvar3); fprintf(sl, • S.lf > S.lf • S.lf < S.lf • S.lf < S.lf\n ·,p17,fYarl,py7,fYar2,pz7,fvar3); fprintf(sl, • S.lf > S.lf • S.lf < S.lf • S.lf > S.lf\n ·,px8,fvarl,py8,fYar2,pz8,fvar3); fprintf(sl, ·•••••••••••••••••••••••••••••••••••\n ");

fclose(sl);

, ....................... /

314

defpnts() {

/t DIFIMIS THI 8 PIRIMKTIR POIMTS t/

extern double pxl, pJl, pzl: extern double px2, pJ2, pz2; extern double p13, py3, pz3; extern double p14. PJ4, pz4: extern double p15, py5, pz5; extern double p16, py6, pz6; extern double px7, py7, pz7; extern doable px8,py8, pz8;

extern double height.length, vidth, x,y,z; FILI tsl;

pxl:(-vidth/2.0)+1; pyl:(height/2.0)+y; pzl:(length/2.0)+z; px2=(-vidth/2.0)+1; py2:(height/2.0)+y; pz2:(-length/2.0l+z;

px3:(vidth/2.0)+1; py3:(height/2.0)+y; pz3:(-length/2.0)+z;

px4:(vidth/2.0)+x; py4:(height/2.0)+y; pz4:(length/2.0)+z;

p15:(-vidth/2.0)+x; py5:(-height/2.0)+y; pz5:(length/2.0)+z;

p16:(-1idth/2.0)+1; py6:(-height/2.0)+y; p16:(-length/2.0)+z;

px7:(vidth/2.0)+x; py7:(-height/2.0)+y; pz7:(-length/2.0)+z;

px8:(vidth/2.0)+x; py8:(-height/2.0)+y; pz8:(length/2.0)tz; }

(************************!

315

1••····················••1 filterpts() I* rILTKRS KACH POllT •/ {

extern int Yali; extern double fyar, fyarl,fYar2,fvar3; extern double pxl, pyl, pzl; extern double px2, py2, pz2; extern double px3, py3, pz3; extern double p14, py4, pz4; extern double p15, py5, pz5; extern double p16, py6, pz6; extern double p17, py7, pz7; extern double p18,py8, pz8;

if((p1l<fYarl) ll (pyl>fvar2) ll (pzl>fvar3)) { if((p12<fvarl) ll (py2>fvar2) ll (pz2<fvar3))

{ I* printf("PT2 01 "); *I

'*'*********************/

if((p13>fYarll ll (py3>fYar2) ll (pz3<fYar3)) {

I* printf("PT3 01 "); •! if((px4>fYarl) ll (py4>fvar2J ll (pz4>fYar3))

{ I* printf("PT4 0( "); s/

if((p15<fYarl) ll (py5<fYar2) ll (pz5>fYar3)) {

I* printf("PT5 0( "J; *I if((p16<fYarl) ll (py6<fYar2) ll (pz6<fYar3))

{ I* printfl"PT6 0( "); *I

if((p17>fYarl) ll (py7<fvar2) ll (pz7<fYar3)) (

I* printf("PT7 01 ");s/ if((p18>fYarl) ll (py8<fvar2) ll (pz8>fYar3))

{ Yali:l;

l

316

'***********************/ setcl2f l I* SITS CO!lMD LIST TO BOARD*/

f /*BKGII*/ extern int shade.Yax. '''· yvz: extern int •vxlY, vvx2Y, ,,,1,, •112v: extern int ra1disk ,vdov; extern int count,planon: extern double vinxl, vinx2, vinyl, viny2; extern int •ectotal,total,faceton; e1tern int sscount,ssnu1,total,ssct,Ytot; static char inputto; static char strlto; int ct : O: extern int uli: nu •ft: nu •f?.: r.h3r i;t.rinru: int locator :O: shade:O: nzsendr l: uli:O: Yectotal:O: Ytot:O; ssct:O: total:O: sscount:O:

I* SITS VIIDOM SIZI *I

if ln1rli!1k::1l {

f2: fopen("d:co11and.i","v'l: fl: fopen('d:co11and.d","r'l: }

if (radisk==Ol { f2: fopen("co11and.i" ,"v"); fl : fopen('co11and.d', 'r"l; }

317

1diden( l;

1indo1(vin1l, vin12, vinJl, vinJ2); if(vdov::l)

I* RISITS !ODILIIG !ATRII a/

I* SITS VIIDOV SIZI */

{ nrotl(n1); nrotJ(HJ); nrotz(nz); vindov(vin1l, vin12, vinrl. vinr2J; vvport(vv1l9, 9Vl29, vvrlv. vvJ29); }

printf("\nCLROM TIST Liii 475 ok util.c "); setupnrs(); printf("\nCLROI TIST Liii 459 oi util.c ");

cldel(2); dispat(2,0); clbeg(2); printf("\nCLROI TIST Liii 462 oi util.c ');

vhile (fgets(input,LI!,fl)!:IOLL) { strcpJ(strl,input); fit(input,6); ssolidr(input,strl); if(sscount::O)

{ strcpr(string,lstrls); toi(string); count:O; if(faceton::l)

{ if(strc1p(DISPAT 1 input)!:O)

func2(input); }

if (faceton::O) {

}

f unc2 (input) ; }

} /a VBILI llD */

!•ROMS SITOP CO!!AMDSt/

/a DILITIS llISTIIG CO!!AID LIST •/ ti SITS TO VIII PRA!I•/ I* BIGIIS CO!!AID LIST t/

I* RIADS PILI */

,. !AY PRISIT 1ACITIIG roa SPllD .,

1diden(); clend(); fclose( fl l; fclose( f2 l; clrun(2);

}/t KMDt/ /lttttttttttttitttttttttttttttat/

318

/t KHDS CO!!AKDLIST t/ /t CLOSKS JILK t/ I* ROIS CO!!AID LISTt/

'/***********************/ subtract(} /t PKRPOR!S & BOLKAM OPKR&TIOI t/

{ /tBKGIMt/ extern int •1x, '''· •1&; extern int •1xl•. '1x2•. •111•. •112•: extern int ra1disk .1do1: extern int count,planon.i•ar: extern double 1inxl. 1inx2. vinyl, 1in12: /t SITS MIMDOM SIZK */ extern double f•ar2,ftar3,ftar4, height,lengtb, 1idth, x,y,z; extern double rotnu1,f•ar, fyarl,ftar2,f•ar3: extern int i'ar, i•arl, i•ar2; extern int 'ectotal,total; extern int sscount,ssnu1,total.ssct,•tot; static char inputco; static char strlc1; int ct : O; extern int nli; 1ILK tfl; 1ILK tf2; 1ILI tf3; char stringu; int locator :O; extern int bop; int key; int cnt; if(bop::l) /t TKST FOR FIRST PASS t/ {

f3: fopen("sub.i","1"); fclose(f3); inr:4; har2=vidth; har3=height; fnr4:lengtb; block(4, 1idth, height, lenfth); ke1:SS; x11.send(); defp1ts(); nli:O; nctotal=O;

}

•tot:O; ssct:O; total=O: sscount:O; ke1loop();

319

I* IMTIB llYBOABD */

if (bop::O) goto 011t;

if (bop::2)

I* COBPLITIOM TIST */

{ if (radisk::l)

{ /* OPll fILIS */ fl: fopen("d:setsub.i","1"); f2 = fopen("d:co11and.i", "v"); fl: fopen("d:co11and.d", "r"); }

if (radisk==Ol { f3: fopen("setsub.i","1"); f2: fopen( 0 co11and.i", 0 1°); fl : fopen("co11and.d". "r"); }

fprintf(f3,"solbeg l"); /* PBIITS SOL COBBAIDS TO JILK*/ fprintf(f3,"\nsolbop· 0"); 1hile (fgets(inp11t,LIB,fl)!:IOLL) /* iKADS STRIIG COBBAIDS S/

( strcp1(strl,input); fit(input,6); ssolidr(input,strl); if((strc1p(SSOLID,input)::O)::(strc1p(BL&ll,input)::O))

{ fprintf(f2, "Is" ,strl); }

if (ssco11nt::O) { strcpJ(string,lstrls); tok( string); if(strc1p(LOCATl,input)::O)

{ I* printpts();s/

tali=O; filterpts(); }

ID •/

320

if ((Yali ::01::(strc1p(!DTBAl,input)::O)) { printf("\n•lst" ,strl); !• DOIS MOT IIICOTI ONLY PRINTS •/ count:O;

I• func2(input); •/ fprintf(f2,"ls",strl); }

if (uli ::1) { if(strc1p(LOCATl,input)::O)

{ strcpr(string,lstrlcl; /a TBAISJOB!S LOCATIOI TO TRAHSLATI CO!!A

fprintf(f3."\n1diden"); !• RISITS !ODILIHG !ATRII */ fprintf(f3,"\nldtran ls",string); I• TRAHSLATIS SOLID•/ } /* llD LOCATI rr */

count:O; if(strc1p(BDTBAl,input)!:O) if(strc1p(LOCATl,input)!:O) /* PRIITS ALL TRANSLATION CO!!AMDS*/ fprintf(f3, "ls",strl); } /* llD YALI If •/

} /* llD SSCOOIT If •/ }/• WBILI llD */

f close( f3); fclose( fl l; f close ( f 2) ; } /* llD If BOP STATl!llT t/ if (bop::2) subtract2(); out:;

I* IKD•/

!***************************/

I* CLOSKS JILi */

l21

subtract2( l {

I* TRlBSFIRS FILIS TO COMMAND PILI */

e1tern double 1,1,z,1d,yd,zd; static char input40; static char strl4o; FILI •fl; FILI *f2; rILI *fl; FILI *f4; e1tern int bop, ra1disi;

fl: fopen("setsub.i", "r"); f4: fopen("sub.i","r"); bop:O;

if (raadisi::l) { f2: fopen("d:co11and.i", "r"); fl: fopen("d:co11and.d", "1"); }

if (raadisi::O) { f2: fopen("co11and.i", "r"); fl: fopen("co11and.d","1"); }

vhile (fgets(input,LI!,f2)!:1DLL) fprintf(fl,"Xs",input);

vhile (fgets(input,LI!,f3)!:1DLL) fprintf(fl, ·is· ,input);

vhile (fgets(input,LI!,f4)!:1DLL) fprintf(fl, "Xs",input);

fprintf{fl,"\nsolend "); fprintf(fl,"\nsolrun 1 "); fprintf(fl, "\n1diden\n "); 1:0.0; J=O.O; z:O.O; xd:O.O; yd:O.O; zd:O.O; !close( f3); f close (fl) ; fclose(f2); fclose(f4);

getfile( l; } /* 110•/ /********************'***!

I* TRAISFIRS JILIS */

I* NRITIS IKD CORftAMDS */

q

I* CLOSIS JILi */

/t ROIS CO!!AID JILi t/

The vita has been removed from the scanned document

Recommended