%!PS-Adobe-3.0 %%Title: Makefile, display.c, display.h, geom.c, geom.h, main.c, vector.h %%For: Jacob Welsh %%Creator: a2ps version 4.13c %%CreationDate: Wed Jun 11 11:47:55 2008 %%BoundingBox: 24 24 588 768 %%DocumentData: Clean7Bit %%Orientation: Landscape %%Pages: 10 %%PageOrder: Ascend %%DocumentMedia: Letter 612 792 0 () () %%DocumentNeededResources: font Courier %%+ font Courier-Bold %%+ font Courier-BoldOblique %%+ font Courier-Oblique %%+ font Helvetica %%+ font Helvetica-Bold %%+ font Symbol %%+ font Times-Bold %%+ font Times-Roman %%DocumentProcessColors: Black %%DocumentSuppliedResources: procset a2ps-a2ps-hdr %%+ procset a2ps-black+white-Prolog %%+ encoding ISO-8859-1Encoding %%EndComments /a2psdict 200 dict def a2psdict begin %%BeginProlog %%Copyright: (c) 1988, 89, 90, 91, 92, 93 Miguel Santana %%Copyright: (c) 1995, 96, 97, 98 Akim Demaille, Miguel Santana % Check PostScript language level. /languagelevel where { pop /gs_languagelevel languagelevel def } { /gs_languagelevel 1 def } ifelse % EPSF import as in the Red Book /BeginInclude { /b4_Inc_state save def % Save state for cleanup /dict_count countdictstack def % Count objects on dict stack /op_count count 1 sub def % Count objects on operand stack userdict begin 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit [ ] 0 setdash newpath gs_languagelevel 1 ne { false setstrokeadjust false setoverprint } if } bind def /EndInclude { count op_count sub { pos } repeat % Clean up stacks countdictstack dict_count sub { end } repeat b4_Inc_state restore } bind def /BeginEPSF { BeginInclude /showpage { } def } bind def /EndEPSF { EndInclude } bind def % Page prefeed /page_prefeed { % bool -> - statusdict /prefeed known { statusdict exch /prefeed exch put } { pop } ifelse } bind def /deffont { findfont exch scalefont def } bind def /reencode_font { findfont reencode 2 copy definefont pop def } bind def % Function c-show (str => -) % centers text only according to x axis. /c-show { dup stringwidth pop 2 div neg 0 rmoveto show } bind def % Function l-show (str => -) % prints texts so that it ends at currentpoint /l-show { dup stringwidth pop neg 0 rmoveto show } bind def % center-fit show (str w => -) % show centered, and scale currentfont so that the width is less than w /cfshow { exch dup stringwidth pop % If the title is too big, try to make it smaller 3 2 roll 2 copy gt { % if, i.e. too big exch div currentfont exch scalefont setfont } { % ifelse pop pop } ifelse c-show % center title } bind def % Return the y size of the current font % - => fontsize /currentfontsize { currentfont /FontType get 0 eq { currentfont /FontMatrix get 3 get }{ currentfont /FontMatrix get 3 get 1000 mul } ifelse } bind def % reencode the font % -> /reencode { %def dup length 5 add dict begin { %forall 1 index /FID ne { def }{ pop pop } ifelse } forall /Encoding exch def % Use the font's bounding box to determine the ascent, descent, % and overall height; don't forget that these values have to be % transformed using the font's matrix. % We use `load' because sometimes BBox is executable, sometimes not. % Since we need 4 numbers an not an array avoid BBox from being executed /FontBBox load aload pop FontMatrix transform /Ascent exch def pop FontMatrix transform /Descent exch def pop /FontHeight Ascent Descent sub def % Define these in case they're not in the FontInfo (also, here % they're easier to get to. /UnderlinePosition 1 def /UnderlineThickness 1 def % Get the underline position and thickness if they're defined. currentdict /FontInfo known { FontInfo dup /UnderlinePosition known { dup /UnderlinePosition get 0 exch FontMatrix transform exch pop /UnderlinePosition exch def } if dup /UnderlineThickness known { /UnderlineThickness get 0 exch FontMatrix transform exch pop /UnderlineThickness exch def } if } if currentdict end } bind def % composite fonts for ASCII-EUC mixed string % Version 1.2 1/31/1990 % Orignal Ken'ichi HANDA (handa@etl.go.jp) % Modified Norio Katayama (katayama@rd.nacsis.ac.jp),1998 % Extend & Fix Koji Nakamaru (maru@on.cs.keio.ac.jp), 1999 % Anyone can freely copy, modify, distribute this program. /copyfont { % font-dic extra-entry-count copyfont font-dic 1 index maxlength add dict begin { 1 index /FID ne 2 index /UniqueID ne and {def} {pop pop} ifelse } forall currentdict end } bind def /compositefont { % ASCIIFontName EUCFontName RomanScale RomanOffset Rot(T/F) compositefont font /RomanRotation exch def /RomanOffset exch def /RomanScale exch def userdict /fixeucfont_dict known not { userdict begin /fixeucfont_dict 2 dict begin /UpperByteEncoding [ 16#00 1 16#20 { pop 0 } for 16#21 1 16#28 { 16#20 sub } for 16#29 1 16#2F { pop 0 } for 16#30 1 16#74 { 16#27 sub } for 16#75 1 16#FF { pop 0 } for ] def /LowerByteEncoding [ 16#00 1 16#A0 { pop /.notdef } for 16#A1 1 16#FE { 16#80 sub 16 2 string cvrs (cXX) dup 1 4 -1 roll putinterval cvn } for /.notdef ] def currentdict end def end } if findfont dup /FontType get 0 eq { 14 dict begin % % 7+8 bit EUC font % 12 dict begin /EUCFont exch def /FontInfo (7+8 bit EUC font) readonly def /PaintType 0 def /FontType 0 def /FontMatrix matrix def % /FontName /Encoding fixeucfont_dict /UpperByteEncoding get def /FMapType 2 def EUCFont /WMode known { EUCFont /WMode get /WMode exch def } { /WMode 0 def } ifelse /FDepVector [ EUCFont /FDepVector get 0 get [ 16#21 1 16#28 {} for 16#30 1 16#74 {} for ] { 13 dict begin /EUCFont EUCFont def /UpperByte exch 16#80 add def % /FontName /FontInfo (EUC lower byte font) readonly def /PaintType 0 def /FontType 3 def /FontMatrix matrix def /FontBBox {0 0 0 0} def /Encoding fixeucfont_dict /LowerByteEncoding get def % /UniqueID % /WMode /BuildChar { gsave exch dup /EUCFont get setfont /UpperByte get 2 string dup 0 4 -1 roll put dup 1 4 -1 roll put dup stringwidth setcharwidth 0 0 moveto show grestore } bind def currentdict end /lowerbytefont exch definefont } forall ] def currentdict end /eucfont exch definefont exch findfont 1 copyfont dup begin RomanRotation { /FontMatrix FontMatrix [ 0 RomanScale neg RomanScale 0 RomanOffset neg 0 ] matrix concatmatrix def }{ /FontMatrix FontMatrix [ RomanScale 0 0 RomanScale 0 RomanOffset ] matrix concatmatrix def /CDevProc {pop pop pop pop 0 exch -1000 exch 2 div 880} def } ifelse end /asciifont exch definefont exch /FDepVector [ 4 2 roll ] def /FontType 0 def /WMode 0 def /FMapType 4 def /FontMatrix matrix def /Encoding [0 1] def /FontBBox {0 0 0 0} def % /FontHeight 1.0 def % XXXX /FontHeight RomanScale 1.0 ge { RomanScale }{ 1.0 } ifelse def /Descent -0.3 def % XXXX currentdict end /tmpfont exch definefont pop /tmpfont findfont }{ pop findfont 0 copyfont } ifelse } def /slantfont { % FontName slant-degree slantfont font' exch findfont 1 copyfont begin [ 1 0 4 -1 roll 1 0 0 ] FontMatrix exch matrix concatmatrix /FontMatrix exch def currentdict end } def % Function print line number ( # -) /# { gsave sx cw mul neg 2 div 0 rmoveto f# setfont c-show grestore } bind def % -------- Some routines to enlight plain b/w printings --------- % Underline % width -- /dounderline { currentpoint gsave moveto 0 currentfont /Descent get currentfontsize mul rmoveto 0 rlineto stroke grestore } bind def % Underline a string % string -- /dounderlinestring { stringwidth pop dounderline } bind def /UL { /ul exch store } bind def % Draw a box of WIDTH wrt current font % width -- /dobox { currentpoint gsave newpath moveto 0 currentfont /Descent get currentfontsize mul rmoveto dup 0 rlineto 0 currentfont /FontHeight get currentfontsize mul rlineto neg 0 rlineto closepath stroke grestore } bind def /BX { /bx exch store } bind def % Box a string % string -- /doboxstring { stringwidth pop dobox } bind def % % ------------- Color routines --------------- % /FG /setrgbcolor load def % Draw the background % width -- /dobackground { currentpoint gsave newpath moveto 0 currentfont /Descent get currentfontsize mul rmoveto dup 0 rlineto 0 currentfont /FontHeight get currentfontsize mul rlineto neg 0 rlineto closepath bgcolor aload pop setrgbcolor fill grestore } bind def % Draw bg for a string % string -- /dobackgroundstring { stringwidth pop dobackground } bind def /BG { dup /bg exch store { mark 4 1 roll ] /bgcolor exch store } if } bind def /Show { bg { dup dobackgroundstring } if ul { dup dounderlinestring } if bx { dup doboxstring } if show } bind def % Function T(ab), jumps to the n-th tabulation in the current line /T { cw mul x0 add bg { dup currentpoint pop sub dobackground } if ul { dup currentpoint pop sub dounderline } if bx { dup currentpoint pop sub dobox } if y0 moveto } bind def % Function n: move to the next line /n { /y0 y0 bfs sub store x0 y0 moveto } bind def % Function N: show and move to the next line /N { Show /y0 y0 bfs sub store x0 y0 moveto } bind def /S { Show } bind def %%BeginResource: procset a2ps-a2ps-hdr 2.0 2 %%Copyright: (c) 1988, 89, 90, 91, 92, 93 Miguel Santana %%Copyright: (c) 1995, 96, 97, 98 Akim Demaille, Miguel Santana % Function title: prints page header. % are passed as argument /title { % 1. Draw the background x v get y v get moveto gsave 0 th 2 div neg rmoveto th setlinewidth 0.95 setgray pw 0 rlineto stroke grestore % 2. Border it gsave 0.7 setlinewidth pw 0 rlineto 0 th neg rlineto pw neg 0 rlineto closepath stroke grestore % stk: ct rt lt x v get y v get th sub 1 add moveto %%IncludeResource: font Helvetica fHelvetica fnfs 0.8 mul scalefont setfont % 3. The left title gsave dup stringwidth pop fnfs 0.8 mul add exch % leave space took on stack fnfs 0.8 mul hm rmoveto show % left title grestore exch % stk: ct ltw rt % 4. the right title gsave dup stringwidth pop fnfs 0.8 mul add exch % leave space took on stack dup pw exch stringwidth pop fnfs 0.8 mul add sub hm rmoveto show % right title grestore % stk: ct ltw rtw % 5. the center title gsave pw 3 1 roll % stk: ct pw ltw rtw 3 copy % Move to the center of the left room sub add 2 div hm rmoveto % What is the available space in here? add sub fnfs 0.8 mul sub fnfs 0.8 mul sub % stk: ct space_left %%IncludeResource: font Helvetica-Bold fHelvetica-Bold fnfs scalefont setfont cfshow grestore } bind def % Function border: prints virtual page border /border { %def gsave % print four sides 0 setgray x v get y v get moveto 0.7 setlinewidth % of the square pw 0 rlineto 0 ph neg rlineto pw neg 0 rlineto closepath stroke grestore } bind def % Function water: prints a water mark in background /water { %def gsave scx scy moveto rotate %%IncludeResource: font Times-Bold fTimes-Bold 100 scalefont setfont .97 setgray dup stringwidth pop 2 div neg -50 rmoveto show grestore } bind def % Function rhead: prints the right header /rhead { %def lx ly moveto fHelvetica fnfs 0.8 mul scalefont setfont l-show } bind def % Function footer (cf rf lf -> -) /footer { fHelvetica fnfs 0.8 mul scalefont setfont dx dy moveto show snx sny moveto l-show fnx fny moveto c-show } bind def %%EndResource %%BeginResource: procset a2ps-black+white-Prolog 2.0 1 % Function T(ab), jumps to the n-th tabulation in the current line /T { cw mul x0 add y0 moveto } bind def % Function n: move to the next line /n { %def /y0 y0 bfs sub store x0 y0 moveto } bind def % Function N: show and move to the next line /N { Show /y0 y0 bfs sub store x0 y0 moveto } bind def /S { Show } bind def /p { false UL false BX fCourier bfs scalefont setfont Show } bind def /sy { false UL false BX fSymbol bfs scalefont setfont Show } bind def /k { false UL false BX fCourier-Oblique bfs scalefont setfont Show } bind def /K { false UL false BX fCourier-Bold bfs scalefont setfont Show } bind def /c { false UL false BX fCourier-Oblique bfs scalefont setfont Show } bind def /C { false UL false BX fCourier-BoldOblique bfs scalefont setfont Show } bind def /l { false UL false BX fHelvetica bfs scalefont setfont Show } bind def /L { false UL false BX fHelvetica-Bold bfs scalefont setfont Show } bind def /str{ false UL false BX fTimes-Roman bfs scalefont setfont Show } bind def /e{ false UL true BX fHelvetica-Bold bfs scalefont setfont Show } bind def %%EndResource %%EndProlog %%BeginSetup %%IncludeResource: font Courier %%IncludeResource: font Courier-Oblique %%IncludeResource: font Courier-Bold %%IncludeResource: font Times-Roman %%IncludeResource: font Symbol %%IncludeResource: font Courier-BoldOblique %%BeginResource: encoding ISO-8859-1Encoding /ISO-8859-1Encoding [ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright /parenleft /parenright /asterisk /plus /comma /minus /period /slash /zero /one /two /three /four /five /six /seven /eight /nine /colon /semicolon /less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright /ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph /bullet /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf /threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis ] def %%EndResource % Initialize page description variables. /sh 612 def /sw 792 def /llx 24 def /urx 768 def /ury 588 def /lly 24 def /#copies 1 def /th 15.000000 def /fnfs 11 def /bfs 7.493857 def /cw 4.496314 def % Dictionary for ISO-8859-1 support /iso1dict 8 dict begin /fCourier ISO-8859-1Encoding /Courier reencode_font /fCourier-Bold ISO-8859-1Encoding /Courier-Bold reencode_font /fCourier-BoldOblique ISO-8859-1Encoding /Courier-BoldOblique reencode_font /fCourier-Oblique ISO-8859-1Encoding /Courier-Oblique reencode_font /fHelvetica ISO-8859-1Encoding /Helvetica reencode_font /fHelvetica-Bold ISO-8859-1Encoding /Helvetica-Bold reencode_font /fTimes-Bold ISO-8859-1Encoding /Times-Bold reencode_font /fTimes-Roman ISO-8859-1Encoding /Times-Roman reencode_font currentdict end def /bgcolor [ 0 0 0 ] def /bg false def /ul false def /bx false def % The font for line numbering /f# /Helvetica findfont bfs .6 mul scalefont def /fSymbol /Symbol findfont def /hm fnfs 0.25 mul def /pw cw 81.400000 mul def /ph 522.321860 th add def /pmw urx llx sub pw 2 mul sub 1 div def /pmh 0 def /v 0 def /x [ 0 dup pmw add pw add ] def /y [ pmh ph add 0 mul ph add dup ] def /scx sw 2 div def /scy sh 2 div def /snx urx def /sny lly 2 add def /dx llx def /dy sny def /fnx scx def /fny dy def /lx snx def /ly ury fnfs 0.8 mul sub def /sx 0 def /tab 8 def /x0 0 def /y0 0 def %%EndSetup %%Page: (1,1) 1 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (CC) l (=gcc) p n (CFLAGS) l (=-Wall -g `sdl-config --cflags` -DLAPTOP) p n (#CFLAGS=-Wall -g `sdl-config --cflags`) c n (LIBS) l (=-lm -lGL -lGLU `sdl-config --libs`) p n () N (geom) L (: main.o geom.o display.o) p n () S 8 T ($\(CC\) $\(CFLAGS\) -o geom main.o geom.o display.o $\(LIBS\)) N () N (main.o) L (: main.c) p n () S 8 T ($\(CC\) $\(CFLAGS\) -c main.c -o main.o) N () N (geom.o) L (: geom.c) p n () S 8 T ($\(CC\) $\(CFLAGS\) -c geom.c -o geom.o) N () N (display.o) L (: display.c) p n () S 8 T ($\(CC\) $\(CFLAGS\) -c display.c -o display.o) N () N (clean) L (:) p n () S 8 T (rm -f geom *.o) N (Makefile) (Page 1/1) (Jun 11, 08 11:39) title border /v 1 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (/* display.c) c n ( * Part of a 3D Interactive Geometry Program) N ( * Copyright 2007-2008 Jacob Welsh) N ( */) N () p n (#include) K ( ) p n (#include) K ( ) p n () N (#include) K ( ") p (display.h) str (") p n () N (SDL_Surface *dispSurf;) N () N (int) k ( dispW = 0, dispH = 0;) p n () N (int) k ( dispLib = DISP_OPENGL;) p n () N (int) k ( matrix_changed = 1;) p n (double) k ( matrix_model[16], matrix_proj[16];) p n (int) k ( matrix_view[4];) p n () N (static) K ( ) p (inline) K ( ) p (int) k ( vecToCol \(vect v\) {) p n () S 8 T (Uint8 r, g, b;) N () S 8 T () S (if) K ( \(v[0] < 0\) r = 0;) p n () S 8 T () S (else) K ( ) p (if) K ( \(v[0] > 1\) r = 255;) p n () S 8 T () S (else) K ( r = v[0] * 255.;) p n () S 8 T () N () S 8 T () S (if) K ( \(v[1] < 0\) g = 0;) p n () S 8 T () S (else) K ( ) p (if) K ( \(v[1] > 1\) g = 255;) p n () S 8 T () S (else) K ( g = v[1] * 255.;) p n () S 8 T () N () S 8 T () S (if) K ( \(v[2] < 0\) b = 0;) p n () S 8 T () S (else) K ( ) p (if) K ( \(v[2] > 1\) b = 255;) p n () S 8 T () S (else) K ( b = v[2] * 255.;) p n () S 8 T () N () S 8 T () S (return) K ( SDL_MapRGB\(dispSurf->format, r, g, b\);) p n (}) N () N (static) K ( ) p (inline) K ( ) p (void) k ( refresh_matrices\(\) {) p n () S 8 T () S (if) K ( \(matrix_changed\) {) p n () S 8 T () S 16 T (glGetDoublev \(GL_MODELVIEW_MATRIX, matrix_model\);) N () S 8 T () S 16 T (glGetDoublev \(GL_PROJECTION_MATRIX, matrix_proj\);) N () S 8 T () S 16 T (glGetIntegerv \(GL_VIEWPORT, matrix_view\);) N () S 8 T () S 16 T (matrix_changed = 0;) N () S 8 T (}) N (}) N () N (int) k ( window_to_space \() p (int) k ( w_x, ) p (int) k ( w_y, vect space_pos\) {) p n () S 8 T (refresh_matrices\(\);) N () S 8 T () S (return) K ( gluUnProject \(w_x,w_y,0, matrix_model, matrix_proj, matrix_view,) p n () S 8 T () S 16 T () S 24 T (space_pos+X, space_pos+Y, space_pos+Z\);) N (}) N (int) k ( space_to_window \(vect space_pos, ) p (int) k ( *w_x, ) p (int) k ( *w_y\) {) p n () S 8 T (refresh_matrices\(\);) N () S 8 T () S (static) K ( ) p (double) k ( d_x, d_y, d_z;) p n () S 8 T () S (int) k ( ret;) p n () S 8 T (ret = gluProject \(space_pos[X], space_pos[Y], space_pos[Z],) N () S 8 T () S 16 T () S 24 T (matrix_model, matrix_proj, matrix_view,) N () S 8 T () S 16 T () S 24 T (&d_x, &d_y, &d_z\);) N () S 8 T (*w_x = \() S (int) k (\) d_x;) p n () S 8 T (*w_y = \() S (int) k (\) d_y;) p n () S 8 T () S (return) K ( ret;) p n (}) N () N (//Drawing functions) c n (//Return 1 = success; 0 = clipped; -1 = error) N (int) k ( \(*drawFuncsGL[GEOM_NUM_TYPES]\) \(geomObj *obj\);) p n (int) k ( \(*drawFuncsSDL[GEOM_NUM_TYPES]\) \(geomObj *obj\);) p n () N (// A wrapper around the function pointers, with sanity check) c n (display.c) (Page 1/4) (Jun 11, 08 11:47) title border grestore (Printed by Jacob Welsh) rhead (Makefile, display.c) (1/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Page: (2-3) 2 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (int) k ( drawObj \(geomObj *obj\) {) p n () S 8 T () S (if) K ( \(obj && obj->type >= 0 && obj->type < GEOM_NUM_TYPES && \(obj->flags &) p n ( GEOM_F_VISIBLE\)\) {) N () S 8 T () S 16 T () S (if) K ( \(dispLib == DISP_OPENGL\)) p n () S 8 T () S 16 T () S 24 T () S (return) K ( drawFuncsGL[obj->type] \(obj\);) p n () S 8 T () S 16 T () S (else) K n () p 8 T () S 16 T () S 24 T () S (return) K ( drawFuncsSDL[obj->type] \(obj\);) p n () S 8 T (}) N () S 8 T () S (else) K n () p 8 T () S 16 T () S (return) K ( -1;) p n (}) N () N (int) k ( drawPointSDL \(geomObj *pt\) {) p n (//) c 8 T (int x, y;) N (//) S 8 T (coordToPx \(canv, pt->obj.point.pos, &x, &y\);) N (//) S 8 T (if \(x < 0 || y < 0 || x > dispW || y > dispH\) return 0;) N (//) S 8 T (\(\(Uint32 *\)dispSurf->pixels\)[x + dispW*y] = vecToCol\(pt->color\);) N () p 8 T () S (return) K ( 0;) p n (}) N (int) k ( drawPointGL \(geomObj *pt\) {) p n () S 8 T () S (if) K ( \(pt == selection\)) p n () S 8 T () S 16 T (glColor3d \(1, 1, 1\);) N () S 8 T () S (else) K ( ) p (if) K ( \(pt == nearest\)) p n () S 8 T () S 16 T (glColor3d \(0, 1, 1\);) N () S 8 T () S (else) K n () p 8 T () S 16 T (glColor3dv\(pt->color\);) N () S 8 T () N () S 8 T () S (// hack to deal with my laptop's inability to draw glPointSize > 1) c n () p 8 T () S (// also, will probably be useful in the future for better looking points) c n (#ifdef) K ( LAPTOP) p n () S 8 T () S (int) k ( win_x, win_y;) p n () S 8 T (space_to_window \(pt->obj.point.pos, &win_x, &win_y\);) N () N () S 8 T (glMatrixMode \(GL_MODELVIEW\);) N () S 8 T (glPushMatrix\(\);) N () S 8 T (glLoadIdentity\(\);) N () S 8 T (glTranslatef \(-1, -1, 0\);) N () S 8 T (glScalef \(2./dispW, 2./dispH, 1\);) N () S 8 T (glMatrixMode \(GL_PROJECTION\);) N () S 8 T (glPushMatrix\(\);) N () S 8 T (glLoadIdentity\(\);) N () N () S 8 T (glBegin \(GL_QUADS\);) N () S 8 T () S 16 T (glVertex3f \(win_x - 2, win_y - 2, 0\);) N () S 8 T () S 16 T (glVertex3f \(win_x - 2, win_y + 2, 0\);) N () S 8 T () S 16 T (glVertex3f \(win_x + 2, win_y + 2, 0\);) N () S 8 T () S 16 T (glVertex3f \(win_x + 2, win_y - 2, 0\);) N () S 8 T (glEnd\(\);) N () S 8 T () N () S 8 T (glPopMatrix\(\);) N () S 8 T (glMatrixMode \(GL_MODELVIEW\);) N () S 8 T (glPopMatrix\(\);) N (#else) K n () p 8 T (glBegin \(GL_POINTS\);) N () S 8 T () S 16 T (glVertex3dv \(pt->obj.point.pos\);) N () S 8 T (glEnd\(\);) N (#endif) K n () p 8 T () N () S 8 T () N () S 8 T () S (return) K ( 1;) p n (}) N () N (int) k ( drawLineSDL \(geomObj *ln\) {) p n () S 8 T () S (return) K ( 0;) p n (}) N (int) k ( drawLineGL \(geomObj *ln\) {) p n () S 8 T (glColor3dv\(ln->color\);) N () S 8 T (glBegin \(GL_LINES\);) N () S 8 T () S 16 T (glVertex3dv \(ln->obj.line.a->pos\);) N (display.c) (Page 2/4) (Jun 11, 08 11:47) title border /v 1 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto () p 8 T () S 16 T (glVertex3dv \(ln->obj.line.b->pos\);) N () S 8 T (glEnd\(\);) N () S 8 T () S (return) K ( 1;) p n (}) N () N (int) k ( drawPlaneSDL \(geomObj *pln\) {) p n () S 8 T () S (return) K ( 0;) p n (}) N (int) k ( drawPlaneGL \(geomObj *pln\) {) p n () S 8 T () S (return) K ( 0;) p n (}) N () N (int) k ( drawSpaceSDL \(geomObj *sp\) {) p n () S 8 T () S (return) K ( 0;) p n (}) N (int) k ( drawSpaceGL \(geomObj *sp\) {) p n () S 8 T (glClearColor \(sp->color[R], sp->color[G], sp->color[B], 1\);) N () S 8 T (glClear \(GL_COLOR_BUFFER_BIT\);) N () S 8 T () S (return) K ( 1;) p n (}) N () N (// Miscellaneous display functions) c n () p n (int) k ( initDisp\() p (void) k (\) {) p n () S 8 T () S (// Initialize drawing function pointer arrays) c n () p 8 T (drawFuncsSDL[GEOM_T_POINT] = drawPointSDL;) N () S 8 T (drawFuncsGL[GEOM_T_POINT] = drawPointGL;) N () N () S 8 T (drawFuncsSDL[GEOM_T_LINE] = drawLineSDL;) N () S 8 T (drawFuncsGL[GEOM_T_LINE] = drawLineGL;) N () N () S 8 T (drawFuncsSDL[GEOM_T_PLANE] = drawPlaneSDL;) N () S 8 T (drawFuncsGL[GEOM_T_PLANE] = drawPlaneGL;) N () N (//) c 8 T (drawFuncsSDL[GEOM_T_SPACE] = drawSpaceSDL;) N (//) S 8 T (drawFuncsGL[GEOM_T_SPACE] = drawSpaceGL;) N () p n () S 8 T () S (// Initialize SDL) c n () p 8 T () N () S 8 T () S (if) K ( \(SDL_Init\(SDL_INIT_VIDEO\)\) {) p n () S 8 T () S 16 T (fprintf \(stderr, ") S (Failed to init SDL: %s\\n) str (", SDL_GetError\(\)\);) p n () S 8 T () S 16 T () S (return) K ( 0;) p n () S 8 T (}) N () S 8 T (atexit \(SDL_Quit\);) N () S 8 T () S (return) K ( 1;) p n (}) N () N (int) k ( sizeDispSDL\() p (int) k ( w, ) p (int) k ( h\) {) p n () S 8 T (dispSurf = SDL_SetVideoMode\(w, h, 32, SDL_SWSURFACE | SDL_RESIZABLE\);) N () S 8 T () S (if) K ( \(!dispSurf\) {) p n () S 8 T () S 16 T (fprintf \(stderr, ") S (Failed to get display surface: %s\\n) str (", SDL_GetError\(\)\);) p n () S 8 T () S 16 T () S (return) K ( 0;) p n () S 8 T (}) N () S 8 T (dispW = dispSurf->w;) N () S 8 T (dispH = dispSurf->h;) N () S 8 T () S (return) K ( 1;) p n (}) N (int) k ( sizeDispGL\() p (int) k ( w, ) p (int) k ( h\) {) p n () S 8 T (SDL_GL_SetAttribute \(SDL_GL_RED_SIZE, 8\);) N () S 8 T (SDL_GL_SetAttribute \(SDL_GL_GREEN_SIZE, 8\);) N () S 8 T (SDL_GL_SetAttribute \(SDL_GL_BLUE_SIZE, 8\);) N () S 8 T (SDL_GL_SetAttribute \(SDL_GL_DEPTH_SIZE, 16\);) N () S 8 T (SDL_GL_SetAttribute \(SDL_GL_DOUBLEBUFFER, 1\);) N () S 8 T (dispSurf = SDL_SetVideoMode\(w, h, 32, SDL_OPENGL | SDL_RESIZABLE\);) N () S 8 T () S (if) K ( \(!dispSurf\) {) p n () S 8 T () S 16 T (fprintf \(stderr, ") S (Failed to get OpenGL surface: %s\\n) str (", SDL_GetError\(\)\);) p n () S 8 T () S 16 T () S (return) K ( 0;) p n () S 8 T (}) N () S 8 T (dispW = dispSurf->w;) N (display.c) (Page 3/4) (Jun 11, 08 11:47) title border grestore (Printed by Jacob Welsh) rhead (display.c) (2/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Page: (4,1) 3 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto () p 8 T (dispH = dispSurf->h;) N () S 8 T (glViewport \(0, 0, dispW, dispH\);) N () S 8 T (matrix_changed = 1;) N () S 8 T () S (return) K ( 1;) p n (}) N () N (int) k ( redrawAllGL \(Space *space\) {) p n () S 8 T (glMatrixMode \(GL_PROJECTION\);) N () S 8 T (glLoadIdentity\(\);) N () S 8 T () S (//gluPerspective \(90, 1, 1, 1000\);) c n () p 8 T (glOrtho \(-1, 1, -1, 1, -1, 1\);) N () S 8 T (glMatrixMode \(GL_MODELVIEW\);) N () S 8 T (glLoadIdentity\(\);) N () S 8 T (gluLookAt \(space->eyePos[X], space->eyePos[Y], space->eyePos[Z],) N () S 8 T () S 16 T ( space->lookAt[X], space->lookAt[Y], space->lookAt[Z],) N () S 8 T () S 16 T ( 0, 0, 1\);) N () S 8 T (matrix_changed = 1;) N () S 8 T (glClearColor \(space->bkgndCol[R], space->bkgndCol[G], space->bkgndCol[B]) N (, 0\);) N () S 8 T (glClear \(GL_COLOR_BUFFER_BIT\);) N () N () S 8 T (geomObj *curr;) N () S 8 T () S (for) K ( \(curr = space->firstObj; curr; curr = curr->next\) {) p n () S 8 T () S 16 T (drawObj \(curr\);) N () S 8 T (}) N () N () S 8 T (SDL_GL_SwapBuffers\(\);) N () S 8 T () S (return) K ( 0;) p n (}) N () N (int) k ( redrawAllSDL \(Space *space\) {) p n () S 8 T (fprintf \(stderr, ") S (redrawAllSDL: stub!\\n) str ("\);) p n () S 8 T () S (return) K ( 0;) p n (}) N (display.c) (Page 4/4) (Jun 11, 08 11:47) title border /v 1 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (/* display.h) c n ( * Part of a 3D Interactive Geometry Program) N ( * Copyright 2007-2008 Jacob Welsh) N ( */) N () p n (#ifndef) K ( DISPLAY_H) p n (#define) K ( DISPLAY_H) p n () N (#include) K ( ") p (SDL.h) str (") p n (#include) K ( ") p (geom.h) str (") p n (#include) K ( ") p (vector.h) str (") p n () N (extern) K ( SDL_Surface *dispSurf;) p n () N (extern) K ( ) p (int) k ( dispW, dispH;) p n () N (#define) K ( DISP_OPENGL 0) p n (#define) K ( DISP_SDL 1) p n (extern) K ( ) p (int) k ( dispLib;) p n () N (// set this to 1 when running a gl command that modifies matrices or viewport) c n (extern) K ( ) p (int) k ( matrix_changed;) p n () N (// Library-specific display functions) c n (int) k ( initDisp\() p (void) k (\);) p n () N (int) k ( sizeDispGL\() p (int) k ( w, ) p (int) k ( h\);) p n (int) k ( sizeDispSDL\() p (int) k ( w, ) p (int) k ( h\);) p n () N (int) k ( window_to_space \() p (int) k ( w_x, ) p (int) k ( w_y, vect space_pos\);) p n (int) k ( space_to_window \(vect space_pos, ) p (int) k ( *w_x, ) p (int) k ( *w_y\);) p n () N (//int redrawAllGL\(Canvas *canv\);) c n (//int redrawAllSDL\(Canvas *canv\);) N (int) k ( redrawAllGL\(Space *space\);) p n (int) k ( redrawAllSDL\(Space *space\);) p n () N (// Wrapper display functions) c n (static) K ( ) p (inline) K ( ) p (int) k ( sizeDisp \() p (int) k ( w, ) p (int) k ( h\) {) p n () S 8 T () S (if) K ( \(dispLib == DISP_OPENGL\)) p n () S 8 T () S 16 T () S (return) K ( sizeDispGL\(w, h\);) p n () S 8 T () S (else) K n () p 8 T () S 16 T () S (return) K ( sizeDispSDL\(w, h\);) p n (}) N (static) K ( ) p (inline) K ( ) p (int) k ( redrawAll \(Space *space\) {) p n () S 8 T () S (if) K ( \(dispLib == DISP_OPENGL\)) p n () S 8 T () S 16 T () S (return) K ( redrawAllGL\(space\);) p n () S 8 T () S (else) K n () p 8 T () S 16 T () S (return) K ( redrawAllSDL\(space\);) p n (}) N () N (#endif) K n (display.h) (Page 1/1) (Jun 11, 08 11:47) title border grestore (Printed by Jacob Welsh) rhead (display.c, display.h) (3/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Page: (1-2) 4 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (/* geom.c) c n ( * Part of a 3D Interactive Geometry Program) N ( * Copyright 2007-2008 Jacob Welsh) N ( */) N () p n (#include) K ( ) p n (#include) K ( ) p n (#include) K ( ) p n () N (#include) K ( ") p (vector.h) str (") p n (#include) K ( ") p (geom.h) str (") p n (#include) K ( ") p (display.h) str (") p n () N (geomObj *newObj \() S (int) k ( type, Space *space\) {) p n () S 8 T (geomObj *new = malloc \() S (sizeof) K (\(geomObj\)\);) p n () S 8 T () S (if) K ( \(!new\) {) p n () S 8 T () S 16 T (fprintf \(stderr, ") S (Out of memory!) str ("\);) p n () S 8 T () S 16 T (exit\(-1\);) N () S 8 T (}) N () N () S 8 T (new->type = type;) N () S 8 T (new->flags = GEOM_F_VISIBLE;) N () N () S 8 T (new->next = ) S (NULL) K (;) p n () S 8 T () S (if) K ( \(space->firstObj == ) p (NULL) K (\)) p n () S 8 T () S 16 T (space->firstObj = new;) N () S 8 T () S (if) K ( \(space->lastObj != ) p (NULL) K (\)) p n () S 8 T () S 16 T (space->lastObj->next = new;) N () S 8 T (space->lastObj = new;) N () N () S 8 T () S (return) K ( new;) p n (}) N () N (Space *newSpace \() S (void) k (\) {) p n () S 8 T (Space *new = malloc \() S (sizeof) K (\(Space\)\);) p n () S 8 T () S (if) K ( \(!new\) {) p n () S 8 T () S 16 T (fprintf \(stderr, ") S (Out of memory!) str ("\);) p n () S 8 T () S 16 T (exit \(-1\);) N () S 8 T (}) N () S 8 T (Assignvfff \(new->bkgndCol, 0, 0, 0\);) N () S 8 T (Assignvfff \(new->eyePos, 0, 0, 1\);) N () S 8 T (Assignvfff \(new->lookAt, 0, 0, 0\);) N () S 8 T (new->zoom = 1;) N () S 8 T (new->firstObj = new->lastObj = ) S (NULL) K (;) p n () S 8 T () S (return) K ( new;) p n (}) N () N (// Return: 1 if distance found; 0 if error; -1 if behind ray) c n (int) k ( find_distance \() p (double) k ( *d, vect pt, geomObj *obj, Space *space\) {) p n () S 8 T () S (/* Conventions: P := closest point on object; O := eye \(origin\) R := pt) c n () S 8 T ( * h = || P-O || h2 = h^2 = \(P-O\)*\(P-O\)) N () S 8 T ( * d = distance to find) N () S 8 T ( * r = projection of P onto ray O->R) N () S 8 T ( */) N () p 8 T () S (double) k ( h, r, h2;) p n () S 8 T (vect tmpA, tmpB;) N () S 8 T () S (double) k ( tmpf;) p n () S 8 T () S (switch) K ( \(obj->type\) {) p n () S 8 T () S (case) K ( GEOM_T_POINT:) p n () S 8 T () S 16 T () S (// d = sqrt \( h^2 - \( \(P-O\)*\(R-O\) \)^2 / \(R-O\)^2 \)) c n () p 8 T () S 16 T (Subvvv \(tmpA, obj->obj.point.pos, space->eyePos\);) N () S 8 T () S 16 T (h2 = fDotvv \(tmpA, tmpA\);) N () S 8 T () S 16 T (Subvvv \(tmpB, pt, space->eyePos\);) N () S 8 T () S 16 T (tmpf = fDotvv \(tmpA, tmpB\);) N () S 8 T () S 16 T () S (// if it's behind us) c n () p 8 T () S 16 T () S (//if \(LessOrEqualff \(tmpf, 0\)\) {) c n () p 8 T () S 16 T () S (//) c 24 T (return -1;) N () p 8 T () S 16 T () S (//}) c n () p 8 T () S 16 T (*d = sqrt \( h2 - tmpf*tmpf / fDotvv \(tmpB, tmpB\) \);) N (geom.c) (Page 1/2) (Jun 11, 08 11:47) title border /v 1 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto () p 8 T () S 16 T () S (break) K (;) p n () S 8 T () S (case) K ( GEOM_T_LINE:) p n () S 8 T () S 16 T () S (// not yet implemented \(or calculated ;\)) c n () p 8 T () S 16 T () S (break) K (;) p n () S 8 T () S (case) K ( GEOM_T_CIRCLE:) p n () S 8 T () S (case) K ( GEOM_T_PLANE:) p n () S 8 T () S 16 T () S (// definitely not yet implemented) c n () p 8 T () S 16 T () S (break) K (;) p n () S 8 T (}) N () S 8 T () S (return) K ( 1;) p n (}) N () N (geomObj *find_closest \(vect pt, Space *space\) {) N () S 8 T (geomObj *curr, *closest = ) S (NULL) K (;) p n () S 8 T () S (double) k ( d, dmin = INF;) p n () S 8 T () S (for) K ( \(curr = space->firstObj; curr; curr = curr->next\) {) p n () S 8 T () S 16 T () S (if) K ( \(! curr->flags & GEOM_F_VISIBLE\) {) p n () S 8 T () S 16 T () S 24 T () S (continue) K (;) p n () S 8 T () S 16 T (}) N () S 8 T () S 16 T () S (if) K ( \(find_distance \(&d, pt, curr, space\) == 1\) {) p n () S 8 T () S 16 T () S 24 T () S (if) K ( \(d < dmin\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T (dmin = d;) N () S 8 T () S 16 T () S 24 T () S 32 T (closest = curr;) N () S 8 T () S 16 T () S 24 T (}) N () S 8 T () S 16 T (}) N () S 8 T (}) N () S 8 T () S (return) K ( closest;) p n (}) N (geom.c) (Page 2/2) (Jun 11, 08 11:47) title border grestore (Printed by Jacob Welsh) rhead (geom.c) (4/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Page: (1-2) 5 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (/* geom.h) c n ( * Part of a 3D Interactive Geometry Program) N ( * Copyright 2007-2008 Jacob Welsh) N ( */) N () p n (#ifndef) K ( GEOM_H) p n (#define) K ( GEOM_H) p n () N (#include) K ( ") p (vector.h) str (") p n () N (// Object types \(geomObj.type\)) c n (#define) K ( GEOM_T_POINT) p 24 T (0) N (#define) K ( GEOM_T_LINE) p 24 T (1) N (#define) K ( GEOM_T_PLANE) p 24 T (2) N (#define) K ( GEOM_T_CIRCLE) p 24 T (3) N (#define) K ( GEOM_NUM_TYPES) p 24 T (4) N () N (// Object flags \(bitwise; geomObj.flags\)) c n (#define) K ( GEOM_F_VISIBLE 1) p n () N (typedef) K ( ) p (struct) k ( Point {) p n () S 8 T (vect pos;) N () S 8 T () S (double) k ( t;) p n (} Point;) N () N (typedef) K ( ) p (struct) k ( Line {) p n () S 8 T (Point *a;) N () S 8 T (Point *b;) N (} Line;) N () N (typedef) K ( ) p (struct) k ( Plane {) p n () S 8 T (Point *a, *b, *c;) N (} Plane;) N () N (typedef) K ( ) p (struct) k ( Circle {) p n () S 8 T (Point *c, *r;) N (} Circle;) N () N (typedef) K ( ) p (struct) k ( geomObj {) p n () S 8 T () S (int) k ( type;) p n () S 8 T (vect color;) N () S 8 T () S (int) k ( flags;) p n () S 8 T () S (union) K ( {) p n () S 8 T () S 16 T (Point point;) N () S 8 T () S 16 T (Line line;) N () S 8 T () S 16 T (Plane plane;) N () S 8 T () S 16 T (Circle circle;) N () S 8 T (} obj;) N (//) c 8 T (struct geomObj *parent;) N (//) S 8 T (struct geomObj *pnext; //next in the LL of parents) N () p 8 T () S (struct) k ( geomObj *next; ) p (//next in the global LL) c n (} geomObj;) p n () N (typedef) K ( ) p (struct) k ( Space {) p n () S 8 T () S (//Properties) c n () p 8 T (vect bkgndCol;) N () N () S 8 T () S (//World to Screen mapping) c n () p 8 T (vect eyePos;) N () S 8 T () S (double) k ( eyeTheta, eyePhi, eyeR;) p n () S 8 T (vect lookAt;) N () S 8 T () S (double) k ( zoom;) p n () N () S 8 T () S (//Objects in the global LL) c n () p 8 T (geomObj *firstObj;) N () S 8 T (geomObj *lastObj;) N (} Space;) N () N (// Find the object which lies closest to the ray from the eye through pt) c n (geom.h) (Page 1/2) (Jun 11, 08 11:45) title border /v 1 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (geomObj *find_closest \(vect pt, Space *space\);) p n () N (// Find the shortest distance between an object and an eye ray) c n (int) k ( find_distance \() p (double) k ( *d, vect pt, geomObj *obj, Space *space\);) p n () N (Space *newSpace \() S (void) k (\);) p n (geomObj *newObj \() S (int) k ( type, Space *space\);) p n () N (enum) k ( major_modes { m_interact, m_points, m_lines, m_circles };) p n (enum) k ( minor_modes { m_none,) p n () S 8 T () S 16 T ( m_interact_normal, m_interact_rotateview,) N () S 8 T () S 16 T ( m_lines_segment, m_lines_ray, m_lines_line };) N () N (// The following variables are declared in main.c) c n (extern) K ( ) p (enum) k ( major_modes major_mode;) p n (extern) K ( ) p (enum) k ( minor_modes minor_mode;) p n () N (extern) K ( geomObj *selection, *nearest;) p n () N (#endif) K n (geom.h) (Page 2/2) (Jun 11, 08 11:45) title border grestore (Printed by Jacob Welsh) rhead (geom.h) (5/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Page: (1-2) 6 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (/* main.c) c n ( * Part of a 3D Interactive Geometry Program) N ( * Copyright 2007-2008 Jacob Welsh) N ( */) N () p n (#include) K ( ) p n (#include) K ( ) p n (#include) K ( ) p n (#include) K ( ) p n (#include) K ( ") p (SDL.h) str (") p n () N (#include) K ( ") p (vector.h) str (") p n (#include) K ( ") p (display.h) str (") p n (#include) K ( ") p (geom.h) str (") p n () N (//Canvas *canv;) c n (Space *space;) p n (vect tmpVec, mousePos, lastMousePos;) N (geomObj *line = ) S (NULL) K (, *pt = ) p (NULL) K (, *pt1 = ) p (NULL) K (, *pt2 = ) p (NULL) K (;) p n (geomObj *tmpPt = ) S (NULL) K (, *tmpLn = ) p (NULL) K (;) p n (geomObj *selection = ) S (NULL) K (, *nearest = ) p (NULL) K (, *oldNearest = ) p (NULL) K (;) p n () N (enum) k ( major_modes major_mode = m_interact;) p n (enum) k ( minor_modes minor_mode = m_interact_normal;) p n (int) k ( stage = 0;) p n (int) k ( fSnap = 0;) p n () N (void) k ( switch_mode \() p (enum) k ( major_modes new_maj, ) p (enum) k ( minor_modes new_min\) {) p n () S 8 T () S (switch) K ( \(new_maj\) {) p n () S 8 T () S (case) K ( m_interact:) p n () S 8 T () S 16 T (tmpPt->flags &= ~GEOM_F_VISIBLE;) N () S 8 T () S 16 T (tmpLn->flags &= ~GEOM_F_VISIBLE;) N () S 8 T () S 16 T (stage = 0;) N () S 8 T () S 16 T () S (break) K (;) p n () S 8 T () S (case) K ( m_points:) p n () S 8 T () S 16 T (tmpPt->flags |= GEOM_F_VISIBLE;) N () S 8 T () S 16 T (selection = nearest = ) S (NULL) K (;) p n () S 8 T () S 16 T () S (break) K (;) p n () S 8 T () S (case) K ( m_lines:) p n () S 8 T () S 16 T (tmpPt->flags |= GEOM_F_VISIBLE;) N () S 8 T () S 16 T (selection = nearest = ) S (NULL) K (;) p n () S 8 T () S 16 T (fSnap = 0;) N () S 8 T () S 16 T () S (break) K (;) p n () S 8 T () S (case) K ( m_circles:) p n () S 8 T () S 16 T (tmpPt->flags |= GEOM_F_VISIBLE;) N () S 8 T (}) N () S 8 T (major_mode = new_maj;) N () S 8 T (minor_mode = new_min;) N (}) N () N (void) k ( update_eyepos \(Space *s\) {) p n () S 8 T (s->eyePos[X] = s->eyeR * cos\(s->eyeTheta\) * sin\(s->eyePhi\);) N () S 8 T (s->eyePos[Y] = s->eyeR * sin\(s->eyeTheta\) * sin\(s->eyePhi\);) N () S 8 T (s->eyePos[Z] = s->eyeR * cos\(s->eyePhi\);) N (}) N () N (int) k ( EventLoop \() p (void) k (\) {) p n () S 8 T (SDL_Event ev;) N () S 8 T () S (int) k ( needs_redraw = 0;) p n () S 8 T () S (int) k ( mouse_x, mouse_y;) p n () S 8 T () S (while) K ( \(SDL_PollEvent\(&ev\)\) {) p n () S 8 T () S 16 T () S (switch) K ( \(ev.type\) {) p n () S 8 T () S 16 T () S (case) K ( SDL_KEYDOWN:) p n () S 8 T () S 16 T () S 24 T () S (switch) K ( \(ev.key.keysym.sym\) {) p n () S 8 T () S 16 T () S 24 T () S (case) K ( SDLK_ESCAPE:) p n () S 8 T () S 16 T () S 24 T () S 32 T (switch_mode \(m_interact, m_interact_normal\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (case) K ( SDLK_p:) p n () S 8 T () S 16 T () S 24 T () S 32 T (switch_mode \(m_points, m_none\);) N (main.c) (Page 1/6) (Jun 11, 08 11:46) title border /v 1 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto () p 8 T () S 16 T () S 24 T () S 32 T (SDL_GetMouseState \(&mouse_x, &mouse_y\);) N () S 8 T () S 16 T () S 24 T () S 32 T (window_to_space \(mouse_x, dispH - mouse_y, tmpPt) N (->obj.point.pos\);) N () S 8 T () S 16 T () S 24 T () S 32 T (tmpPt->obj.point.pos[Z] = 0;) N () S 8 T () S 16 T () S 24 T () S 32 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (case) K ( SDLK_l:) p n () S 8 T () S 16 T () S 24 T () S 32 T () S (if) K ( \(major_mode == m_lines\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(minor_mode == m_lines_segment\) switc) p n (h_mode \(m_lines, m_lines_ray\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (else) K ( ) p (if) K ( \(minor_mode == m_lines_ray\) swit) p n (ch_mode \(m_lines, m_lines_line\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (else) K ( switch_mode \(m_lines, m_lines_segme) p n (nt\);) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S (else) K ( {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (switch_mode \(m_lines, m_lines_segment\);) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T (SDL_GetMouseState \(&mouse_x, &mouse_y\);) N () S 8 T () S 16 T () S 24 T () S 32 T (window_to_space \(mouse_x, dispH - mouse_y, tmpPt) N (->obj.point.pos\);) N () S 8 T () S 16 T () S 24 T () S 32 T (tmpPt->obj.point.pos[Z] = 0;) N () S 8 T () S 16 T () S 24 T () S 32 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (case) K ( SDLK_s:) p n () S 8 T () S 16 T () S 24 T () S 32 T () S (if) K ( \(major_mode == m_lines\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (// toggle snapping) c n () p 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(fSnap\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpPt->flags |= GEOM_F_VISIBLE;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (else) K ( {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpPt->flags &= ~GEOM_F_VISIBLE;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (fSnap = !fSnap;) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (case) K ( SDLK_q:) p n () S 8 T () S 16 T () S 24 T () S 32 T () S (return) K ( 0;) p n () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (default) K (:) p n () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T (}) N () S 8 T () S 16 T () S 24 T () S (break) K (;) p n () S 8 T () S 16 T () S (case) K ( SDL_MOUSEMOTION:) p n () S 8 T () S 16 T () S 24 T () S (switch) K ( \(major_mode\) {) p n () S 8 T () S 16 T () S 24 T () S (case) K ( m_interact:) p n () S 8 T () S 16 T () S 24 T () S 32 T () S (if) K ( \(ev.motion.state & SDL_BUTTON\(1\)\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (// drag the selection) c n () p 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(!selection\) ) p (break) K (;) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(selection->type != GEOM_T_POINT\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (fprintf \(stderr, ") S (ERROR: Missing co) str n (de!\\n) S ("\);) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S (return) K ( 0;) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (Assignvv \(lastMousePos, mousePos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (window_to_space \(ev.motion.x, dispH - ev) N (.motion.y,) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S 56 T (mousePos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (Subvvv \(tmpVec, mousePos, lastMousePos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (PlusEqvv \(selection->obj.point.pos, tmpV) N (ec\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (printf \(") S (%f %f\\n%f %f\\n) str (", mousePos[X], mou) p n (sePos[Y], selection->obj.point.pos[X], selection->obj.point.pos[Y]\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S (else) K ( ) p (if) K ( \(ev.motion.state & SDL_BUTTON\(2\)\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (// rotate the view) c n () p 8 T () S 16 T () S 24 T () S 32 T () S 40 T (space->eyeTheta += ev.motion.xrel * 0.01) N (;) N (main.c) (Page 2/6) (Jun 11, 08 11:46) title border grestore (Printed by Jacob Welsh) rhead (main.c) (6/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Page: (3-4) 7 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto () p 8 T () S 16 T () S 24 T () S 32 T () S 40 T (space->eyePhi += ev.motion.yrel * 0.01;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(space->eyeTheta < 0\) space->eyeTheta) p n ( += 2*M_PI;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(space->eyeTheta > 2*M_PI\) space->eye) p n (Theta -= 2*M_PI;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(space->eyePhi < 0\) space->eyePhi = 0) p n (;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(space->eyePhi > M_PI\) space->eyePhi ) p n (= M_PI;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (update_eyepos \(space\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T (}) S 40 T () N () S 8 T () S 16 T () S 24 T () S 32 T () S (else) K ( {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (// just find the new nearest point) c n () p 8 T () S 16 T () S 24 T () S 32 T () S 40 T (window_to_space \(ev.motion.x, dispH - ev) N (.motion.y,) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S 56 T (mousePos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (nearest = find_closest \(mousePos, space\)) N (;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(nearest != oldNearest\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (oldNearest = nearest;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (case) K ( m_points:) p n () S 8 T () S 16 T () S 24 T () S 32 T (window_to_space \(ev.motion.x, dispH - ev.motion.) N (y, tmpPt->obj.point.pos\);) N () S 8 T () S 16 T () S 24 T () S 32 T (tmpPt->obj.point.pos[Z] = 0;) N () S 8 T () S 16 T () S 24 T () S 32 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (case) K ( m_lines:) p n () S 8 T () S 16 T () S 24 T () S 32 T () S (if) K ( \(fSnap\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (window_to_space \(ev.motion.x, dispH - ev) N (.motion.y,) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S 56 T (mousePos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (nearest = find_closest \(mousePos, space\)) N (;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(nearest != oldNearest\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (oldNearest = nearest;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpLn->obj.line.b = &\(nearest->o) N (bj.point\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S (else) K ( {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (window_to_space \(ev.motion.x, dispH - ev) N (.motion.y, tmpPt->obj.point.pos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (tmpPt->obj.point.pos[Z] = 0;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (default) K (: ) p (break) K (;) p n () S 8 T () S 16 T () S 24 T (}) N () S 8 T () S 16 T () S 24 T () S (break) K (;) p n () S 8 T () S 16 T () S (case) K ( SDL_MOUSEBUTTONDOWN:) p n () S 8 T () S 16 T () S 24 T () S (switch) K ( \(major_mode\) {) p n () S 8 T () S 16 T () S 24 T () S (case) K ( m_interact:) p n () S 8 T () S 16 T () S 24 T () S 32 T (window_to_space \(ev.button.x, dispH - ev.button.) N (y,) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (mousePos\);) N () S 8 T () S 16 T () S 24 T () S 32 T (selection = find_closest \(mousePos, space\);) N () S 8 T () S 16 T () S 24 T () S 32 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (case) K ( m_points:) p n () S 8 T () S 16 T () S 24 T () S 32 T () S (if) K ( \(ev.button.button == 1\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (pt = newObj \(GEOM_T_POINT, space\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (window_to_space \(ev.button.x, dispH - ev) N (.button.y, pt->obj.point.pos\);) N (main.c) (Page 3/6) (Jun 11, 08 11:46) title border /v 1 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto () p 8 T () S 16 T () S 24 T () S 32 T () S 40 T (pt->obj.point.pos[Z] = 0;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (Assignvfff \(pt->color, 1, 0, 0\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (case) K ( m_lines:) p n () S 8 T () S 16 T () S 24 T () S 32 T () S (if) K ( \(fSnap\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(stage == 0\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (window_to_space \(ev.button.x, di) N (spH - ev.button.y,) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S 56 T () S 64 T (mousePos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (nearest = find_closest \(mousePos) N (, space\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S (if) K ( \(nearest != oldNearest\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S 56 T (oldNearest = nearest;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpLn->flags |= GEOM_F_VISIBLE;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpLn->obj.line.a = &\(nearest->o) N (bj.point\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (stage++;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (else) K ( ) p (if) K ( \(stage == 1\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (window_to_space \(ev.button.x, di) N (spH - ev.button.y,) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S 56 T () S 64 T (mousePos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (nearest = find_closest \(mousePos) N (, space\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S (if) K ( \(nearest != oldNearest\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T () S 56 T (oldNearest = nearest;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (line = newObj \(GEOM_T_LINE, spac) N (e\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (Assignvfff \(line->color, 1, 1, 1) N (\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (line->obj.line.a = tmpLn->obj.li) N (ne.a;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (line->obj.line.b = &\(nearest->ob) N (j.point\);) N () N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpLn->flags &= ~GEOM_F_VISIBLE;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (stage = 0;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S (else) K ( {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (if) K ( \(stage == 0\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (pt = newObj \(GEOM_T_POINT, space) N (\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (window_to_space \(ev.button.x, di) N (spH - ev.button.y, pt->obj.point.pos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (pt->obj.point.pos[Z] = 0;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (Assignvfff \(pt->color, 1, 0, 0\);) N () N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpLn->flags |= GEOM_F_VISIBLE;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpLn->obj.line.a = &\(pt->obj.po) N (int\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpLn->obj.line.b = &\(tmpPt->obj) N (.point\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (stage++;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S (else) K ( ) p (if) K ( \(stage == 1\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (line = newObj \(GEOM_T_LINE, spac) N (e\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (Assignvfff \(line->color, 1, 1, 1) N (\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (line->obj.line.a = &\(pt->obj.poi) N (nt\);) N () N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (pt = newObj \(GEOM_T_POINT, space) N (main.c) (Page 4/6) (Jun 11, 08 11:46) title border grestore (Printed by Jacob Welsh) rhead (main.c) (7/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Page: (5-6) 8 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (\);) p n () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (window_to_space \(ev.button.x, di) N (spH - ev.button.y, pt->obj.point.pos\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (pt->obj.point.pos[Z] = 0;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (Assignvfff \(pt->color, 1, 0, 0\);) N () N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (line->obj.line.b = &\(pt->obj.poi) N (nt\);) N () N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (tmpLn->flags &= ~GEOM_F_VISIBLE;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T () S 48 T (stage = 0;) N () S 8 T () S 16 T () S 24 T () S 32 T () S 40 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T (}) N () S 8 T () S 16 T () S 24 T () S 32 T () S (break) K (;) p n () S 8 T () S 16 T () S 24 T () S (default) K (: ) p (break) K (;) p n () S 8 T () S 16 T () S 24 T (}) N () N () S 8 T () S 16 T () S 24 T () S (break) K (;) p n () S 8 T () S 16 T () S (case) K ( SDL_QUIT:) p n () S 8 T () S 16 T () S 24 T () S (return) K ( 0;) p n () S 8 T () S 16 T () S 24 T () S (break) K (;) p n () S 8 T () S 16 T () S (case) K ( SDL_VIDEOEXPOSE:) p n () S 8 T () S 16 T () S 24 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S (break) K (;) p n () S 8 T () S 16 T () S (case) K ( SDL_VIDEORESIZE:) p n () S 8 T () S 16 T () S 24 T () S (if) K ( \(!sizeDisp\(ev.resize.w, ev.resize.h\)\) {) p n () S 8 T () S 16 T () S 24 T () S 32 T (fprintf \(stderr, ") S (Failed to resize display: %s\\n) str (", SDL_Get) p n (Error\(\)\);) N () S 8 T () S 16 T () S 24 T () S 32 T () S (return) K ( -1;) p n () S 8 T () S 16 T () S 24 T (}) N () S 8 T () S 16 T () S 24 T () S (//stretch the canvas to fit the screen) c n () p 8 T () S 16 T () S 24 T () S (//sizeCanvas\(canv, canv->x1, canv->x2, canv->y1, canv->y) c n (2\);) N () p 8 T () S 16 T () S 24 T () S (//redrawAll\(canv\);) c n () p 8 T () S 16 T () S 24 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S (break) K (;) p n () S 8 T () S 16 T () S (case) K ( SDL_ACTIVEEVENT:) p n () S 8 T () S 16 T () S 24 T () S (if) K ( \(ev.active.gain == 1\)) p n () S 8 T () S 16 T () S 24 T () S 32 T (needs_redraw = 1;) N () S 8 T () S 16 T () S 24 T () S (break) K (;) p n () S 8 T () S 16 T (}) N () S 8 T (}) N () S 8 T () S (if) K ( \(needs_redraw\)) p n () S 8 T () S 16 T (redrawAll \(space\);) N () S 8 T () S (return) K ( 1;) p n (}) N () N (int) k ( main \() p (int) k ( argc, ) p (char) k ( *argv[]\) {) p n () S 8 T () S (if) K ( \(initDisp\(\) == 0\) ) p (return) K ( 1;) p n () S 8 T () S (//dispLib = DISP_SDL;) c n () p 8 T (dispLib = DISP_OPENGL;) N () S 8 T () S (if) K ( \(sizeDisp\(640, 480\) == 0\) ) p (return) K ( 1;) p n () N () S 8 T (glPointSize \(4\);) N () N () S 8 T () S (// Create the containing space for all geometry) c n () p 8 T (space = newSpace\(\);) N () S 8 T () S (//Assignvfff \(space->eyePos, 0, 0, 100\);) c n () p 8 T (space->eyeTheta = M_PI / 2.;) N () S 8 T (space->eyePhi = M_PI / 2.;) N () S 8 T (space->eyeR = 10;) N () S 8 T (update_eyepos \(space\);) N () S 8 T () S (//Assignvfff \(space->bkgndCol, 0, 1, 1\);) c n () p n () S 8 T () S (//root = newObj \(GEOM_T_SPACE, NULL\);) c n () p 8 T () S (//Assignvfff \(root->obj.space.eyePos, 0, 0, 1\);) c n () p 8 T () S (//Assignvfff \(root->obj.space.lookAt, 0, 0, 0\);) c n () p 8 T () S (//root->obj.space.zoom = 1;) c n () p 8 T () S (//Assignvfff \(root->color, 1, 1, 1\);) c n (main.c) (Page 5/6) (Jun 11, 08 11:46) title border /v 1 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto () p n () S 8 T (pt1 = newObj \(GEOM_T_POINT, space\);) N () S 8 T (Assignvfff \(pt1->obj.point.pos, 0, 0, 0\);) N () S 8 T (Assignvfff \(pt1->color, 1, 0, 0\);) N () N () S 8 T (tmpPt = newObj \(GEOM_T_POINT, space\);) N () S 8 T (tmpPt->flags &= ~GEOM_F_VISIBLE;) N () S 8 T (Assignvfff \(tmpPt->color, 1, 0, 0\);) N () N () S 8 T (tmpLn = newObj \(GEOM_T_LINE, space\);) N () S 8 T (tmpLn->flags &= ~GEOM_F_VISIBLE;) N () S 8 T (Assignvfff \(tmpLn->color, 1, 1, 1\);) N () N (//) c 8 T (pt2 = newObj \(GEOM_T_POINT, space\);) N (//) S 8 T (Assignvfff \(pt2->obj.point.pos, .1, 0, 0\);) N (//) S 8 T (Assignvfff \(pt2->color, 0, 1, 0\);) N (//) S 8 T () N (//) S 8 T (line = newObj \(GEOM_T_LINE, space\);) N (//) S 8 T (line->obj.line.a = &\(pt1->obj.point\);) N (//) S 8 T (line->obj.line.b = &\(pt2->obj.point\);) N (//) S 8 T (Assignvfff \(line->color, 0, 0, 1\);) N () p n () S 8 T (redrawAll\(space\);) N () S 8 T () N () S 8 T () S (while) K ( \(EventLoop\(\)\) {) p n () S 8 T () S 16 T (SDL_Delay \(10\);) N () S 8 T () S 16 T (redrawAll\(space\);) N () S 8 T (}) N () S 8 T () S (return) K ( 0;) p n (}) N (main.c) (Page 6/6) (Jun 11, 08 11:46) title border grestore (Printed by Jacob Welsh) rhead (main.c) (8/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Page: (1-2) 9 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (/***********************************************************************) c n ( Copyright \(C\) 2006-2008 Jacob Welsh ) N ( ) N ( This program is free software; you can redistribute it and/or modify) N ( it under the terms of the GNU General Public License as published by) N ( the Free Software Foundation; either version 2 of the License, or) N ( \(at your option\) any later version.) N ( ) N ( This program is distributed in the hope that it will be useful,) N ( but WITHOUT ANY WARRANTY; without even the implied warranty of) N ( MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file) N ( COPYING for details.) N ( **********************************************************************) N ( vector.h: Defines inline functions and macros for the convenient) N ( manipulation of vectors.) N (*/) N () p n (#ifndef) K ( VECTOR_H) p n (#define) K ( VECTOR_H) p n () N (#include) K ( ) p n () N (typedef) K ( ) p (double) k ( Float;) p n (typedef) K ( Float vect[3];) p n () N (#define) K ( EPSILON 1e-6) p n (#define) K ( INF 1./0.) p n () N (#define) K ( X 0) p n (#define) K ( Y 1) p n (#define) K ( Z 2) p n () N (#define) K ( R 0) p n (#define) K ( G 1) p n (#define) K ( B 2) p n () N (// Yeah I know, not enough parentheses -- just don't abuse these too hard.) c n (#define) K ( Equalff\(a,b\) \(a+EPSILON >= b && a-EPSILON <= b\)) p n (#define) K ( LessThanff\(a,b\) \(a+EPSILON < b\)) p n (#define) K ( LessOrEqualff\(a,b\) \(a-EPSILON <= b\)) p n (#define) K ( GrtThanff\(a,b\) \(a-EPSILON > b\)) p n (#define) K ( GrtOrEqualff\(a,b\) \(a+EPSILON >= b\)) p n () N (#define) K ( fDotvv\(a,b\) \(a[X]*b[X] + a[Y]*b[Y] + a[Z]*b[Z]\)) p n () N (#define) K ( fLengthv\(vec\) sqrt\(vec[X]*vec[X] + vec[Y]*vec[Y] + vec[Z]*vec[Z]\)) p n (#define) K ( fLengthfff\(a,b,c\) sqrt\(a*a + b*b + c*c\)) p n () N (inline) K ( ) p (static) K ( ) p (void) k ( Assignvv \(vect dest, vect src\)) p n ({) N () S 8 T (dest[X] = src[X];) N () S 8 T (dest[Y] = src[Y];) N () S 8 T (dest[Z] = src[Z];) N (}) N (inline) K ( ) p (static) K ( ) p (void) k ( Assignvf \(vect dest, Float src\)) p n ({) N () S 8 T (dest[X] = src;) N () S 8 T (dest[Y] = src;) N () S 8 T (dest[Z] = src;) N (}) N (inline) K ( ) p (static) K ( ) p (void) k ( Assignvfff \(vect dest, Float a, Float b, Float c\)) p n ({) N () S 8 T (dest[X] = a;) N () S 8 T (dest[Y] = b;) N () S 8 T (dest[Z] = c;) N (}) N () N () N (inline) K ( ) p (static) K ( ) p (void) k ( PlusEqvv \(vect dest, vect src\)) p n (vector.h) (Page 1/3) (Jun 11, 08 11:46) title border /v 1 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto ({) p n () S 8 T (dest[X] += src[X];) N () S 8 T (dest[Y] += src[Y];) N () S 8 T (dest[Z] += src[Z];) N (}) N (inline) K ( ) p (static) K ( ) p (void) k ( PlusEqvf \(vect dest, Float src\)) p n ({) N () S 8 T (dest[X] += src;) N () S 8 T (dest[Y] += src;) N () S 8 T (dest[Z] += src;) N (}) N () N (inline) K ( ) p (static) K ( ) p (void) k ( Addvvv \(vect dest, vect a, vect b\)) p n ({) N () S 8 T (dest[X] = a[X] + b[X];) N () S 8 T (dest[Y] = a[Y] + b[Y];) N () S 8 T (dest[Z] = a[Z] + b[Z];) N (}) N (inline) K ( ) p (static) K ( ) p (void) k ( Addvvf \(vect dest, vect a, Float b\)) p n ({) N () S 8 T (dest[X] = a[X] + b;) N () S 8 T (dest[Y] = a[Y] + b;) N () S 8 T (dest[Z] = a[Z] + b;) N (}) N () N (inline) K ( ) p (static) K ( ) p (void) k ( MinEqvv \(vect subfrom, vect sub\)) p n ({) N () S 8 T (subfrom[X] -= sub[X];) N () S 8 T (subfrom[Y] -= sub[Y];) N () S 8 T (subfrom[Z] -= sub[Z];) N (}) N (inline) K ( ) p (static) K ( ) p (void) k ( MinEqvf \(vect subfrom, Float sub\)) p n ({) N () S 8 T (subfrom[X] -= sub;) N () S 8 T (subfrom[Y] -= sub;) N () S 8 T (subfrom[Z] -= sub;) N (}) N () N (inline) K ( ) p (static) K ( ) p (void) k ( Subvvv \(vect dest, vect a, vect b\)) p n ({) N () S 8 T (dest[X] = a[X] - b[X];) N () S 8 T (dest[Y] = a[Y] - b[Y];) N () S 8 T (dest[Z] = a[Z] - b[Z];) N (}) N (inline) K ( ) p (static) K ( ) p (void) k ( Subvvf \(vect dest, vect a, Float b\)) p n ({) N () S 8 T (dest[X] = a[X] - b;) N () S 8 T (dest[Y] = a[Y] - b;) N () S 8 T (dest[Z] = a[Z] - b;) N (}) N () N (inline) K ( ) p (static) K ( ) p (void) k ( MultEqvv \(vect dest, vect src\)) p n ({) N () S 8 T (dest[X] *= src[X];) N () S 8 T (dest[Y] *= src[Y];) N () S 8 T (dest[Z] *= src[Z];) N (}) N (inline) K ( ) p (static) K ( ) p (void) k ( MultEqvf \(vect dest, Float src\)) p n ({) N () S 8 T (dest[X] *= src;) N () S 8 T (dest[Y] *= src;) N () S 8 T (dest[Z] *= src;) N (}) N () N (inline) K ( ) p (static) K ( ) p (void) k ( Multvvv \(vect dest, vect a, vect b\)) p n ({) N () S 8 T (dest[X] = a[X] * b[X];) N () S 8 T (dest[Y] = a[Y] * b[Y];) N () S 8 T (dest[Z] = a[Z] * b[Z];) N (vector.h) (Page 2/3) (Jun 11, 08 11:46) title border grestore (Printed by Jacob Welsh) rhead (vector.h) (9/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Page: (3) 10 %%BeginPageSetup /pagesave save def sh 0 translate 90 rotate %%EndPageSetup iso1dict begin gsave llx lly 12 add translate /v 0 store /x0 x v get 3.147420 add sx cw mul add store /y0 y v get bfs th add sub store x0 y0 moveto (}) p n (inline) K ( ) p (static) K ( ) p (void) k ( Multvvf \(vect dest, vect a, Float b\)) p n ({) N () S 8 T (dest[X] = a[X] * b;) N () S 8 T (dest[Y] = a[Y] * b;) N () S 8 T (dest[Z] = a[Z] * b;) N (}) N () N (inline) K ( ) p (static) K ( ) p (void) k ( DivEqvv \(vect dividend, vect divisor\)) p n ({) N () S 8 T (dividend[X] /= divisor[X];) N () S 8 T (dividend[Y] /= divisor[Y];) N () S 8 T (dividend[Z] /= divisor[Z];) N (}) N () N (inline) K ( ) p (static) K ( ) p (void) k ( Divvvv \(vect dest, vect a, vect b\)) p n ({) N () S 8 T (dest[X] = a[X] / b[X];) N () S 8 T (dest[Y] = a[Y] / b[Y];) N () S 8 T (dest[Z] = a[Z] / b[Z];) N (}) N (inline) K ( ) p (static) K ( ) p (void) k ( Divvvf \(vect dest, vect a, Float b\)) p n ({) N () S 8 T (dest[X] = a[X] / b;) N () S 8 T (dest[Y] = a[Y] / b;) N () S 8 T (dest[Z] = a[Z] / b;) N (}) N () N (#endif) K ( ) p (//not VECTOR_H) c n (vector.h) (Page 3/3) (Jun 11, 08 11:46) title border grestore (Printed by Jacob Welsh) rhead (vector.h) (10/10) (Wednesday June 11, 2008) footer end % of iso1dict pagesave restore showpage %%Trailer end %%EOF