TUGboat, Volume 0 (9999), No. 0 preliminary draft, December 27, 2017 18:02 ? 1 60 TUGboat, Volume 39 (2018), No. 1 Three-dimensional graphics with An interesting and detailed introduction to the TikZ/PSTricks and the help of Geogebra problem of producing three-dimensional graphics Three-dimensional graphics with with Ti kkZ can be found in an article by Keith Wol- Luciano Battaia TikZ/PSTricks and the help of GeoGebra cott [ [55],]. and It was actually in fact it was the just reading the reading of this ofarticle this that led us to study the problem in order to find AbstractLuciano Battaia article that led us to study the problem in order to finda more a more accessible affordable solution. solution. Wolcott’s This article ends In this article we consider the opportunity of using a Abstract indeedwith a figure with a which figure shows that only shows the the partial onlysolution partial so- of dynamical geometry software like Geogebra in order what had been the main purpose of the project: the In this article we consider the opportunity of using lution of what was the main purpose of the project: to allow an easy export of three-dimensional geomet- drawing of two spheres and their circle of intersection. dynamic geometry software, such as GeoGebra, to the drawing of two spheres and their circle of inter- ric pictures, with subsequent 2D parallel projection, The author himself points out that the figure needs allow easy exporting of three-dimensional geometric section. Wolcott himself points out that the figure in PGF/TikZ or PSTricks code. The help of a software more work. pictures, with subsequent 2D parallel projection, in needs more work. like Geogebra makes easy enough the production of This is the reason why we begin this article PGF/TikZ or PSTricks code. The help of software like That’s the reason why we begin this article with very complex pictures in LATEX code, having only a with figure 1, which exactly reaches Wolcott’s goal. GeoGebra considerably simplifies the production of figure 1 that exactly reaches Wolcott’s goal. Expla- basic knowledge of PGF/TikZ or PSTricks languages Explanations on how we obtain it will be given later, A nations on how to obtain it will be given later, but andvery taking complex advantage pictures of in a L programmingTEX code, requiring substantially only a webut immediately we immediately point point out thatout that our approachour approach to the to mousebasic knowledge driven. All of examplesPGF/TikZ and or samplePSTricks codes languages are in problemthe problem is completely is completely different different from from Wolcott’s Wolcott’s. one. PGF/Tiand takingkZ, advantage but almost of nothing a substantially changesmouse if one prefers driven PSTricksprogram.. All examples and sample code here are in PGF/TikZ, but almost nothing changes if one prefers PSTricks. 1 Introduction The1 Introduction need for high quality in LATEX documents, in particular with labels in the same A styleLTEX as users, the document, particularly has those always writing been scientific an essential pa- requestpers, have by always all users, had above a need all for for high-quality scientific papers. vector graphics,There including is no special labels, problem that fit in the casestyle of of two- the dimensionalrest of their graphics,documents. and the two most widespread toolsTherePSTricks is noand specialPGF/Ti problemkZ (that in from the case now onof two- will dimensional graphics, and the two most widespread only be mentioned shortly as TikZ), together with Figure 1: The intersection of two spheres with the theirtools derivedPSTricks packages, and PGF solve/Tik almostZ (that every from problem now on Figure 1: The intersection of two spheres with the circle of intersection verywill only well. be As mentioned shown by Claudio merely Beccari as TikZ), [2], together in many with their derived packages, solve almost every prob- situations the use of the basic LATEX picture envi- For the sake of completeness, we would like to lem very well. As Claudio Beccari has shown [2], For the sake of completeness, we mention that ronment is sufficient, without any intervention of point out that a slightly different version of this A a slightly different version of this article, in Italian, externalLTEX’s basic packages.picture environment is sufficient for article,can be foundin Italian, in [1]. can be found in [1]. manyThings situations. change a lot if we are interested in three- Things change substantially if we are interested 2 The coming of Geogebra on the scene dimensional graphics. Plots of two variables func- 2 The coming of GeoGebra on the scene tionsin three-dimensional and of various graphics. kinds of Plots surfaces of two-variable can easily For educational reasons we have been using Geogebra befunctions handled and using of various dedicated kinds packages, of surfaces for can instance easily forFor a educational long time, reasonsboth because we have its been non-commercial using GeoGebra use pst3dplotbe handledor pgfplots using dedicated. Also for packages, geometric figuresfor instance some isfor free a long and time, because both its because basic use its isnon-commercial extremely simple. use verypst3dplot interestingor pgfplots packages. Also, are for available, geometric for figures exam- Withis free reference and because to the its problem basic use we is extremelyare dealing simple. with, plesomepst-solides3d very interestingor pst-3d packagesin the arePSTricks available,family for ex- or Withthe interesting reference thing to the is problem the possibility we are ofdealing producing with, tikz-3dplotample pst-solides3din the TikorZ family,pst-3d in but the inPST all casesricks a family some- complexthe interesting two-dimensional thing is the figures possibility and exporting of producing them whator tikz-3dplot deep knowledgein the Ti ofkZ programming family, but techniquesin all cases in a incomplexPSTricks two-dimensionalor TikZ code, figures that can and thenexporting be copied them PSTricksrather deepor Ti knowledgekZ is needed of programming and, in our opinion, techniques this andin PST pastedricks directly or TikZ in code, a LAT thatX source can then with be only copied very EA isin notPST easyricks at or all Ti forkZ the is needed average and, user. in our opinion, limitedand pasted adaptations, directly into mainly a LT regardindEX source the with correct only this isExternal not at all programs easy for that the average produce user.PSTricks or labelvery limited positioning. adaptations, The required mainly knowledge regarding of correct LAT X A E TikZExternalcodes can programs help, for instancethat produceSketchPSTbyricks Eugene or packageslabel positioning. is minimal The and required affordable knowledge for even of inexpe- LTEX TikZ codes can help, for instance Sketch by Eugene packages is minimal and manageable for even in- Ressler, see for example [3], or TEXgraph by Patrick rienced users. Substantially you can produce even Ressler (see for example [3]) and T Xgraph by Patrick experienced users. In short, anyone can produce Fradin (http://texgraph.tuxfamily.org/E ). The complex figures to be included in LATEX documents texgraph.tuxfamily.org/ A lastFradin one ( in particular is very powerful). Theand can last also one witheven acomplexWYSIWYG figurestechnique to be included and extensively in LTEX usingdocu- producein particularPOV-Ray is verycode, powerful but, again, and can it isalso not produce within thements mouse. with This a WYSIWYG seems fartechnique enough from and what extensively a LAT X A E POV-Rthe reachay code, of most but, users. again, Almost it is not the within same the remarks reach userusing normally the mouse. does, This but seems we think far from that what in the a L caseTEX applyof most to users.Asymptote Almost, whose the codesame can remarks be directly apply in- to ofuser graphics normally this does, strategy but we should think that be preferred. in the case Of of Asymptotecluded in a, L whoseAT X source code can through be directly the asymptote includedpack- in a coursegraphics one this must strategy know is Geogebra preferable well for enough, many users. but A E age.LTEX source through the asymptote package. thisOf course does not one require must theknow study GeoGebra of long andwell complex enough, An interesting and detailed introduction to the but this does not require the study of long and com- preliminaryproblem of draft, producing December three-dimensional 27, 2017 18:02 graphics plex handbooks preliminary and, draft, at any December rate, dynamic 27, 2017 geometry 18:02

Luciano Battaia ? 2 preliminary draft, December 27, 2017 18:02 TUGboat, Volume 0 (9999), No. 0 TUGboat, Volume 39 (2018), No. 1 61 handbooks and, at any rate, a software of dynamic softwaregeometry is is of of great great help help to in experiment experimenting the construc- with the constructiontion of technical of technical figures. An figures. example An of example a complex of a complex2D figure2D easilyfigure produced easily produced in Geogebra in GeoGebra and exported and exportedin TikZ almost into Ti withoutkZ almost any withoutintervention intervention in the code in theis proposed generated in code figure is 2. shown in figure 2.

∆x Strain

P0 Time Figure 3: Sphere with meridians and parallels, 0 U Time produced with code exported from Geogebra U0 Strain

Excitation Excitation Figure 3: Sphere with meridians and parallels, producedThe two by pictures Tomasz Trzeciak are almost using identicalPGF/Ti butkZ the TikZ codes are indeed completely different: you can compare them in detail in the Italian version of this Time Time article [1]. Here we only want to point out the fact FigureFigure 2 2:: A A picture picture produced produced with with Geogebra GeoGebra and and that Trzeciak’s code is much more concise and ele- exportedexported into in Ti TikZk,Z, used used for for a mastera master’s degree degree thesis thesis gant, but it requires a deep knowledge of PGF pro- gramming: in fact you must first instruct PGF to GeoGebra can export figures into both PSTricks make the correct calculations for the visible and in- and TiGeogebrakZ code can(and export even intofiguresAsymptote both in PSTricks); in this visible parts of each Latitude or Longitude circles, and TikZ code (and even in Asymptote): in this article we consider only the case of TikZ, with which using appropriate PGF macros, and only after that article we consider only the case of TikZ with which all the figures shown are realized. However, as men- you can draw the circles. In our code all calculations all the proposed figures are realized, pointing out tioned above, substantially nothing changes if you are made by Geogebra, and only the drawing part is however that substantially nothing changes if you left to TikZ. preferpreferPSTPSTricksricks,, because, because, apart apart some from adaptations some adapta- and tionsa limited and some work tolimited clean work up the to code, clean everything up the code, is everythingautomatically is automatically produced. For produced. this reason For also, this only rea- 3 Some maths behind the scene sonvery also, few only fragments a few fragmentsof source code of source will be code proposed. will be GeogebraFigure 4 is: a Sphere very well with structured meridians and and powerful parallels, soft- included.In addition In to addition, this fact it it should should be noted noted that that the the wareproduced of dynamic with code geometry: exported there from are GeoGebra two different generatedcodes are code not veryis not interesting, very interesting, as they as consist it consists al- windows for 2D graphics, a window for 3D graphics, almostmost exclusively exclusively of of\draw\drawinstructions:instructions; all all needed needed a fairly complete , a probability calcula- calculationscalculations have have already already been done done by by Geogebra. GeoGebra. torthat and Trzeciak’s an algebra code window is much where more you can concise read and the ele- SomeSome time time ago ago a a new new version version of of GeoGebra Geogebra, that(Geo- coordinatesgant, but of it the requires points, a the deep equations knowledge of the of curves,PGF pro- gebrasupports Classic three-dimensional 5.0) which supports graphics, three-dimensional has been re- andgramming. so on. The In very fact important you must feature first is instruct that allPGF the to graphicsleased. Unfortunately was released. for Unfortunately, the 3D version for no exportthis 3D windowsmake the can correct interact calculations with each other: for the regarding visible our and in- A versionin a LT noEX export format into has a been LATEX yet format implemented has yet and, been problemvisible parts all what of each you latitudeobtain in or the longitude3D window circle, can using implementedin our opinion, and, this in our will opinion, not be this possible, will not at be least pos- beappropriate appropriatelyPGF transferredmacros, to and the onlymain after2D window that you sible,in a at reasonably least not in short a reasonably time. Because short time. of this Because limi- (andcan then draw exported the circles. in LA InTEX our code). code Besides all calculations that, it are oftation this limitation we decided we to decided experiment to experiment the possibility with ofthe ismade interesting by GeoGebra, to note that and Geogebra only the is drawing in any case part is directly executing a 3D to 2D projection in Geogebra “LAT X oriented”: all textual annotations are inserted possibility of directly executing a 3D to 2D projec- leftE to TikZ. and then exporting it in TikZ code: indeed each in the windows with LAT X code. tion in GeoGebra and then exporting it into TikZ E 3D figure is just an appropriate 2D projection of a Let us consider a Cartesian orthogonal system code. Indeed, each 3D figure is just an appropriate 3 Some maths behind the scene three-dimensional object. in three-dimensional space, that in Geogebra is dis- 2D projection of a three-dimensional object. GeoGebra is a very well structured and powerful pro- Taking this in mind, the first thing we tried to played in the 3D window, with an upward vertical do isKeeping the reproduction this in mind, of a the sphere first originally thing we trieddrawn to z-axis;gram call forα dynamica rotation geometry. around the There vertical are two axis different and reproduceby Tomasz is M. a sphere Trzeciak originally [4] and drawn also reproduced by Tomasz by M. βwindowsa rotation for around2D graphics, a horizontal a window axis. for The3D paral-graphics, TrzeciakKeith Wolcott [4]; it was [5]. also You reproduced can easily compare by Keith our Wolcott own lela projection fairly complete of this spreadsheet, Cartesian system a probability in a plane calcula- inpicture, [5]. Please see figure compare 3, with Trzeciak’s Trzeciak’s original one in Wolcott’s (figure 3) (thattor and in our an case algebra will window be the mainwhere2D youwindow can read of the witharticle. ours (figure 4). Geogebra),coordinates can of be the obtained, points, the for equations instance, of with the the curves, The two pictures are almost identical but the and so on. The very important feature is that all the TipreliminarykZ codes are draft, indeed December completely 27, 2017 different; 18:02 you can windows preliminary can interact draft, with December each other. 27, 2017 Regarding 18:02 our compare them in detail in the Italian version of this problem, all that is obtained in the 3D window can article [1]. Here we only want to point out the fact be appropriately transferred to the main 2D window

Three-dimensional graphics with TikZ/PSTricks and the help of GeoGebra 62 TUGboat, Volume 39 (2018), No. 1

(and then exported into LATEX code). Moreover, it Begin by plotting the 3D sphere with center the origin is interesting to note that GeoGebra is in any case and radius r and its 2D projection that is simply “LATEX oriented”; all textual annotations are inserted the circle with center the origin and again radius in the windows with LATEX code. r. Next draw the parallels and meridians simply Let us consider a Cartesian orthogonal system intersecting the sphere with appropriate planes. If, in three-dimensional space, that in GeoGebra is dis- for instance, you need five parallels they will be found played in the 3D window, with an upward vertical at the latitudes −60◦, −30◦, 0◦, 30◦, 60◦ and the z-axis; call α a rotation around the vertical axis and corresponding planes have the following equations √ β a rotation around a horizontal axis. The paral- z = r sin(−60◦); z = −r 3/2 lel projection of this Cartesian system in a plane z = r sin(−30◦); z = −r/2 (that in our case will be the main 2D window of z = r sin(0◦); z = 0 GeoGebra), can be obtained, for instance, with the . z = r sin(30◦); z = r/2 following formulas: √ ◦ ~i = − cos(α), − sin(α) sin(β) z = r sin(60 ); z = r 3/2 These planes can be plotted simply by writing the ~ −  , j = sin(α), cos(α) sin(β) equations in the input bar. Now ask GeoGebra to ~k = 0, cos(β) find the intersection circle of the planes with the sphere and choose (for instance using the mouse) where~i, ~j, ~k are the vectors of the basis. If you set the five points on each circle. After projecting these origin to the point O = (0, 0), which is preferable, you points on the 2D window, plot the conic through must create two angle sliders with the names α and them, using the specific Command; this will be the β; afterwards the basis vectors can be constructed projected parallel. Do the same for the meridians. with the following GeoGebra code: Now, after choosing the best viewing angle, highlight i = Vector[O, (− cos(α), − sin(α) sin(β))] the visible and invisible part of each ellipse. For the j = Vector[O, (sin(α), − cos(α) sin(β))] . invisible part you can decide if you want to show it or not, you can choose a broken line, a reduced k = Vector[O, (0, cos(β))] thickness, and so on. When everything is perfectly Now, if you consider a point P = (xP, yP, zP) in configured, export into TikZ (or PSTricks) and insert the 3D window, its projection will be the code in your LATEX document; it usually works 0 P = xP~i + yP ~j + zP ~k, very well and only small adaptations are normally or, in the language of GeoGebra, needed, for instance regarding the position of the labels or if you need special shading. The technique P0 = x(P) i + y(P) j + z(P) k. that we have illustrated is absolutely basic; with a If you consider instead a curve C with paramet- little experience in the use of GeoGebra, everything ric equations (f(t), g(t), h(t)), with the parameter t can be faster and further automated. appropriately included between two extremes, its 2D A point that deserves further attention from projection, always in the GeoGebra language, will what has been previously described is how to treat be the visible or invisible parts of the projected figure x0 = f(t) x(i) + g(t) x(j) + h(t) x(k) . in GeoGebra. The 3D window of the software can y0 = f(t) y(i) + g(t) y(j) + h(t) y(k) automatically handle the visible or invisible parts, These formulas allow the 2D projection of every fig- as shown in the screen shot of figure 5. ure made in the 3D window of GeoGebra. After that The projection of this picture on the 2D window you can experiment to find the best view for the produces an image where visible and invisible parts figure by changing the angles α and β, working in are plotted in the same style, as shown in figure 6; the 2D window; this is an important feature because such a figure can’t be exported as it is. in general it is very difficult to find the appropriate Now, by comparing the side by side images of viewing angle, and only trying over and over again the 3D and 2D windows, and using the Intersect can lead to the solution. Naturally not even Geo- command of Geogebra, one can correctly highlight Gebra minimizes the problem of 3D graphics as it is the visible and invisible parts of each curve and clear that those who need images of this type must finally obtain the image ready to export. It is shown have a good mathematical preparation. Nothing is in figure 7. obtained for free! Regarding the intersection of two spheres, plot- In light of these formulas let’s see in detail, as an ted in figure 1, there are no further complications example, how the sphere of figure 4 can be obtained. since the intersection circle can be found directly by

Luciano Battaia TUGboat, Volume 39 (2018), No. 1 63

Figure 7: Screenshot of the main 2D window of Geogebra ready to be exported for the production of the sphere of figure 4 Figure 5: Screenshot of the main 3D window of GeoGebra for the production of the sphere of figure 4 the following parametric equations of the spiral r cos t x(t) = √ 1 + a2t2 r sin t y(t) = √ , 1 + a2t2 −art z(t) = √ 1 + a2t2 where r is the radius of the sphere and a is a pa- rameter. It is preferable to set up r and a with sliders in GeoGebra and then choose the best values after testing different ones. The tracing of the tan- gent vectors and of the angles identified by them is straightforward. The only thing that needs special attention is the fact that plots of lines such as the one needed here can’t be drawn directly by TikZ and you need GNUPLOT Figure 6: Screenshot of the 2D projection in external software, for instance , but this Geogebra of the 3D window shown in figure 5 can be done in a straightforward way, and, in any case, GeoGebra automatically handles this problem in the export procedure! It should be noticed that PSTricks handles directly these situations. The final plot is shown in figure 8. GeoGebra and then projected on the 2D window as described. In this case we have chosen not to show 5 Polyhedra the overlapping parts of the spheres at all, in order One of the situations where GeoGebra’s interven- to obtain a more readable figure. tion is truly providential is the drawing of polyhedra and their developments; there are special routines to draw, in particular, Platonic solids and to show 4 A spiral on a sphere dynamically their development. The 2D projection of The following example requires a minimum of extra such figures is indeed very simple because you need mathematics, but no further work on the code. The only to find the correct position of the projected goal is to plot a complex spiral, with endless turns, vertices, whose three-dimensional coordinates are au- on a sphere, highlighting the property that the angle tomatically found by GeoGebra. Figure 9 shows the between the meridians and the spiral remains con- dodecahedron, while figure 10 shows a step towards stant. The best way to solve the problem is to use its development in a plane.

Three-dimensional graphics with TikZ/PSTricks and the help of GeoGebra 64 TUGboat, Volume 39 (2018), No. 1

Figure 11: The regular octahedron and its inscribed sphere. The meridians and the parallels through four ?? 4 4 preliminary preliminary draft, draft, December December 27, 27, 2017 2017 18:02 18:02 TUGboat,TUGboat, Volume Volume 0 0 (9999), (9999), No. No. 0 0 Figure 8: A spiral on a sphere of the eight tangent points are highlighted sliderssliders in in Geogebra Geogebra and and then then choose choose the the best best values values afterafter testing testing different different ones. ones. The The tracing tracing of of the the tan- tan- Even more important is the fact that the draw- gentgent vectors vectors and and of of the the angles angles identified identified by by them them is is ing of the curves described by the vertices during straightforward.straightforward. development is relatively straightforward. In Geo- TheThe only only thing thing that that needs needs special special attention attention is is the the Gebra every vertex can leave a track during the de- factfact that that plots plots of of lines lines like like the the one one needed needed here here can’t can’t velopment and it is possible to project this track in bebe drawn drawn directly directly by byTiTikZkZandand you you need need external external the 2D window; it is now very simple to plot, using a softwares,softwares, for for instance instanceGNUPLOTGNUPLOT,, but but this this can can be be GeoGebra macro, a Bezier curve, maybe at intervals, donedone in in a a straightforward straightforward way, way, and, and, in in any any case, case, that approximates this track. Exporting this Bezier GeogebraGeogebra automatically automatically handles handles this this problem problem in in the the curve is a standard procedure. You can see an exam- exportexport procedure! procedure! It It should should be be noticed noticed that thatPSTricksPSTricks pleTUGboat, in figure Volume 12; the curve0 (9999), Γ is No. a complex 0 preliminary curve, while draft, December 27, 2017 18:02 ? 5 FigureFigureFigure 5 9: 5:: The The The regular regular regular dodecahedron dodecahedron dodecahedron handleshandles directly directly these these situations. situations. The The final final plot plot is is all the others are simply circle arcs. It is in principle shownshown in in figure figure 4. 4. possiblethe parametric to find equations the parametric of Γ, but equations the use of Γ,Geoge- but and with variable radius. The intersection of this thebra usecapabilities of GeoGebra makes capabilities everything makes extremely everything simple, sphere with the sides of the polyhedron gives rise extremelywithout any simple, calculation. without any calculation. to regular pentagons and hexagons: the latter be- come regular when the radius of the sphere is exactly 1/3 of the side of the polyhedron and this situation αα Γ αα corresponds to the truncated icosahedron. Using Ge- CC C ogebra it is very easy again to document this process: BB B simply project the truncation at the desired stage and then export it. αα A O AA

FigureFigureFigure 6 10: 6: The: The The regular regular regular dodecahedron: dodecahedron: dodecahedron: a a step step towards towards itsitsits development development development in in in a a a plane plane plane Figure 128:: One One of of the the different different plane plane developments developments of of FigureFigure 4: 4: A A spiral spiral on on a a sphere sphere the regular octahedron. The curves described by the Don’t be fooled by the apparent simplicity of vertices during development are highlighted 55 Polyhedra Polyhedra these pictures. The hand calculation of the coor- dinates of the vertices of the dodecahedron is not Once you have have built built the the outline outline of of a adodecahe- dodeca- OneOne of of the the situations situations where where Geogebra’s Geogebra’s intervention intervention easy at all, and, even worse, their position during hedrondron in in the the3D3Dwindowwindow of Geogebra, of GeoGebra, you youcan also can isis truly truly providential providential is is the the drawing drawing of of polyhedra polyhedra development! alsoexperiment experiment interesting with interesting derived figures. derived An figures. example An andand their their developments: developments: there there are are special special routines routines Also, the drawing of the inscribed and circum- exampleis given inis given figure in 9, figure where 13, the where Leonardo’s Leonardo’sDodeca-Do- toto draw draw in in particular particular Platonic Platonic solids solids and and to to show show scribed spheres is straightforward and you can see decahedronhedron Planum Planum Vacuum Vacuumis represented:is represented. once Once more Figure 10: Outline of the truncation of the dynamicallydynamically their their developments. developments. The The2D2Dprojectionprojection an example concerning the octahedron in figure 11. morethe calculation the calculation of the of position the position of the verticesof the vertices of this icosahedron starting from the vertices ofof such such figures figures is is indeed indeed very very simple simple because because you you need need figure is almost straightforward in Geogebra, but it onlyonly to to find find the the correct correct position position of of the the projected projected could be very difficult otherwise. Figure 11 shows the final result. Nothing new Luciano Battaia vertices,vertices, whose whose three-dimensional three-dimensional coordinates coordinates are are is required in Geogebra to obtain this last figure: it automaticallyautomatically found found by by Geogebra. Geogebra. Figure Figure 5 5shows shows the the is exactly the same construction used for the pre- dodecahedron,dodecahedron, while while figure figure 6 6 shows shows a a step step towards towards vious figure 10, only with a different radius for the its development in a plane. its development in a plane. FigureFigure 7: 7: The The regular regular octahedron octahedron and and its its inscribed inscribed truncating spheres. Don’tDon’t be be fooled fooled by by the the apparent apparent simplicity simplicity of of sphere.sphere. L’ottaedro L’ottaedro regolare regolare e e la la sfera sfera inscritta. inscritta. The The thesethese pictures: pictures: the the hand hand calculation calculation of of the the coordi- coordi- meridiansmeridians and and the the parallels parallels through through four four of of the the eight eight natesnates of of the the vertices vertices of of the the dodecahedron dodecahedron is is not not easy easy thethe tangent tangent points points are are highlighted highlighted atat all, all, and, and, even even worse, worse, their their position position during during devel- devel- opment!opment! AlsoAlso the the drawing drawing of of the the inscribed inscribed and and circum- circum- isis possible possible to to project project this this track track in in the the2D2Dwindow:window: it it scribedscribed spheres spheres is is straightforward straightforward and and you you can can see see isis now now very very simple simple to to plot, plot, using using a a Geogebra Geogebra macro, macro, a a anan example example concerning concerning the the octahedron octahedron in in figure figure 7. 7. BezierBezier curve, curve, maybe maybe at at intervals, intervals, that that approximates approximates EvenEven more more important important is is the the fact fact that that the the draw- draw- thisthis track. track. Exporting Exporting this this Bezier Bezier curve curve is is a a standard standard inging of of the the curves curves described described by by the the vertices vertices during during procedure.procedure. You You can can see see an an example example in in figure figure 8: 8: the the developmentdevelopment is is easy easy enough. enough. In In Geogebra Geogebra every every ver- ver- curvecurve Γ Γ is is a a complex complex curve, curve, while while all all the the others others are are textex can can leave leave a a track track during during the the development development and and it it simplysimply circle circle arcs arcs .It .It is is in in principle principle possible possible to to find find Figure 9: Dodecahedron Planum Vacuum, in Leonardo’s style Figure 11: The truncated icosahedron preliminarypreliminary draft, draft, December December 27, 27, 2017 2017 18:02 18:02 preliminary preliminary draft, draft, December December 27, 27, 2017 2017 18:02 18:02 As is well known, the football is simply the pro- 6 The football jection of the truncated icosahedron on the circum- Once you have acquired familiarity with the Platonic scribed sphere. This can can be achieved in different solids, you can experience the expansion of the tech- ways. In our opinion the simplest one is to project nique to other solids, i.e. the Archimedean solids. each side of the polyhedron onto the sphere by means These can be obtained in various ways from the Pla- of a parametric equation and then again to project tonic ones, for example by truncation starting from the obtained arc in the 2D window. Following we de- the vertices. In figure 10 we show the case of the scribe the outline of this technique. Given a segment icosahedron: given the Platonic solid, we consider, AB with bounds (xA, yA, zA) and (xB, yB, zB), write for each vertex, a sphere centered at the vertex itself the standard parametric equations of the segment

preliminary draft, December 27, 2017 18:02 preliminary draft, December 27, 2017 18:02 TUGboat, Volume 0 (9999), No. 0 preliminary draft, December 27, 2017 18:02 ? 5 the parametric equations of Γ, but the use of Geoge- and with variable radius. The intersection of this bra capabilities makes everything extremely simple, sphere with the sides of the polyhedron gives rise without any calculation. to regular pentagons and hexagons: the latter be- come regular when the radius of the sphere is exactly Γ 1/3 of the side of the polyhedron and this situation corresponds to the truncated icosahedron. Using Ge- TUGboat, VolumeC 0 (9999), No. 0 preliminary draft, December 27, 2017 18:02 ? 5 B ogebra it is very easy again to document this process: simply project the truncation at the desired stage the parametric equations of Γ, but the use of Geoge- and then with export variable it. radius. The intersection of this bra capabilities makesA everythingO extremely simple, sphere with the sides of the polyhedron gives rise without any calculation. to regular pentagons and hexagons: the latter be- TUGboat, Volume 0 (9999), No. 0 preliminary draft,come December regular 27, when 2017 the 18:02 radius of the sphere is exactly ? 5 Γ 1/3 of the side of the polyhedron and this situation corresponds to the truncated icosahedron. Using Ge- C Figurethe parametric 8: One of equations the different of Γ, planeB but the developments use of Geoge- of ogebraand with it is variable very easy radius. again to The document intersection this process: of this thebra regular capabilities octahedron. makes Theeverything curves described extremely by simple, the simplysphere withproject the the sides truncation of the polyhedron at the desired gives stage rise verticeswithout during any calculation. development are highlighted andto regular then export pentagons it. and hexagons: the latter be- A O come regular when the radius of the sphere is exactly Once you have built the outlineΓ of a dodecahe- 1/3 of the side of the polyhedron and this situation dron in the 3D window of Geogebra, you can also corresponds to the truncated icosahedron. Using Ge- C experiment interesting derivedB figures. An example ogebra it is very easy again to document this process: is given in figure 9, where the Leonardo’s Dodeca- simply project the truncation at the desired stage TUGboat, Volume 39 (2018), No. 1 65 hedronFigure Planum 8: One of Vacuum the differentis represented: plane developments once more of Figureand then 10 export: Outline it. of the truncation of the thethe regularcalculation octahedron. of theA position TheO curves of the described vertices by of the this icosahedron starting from the vertices figureofvertices this is figure during almost is development almost straightforward straightforward are highlighted in Geogebra, in GeoGebra, but it couldbut it be could very be difficult very difficult otherwise. otherwise. Figure 11 shows the final result. Nothing new Once you have built the outline of a dodecahe- is required in Geogebra to obtain this last figure: it dron in the 3D window of Geogebra, you can also is exactly the same construction used for the pre- experimentFigure 8: One interesting of the different derived plane figures. developments An example of vious figure 10, only with a different radius for the isthe given regular in octahedron. figure 9, where The curvesthe Leonardo’s describedDodeca- by the truncating spheres. vertices during development are highlighted hedron Planum Vacuum is represented: once more Figure 10: Outline of the truncation of the the calculation of the position of the vertices of this icosahedron starting from the vertices figureOnce is almost you have straightforward built the outline in Geogebra, of a dodecahe- but it coulddron in be the very3D difficultwindow otherwise. of Geogebra, you can also Figure 11 shows the final result. Nothing new experiment interesting derived figures. An example is required in Geogebra to obtain this last figure: it is given in figure 9, where the Leonardo’s Dodeca- is exactly the same construction used for the pre- hedron Planum Vacuum is represented: once more Figurevious figure 1410:: Outline Outline 10, only of of with the the truncation truncation a different of of radius the the for the the calculation of the position of the vertices of this icosahedrontruncatingicosahedron spheres. starting starting from from the the vertices vertices figure is almost straightforward in Geogebra, but it could be very difficult otherwise. Figure 11 shows the final result. Nothing new is required in Geogebra to obtain this last figure: it Figure 913:: Dodecahedron Dodecahedron Planum Planum Vacuum, Vacuum, in in is exactly the same construction used for the pre- Leonardo’s style vious figureFigure 10, 11 only: The with truncated a different icosahedron radius for the truncating spheres. As is well known, the football is simply the pro- 6 The football jection of the truncated icosahedron on the circum- Once you have acquired familiarity with the Platonic scribed sphere. This can can be achieved in different solids, you can experience the expansion of the tech- ways. In our opinion the simplest one is to project nique to other solids, i.e.,i.e. the Archimedean solids. each side of the polyhedron onto the sphere by means TheseFigure can 9:be Dodecahedron obtained in Planum various Vacuum, ways from in the Pla- of a parametric equation and then again to project tonictonics,Leonardo’s ones, for examplestyle for example by truncation by truncation starting starting from from the the obtainedFigure arc 1511 in:: Thethe The2D truncated truncatedwindow. icosahedron icosahedron Following we de- vertices.the vertices. In figure In figure 14 we 10 show we the show case the of casethe icosahe- of the scribe the outline of this technique. Given a segment icosahedron:dron; given the given Platonic the Platonic solid, we solid, consider, we consider, for each AB withAs is bounds well known, (xA, y theA, zA football) and (x isB simply, yB, zB), the write pro- vertex,for6 each The a vertex, football sphere a spherecentered centered at the at vertex the vertex itself itself and theitself:jection standard of the parametric truncated icosahedron equations of on the the segment circum- with variable radius. The intersection of this sphere  Once you have acquired familiarity with the Platonic scribed sphere. f(t) This = xA can+ ( canxB − bex achievedA)t in different withpreliminarysolids,Figure the you 9 sides: Dodecahedron can draft, of experience the December polyhedron Planum the 27, expansion gives Vacuum,2017 rise 18:02 of into the regular tech- ways.P(t In): preliminary ourg( opiniont) = y draft,A the+ (y simplest DecemberB − yA)t one, 27,0 ≤ is 2017t to≤ project1 18:02. pentagonsniqueLeonardo’s to other and style hexagons. solids, i.e. The the latter Archimedean become regular solids. each sideFigure ofh the(t) 11polyhedron =:z TheA + truncated (zB onto− zA the) icosahedront sphere by means when the radius of the sphere is exactly 1/3 of the These can be obtained in various ways from the Pla- Thenof a parametric find the norm equation of P(t and): then again to project sidetonic of ones, the polyhedron for example and by this truncation situation starting corresponds from the obtainedAs is well arc known, in the the2D footballwindow. is Following simply the we pro- de- 6 The football p 2 2 2 tothe the vertices. truncated In figure icosahedron. 10 we show Using the GeoGebra case of the it scribejection the of|| theoutlineP(t) truncated|| = of thisf (t technique. icosahedron) + g (t) + Givenh on(t the). a segment circum- is very easy again to document this process; simply icosahedron:Once you have given acquired the familiarityPlatonic solid, with we the consider, Platonic TheABscribedwith projection sphere. bounds of This (thexA can, segment yA, can zA) be andAB achievedon (xB the, yB unit, in zB different), sphere write projectforsolids, each you the vertex, can truncation experience a sphere at centered the the desired expansion at the stage vertex of and the itselfthen tech- hasways.the thestandard In following our opinion parametric parametric the simplestequations equations: one of theis to segment project exportnique to it. other solids, i.e. the Archimedean solids. each side of the polyhedron onto the sphere by means P(t) ThesepreliminaryFigure can be 15 draft, obtained shows December the in variousfinal 27, result. 2017 ways 18:02Nothing from the new Pla- of a parametric preliminary equationQ( draft,t) = and December then. again 27, 2017 to project 18:02 istonic required ones,for in GeoGebra example by to truncation obtain this starting last figure. from the obtained arc in the 2D||window.P(t)|| Following we de- Itthe is vertices. exactly the In same figure construction 10 we show used the forcase the of pre- the Atscribe this the point outline there of this is nothing technique. to Givendo but a segmentuse the viousicosahedron: figure 14, given only the with Platonic a different solid, radius we consider, for the alreadyAB with considered bounds (x parallelA, yA, zA projection) and (xB, form yB, z3DB),to write2D truncatingfor each vertex, spheres. a sphere centered at the vertex itself tothe obtain standard a 2D parametriccurve. The finalequations result of for the the segment football As is well known, the football is simply the is shown in figure 16. projectionpreliminary of draft, the truncated December icosahedron 27, 2017 18:02 on the cir- One preliminary last practical draft, tip: December the TikZ code 27, 2017 of a figure 18:02 cumscribed sphere. This can be achieved in different like figure 16 is very long and complex (about 250 ways. In our opinion the simplest one is to project rows!) and it is useful to export it from GeoGebra each side of the polyhedron onto the sphere by means one piece at a time, and not all together, especially if of a parametric equation and then again to project you need to paint the different parts in different ways the obtained arc in the 2D window. Following we de- (in our figure only black sphere pentagons and white scribe the outline of this technique. Given a segment sphere hexagons). It will be simpler to correctly AB with bounds (xA, yA, zA) and (xB, yB, zB), write fill the various parts of the figure, or to check if the standard parametric equations of the segment everything works correctly.

Three-dimensional graphics with TikZ/PSTricks and the help of GeoGebra 66 TUGboat, Volume 39 (2018), No. 1

{\pgfmathsetlengthmacro{\h}{(\I-1)/#3*#2} \pgfmathsetlengthmacro{\r}{sqrt(pow(#2,2) -pow(\h,2))} \pgfmathsetmacro{\c}{(\I-0.5)/#3*100} \draw[InColor!\c!OutColor, line width=\r,#1] #6; } }

Figure 16: The football obtained by the projection of the truncated icosahedron on the circumscribed sphere

A simple but interesting application of this tech- nique is shown in figure 17 where we have projected on the circumscribed sphere the regular tetrahedron. This figure solves an interesting problem: is it possi- ble to cut an apple into four equivalent parts in an Figure 18: The molecule of Buckminsterfullerene uncommon way? In a figure like this, in order to hide the invisible parts you need only to plot the rear parts first. As usual, you can easily locate them using the GeoGebra figure.

7 Conic and spherical sections A very relevant problem for people interested in 3D graphics is the drawing of plots concerning conic sections. We only show some examples without ex- tended details; the technique to be used is now fa- miliar because, naturally, the involved curves are conics that GeoGebra can deal with using standard commands. Figure 19 illustrates the two series of circular Figure 17: An apple cut in four parts in a non sections in an oblique cone; the sections parallel to standard way the basis and the subcontrary sections, as considered by Apollonius. The complexity of this figure is due to Before ending this “sport” section of our arti- mathematical calculations; you must find the correct cle we present a simple figure obtained from the angle for the plane that produces the subcontrary truncated icosahedron: the molecule of the Buck- section, and the best way to do this is the original minsterfullerene. In this case we have simply re- Apollonius description. placed the segments that make up the sides of the Figure 20 shows how to section a cone in order polyhedron by tubes and the vertices by shaded to obtain a hyperbola. The technique to obtain such spheres. The following code for the tubes is taken a figure is simple in GeoGebra; after plotting the from https://tex.stackexchange.com: entire cone and the hyperbola on the cone you can \newcommand{\Tube}[6][]% hide, directly in GeoGebra, one of the two parts, {\colorlet{InColor}{#4} leaving only the remaining one. After exporting the \colorlet{OutColor}{#5} code you can shift, for instance, the right part using \foreach \I in {1,...,#3} the following very standard code:

Luciano Battaia TUGboat, Volume 39 (2018), No. 1 67

Figure 19: The two series of circular sections that can TUGboat, Volume 0 (9999), No. 0 preliminary draft,be December obtained in27, an 2017 oblique 18:02 cone ? 7 Figure 21: Intersection between a cylinder and a ?sphere 8 preliminary draft, December 27, 2017 18:02 TUGboat, Volume 0 (9999), No. 0

7 Conic and spherical sections A very relevant problem for people interested in 3D graphics is the drawing of plots concerning conic sec- tions. We only show some examples without detailed infos: the technique to be used is now straightforward because, naturally, the involved curves are conics that Geogebra can deal with standard commands. Figure 15 illustrates the two series of circular sections in an oblique cone: the sections parallel to the basis and the subcontrary sections, as considered by Apollonius. The complexity of this figure is due to mathematical calculations: you must find the correct angle for the plane that produces the subcontrary Figure 16: Section of a cone to obtain a hyperbola section, and the best way to do this is the original Figure 20: Section of a cone to obtain a hyperbola Figure 20: Reproduction of the solar system Apollonius description. FigureFigure 18 22:: The The compound compound of of five five tetrahedra tetrahedra originally drawn by Kepler in 1596: detail of the central part \begin{scope}[xshift=2.4cm] code of the second part Mysterium Cosmographicum: they deal with a pic- h\end{scope} i The first figure is the compound of five tetra- turehedra concerning, which is the one solar of the system five regular as known polyhedral in those ical paper. This technique paired with pgf-plots or The last figure of this section, figure 21, is some- dayscompounds. and consist It can of the be constructed five platonic by solids arranging inscribed five the corresponding packages for the PSTricks family what more complicated, because GeoGebra can’t onetetrahedra into the insideother, while a dodecahedron, the inscribed/circumscribed having no com- allows the production of complex scientific books A handle directly (at least at the moment) the inter- spheresmon vertex. to each The polyhedron correct construction contain the of orbits such a of figure the using LTEX and without any external software. section between a cylinder and a sphere. Anyhow, sixrequires planets, full earth attention, included, in particular with the sun to understand at the cen- As already mentioned, particularly when draw- the intersection curve is a Vivianis’s window and ter.which As are in the the original actual sides by Kepler and which we propose instead both are ing complex figures, a somewhat deep knowledge of the parametric equations can be found easily in all theonly set fake of allsides, the that platonic must solids not be and highlighted a detail of in the the Geogebra is required, but, in our experience, the books of curves. The rest of the construction does fourfigure. interior Furthermore, spheres within this the case corresponding it is better to three hide learning curve of Geogebra is much flatter than that not require special attention; there are only parts of polyhedra.completely the non-visible part of the figure. of TikZ and furthermore the use of Geogebra offers a cylinder and of a sphere. The second and third figures are reproductions the numerous advantages we have described in this of originals by Kepler, published in the 1596 in Mys- article. 8 Some more advanced images terium Cosmographicum. They deal with a picture Naturally there is no rose without thorns and it Figure 15: The two series of circular sections that can is not possible to achieve the effects we have described be obtained in an oblique cone FigureThe technique 17: Intersection based on between exports a from cylinder GeoGebra and a can concerning the solar system as known in those times spherealso handle more complicated figures, but, naturally, and consist of the five Platonic solids inscribed one without hard work and experimentation. a somewhat advanced knowledge of GeoGebra is re- into the other, while the inscribed/circumscribed References Figure 16 shows how to section a cone in order to quired for this. In our opinion the effort is worth the spheres to each polyhedron contain the orbits of the obtain a hyperbola. The technique to obtain such a [1] Luciano Battaia. Grafica 3D con Geogebra e 8candle Some because more what advanced you can images obtain is very interest- six planets, earth included, with the sun at the cen- figure is simple in Geogebra: after plotting the entire ing. We give three images as examples. ter. As in the original by Kepler we propose both TikZ. ArsTEXnica, 22:50–63, 2016. cone and the hyperbola on the cone you can hide, The technique based on exports from Geogebra can [2] Claudio Beccari. The unknown picture environ- directly in Geogebra, one of the two parts, leaving also handle more complicated figures, but, naturally, ment. ArsTEXnica, 11:57–64, 2011. a somewhat advanced knowledgeThree-dimensional of Geogebra is re- graphics with TikZ/PSTricks and the help of GeoGebra only the remaining one. After exporting the code [3] Agostino De Marco. Illustrazioni tridimensionali you can shift, for instance, the right part using the quired for this: in our opinion the effort is worth the con Sketch/LATEX/PSTricks/Tikz nella didattica following very standard code: candle because what you can obtain is very interest- della Dinamica del Volo. ArsTEXnica, 4:51–68, ing. We only set two images up as an example. 2007. \begin{scope}[xshift=2.4cm] The first figure is the compound of five tetrahe- https://www.texample. dra, that is one of the five regular polyhedral com- [4] Tomasz M. Trzeciak. \end{scope} Figure 19: Reproduction of the solar system net/tikz/examples/map-ptojections/, 2008. pounds. It can be constructed by arranging five originally drawn by Kepler in 1596 The last figure of this section, figure 17, is some- tetrahedra inside a dodecahedron, having no com- [5] Keith Wolcott. Three-dimensional graphics with PGF/TikZ. TUGboat, 33(1):102–113, 2012. what more complicated, because Geogebra can’t han- mon vertex. The correct construction of such a figure As with figure 14, one of the secrets for drawing dle directly (at least for the moment) the intersection requires full attention in particular to understand correctly is to start from the backs and to finally Luciano Battaia between a cylinder and a sphere: anyhow the inter- which are the actual sides and which instead are draw the front parts of the figure.  section curve is a Vivianis’s window and their para- only fake sides, that must not be highlighted in the Via Garibaldi 4 San Giorgio Richinvelda, PN 33095 metric equations can be easily found in all curve’s figure. Besides that in this case it is better to hide 9 Conclusion books. The rest of the construction does not require completely the non visible part of the figure. Italy We believe that the proposed technique can be ad- luciano.battaia (at) unive dot special attention: there are only parts of a cylinder The second and third figures figure are reproduc- vantageously used for the production of a large part it and of a sphere. tions of originals by Kepler, published in the 1596 in of the geometric type figures required in a mathemat- http://www.batmath.it preliminary draft, December 27, 2017 18:02 preliminary draft, December 27, 2017 18:02 preliminary draft, December 27, 2017 18:02 preliminary draft, December 27, 2017 18:02 68 TUGboat, Volume 39 (2018), No. 1

the set of all the Platonic solids and a detail of the 9 Conclusion four interior spheres with the corresponding three We believe that the proposed technique can be ad- polyhedra. vantageously used for the production of a large part of the geometric type figures required in a mathemat- ical paper. This technique paired with pgf-plots or the corresponding packages for the PSTricks family allows the production of complex scientific books using LATEX and without any external software. As already mentioned, particularly when draw- ing complex figures, a somewhat deep knowledge of GeoGebra is required, but, in our experience, the learning curve of GeoGebra is much flatter than that of TikZ; the use of GeoGebra also offers the numerous advantages we have described in this article. Naturally there is no rose without thorns and it is not possible to achieve the effects we have described without hard work and experimentation. References Figure 23: Reproduction of the solar system, as [1] Luciano Battaia. Grafica 3D con Geogebra originally drawn by Kepler in 1596 e TikZ. ArsTEXnica, 22:50–63, 2016. guitex.org/home/images/ArsTeXnica/AT022/ battaia.. [2] Claudio Beccari. The unknown picture environment. ArsTEXnica, 11:57–64, 2011. tug.org/TUGboat/tb33-1/tb103becc-picture. pdf. [3] Agostino De Marco. Illustrazioni tridimensionali con Sketch/LATEX/PSTricks/TikZ nella didattica della Dinamica del Volo. ArsTEXnica, 4:51–68, 2007. guitex.org/home/it/numero-4. [4] Tomasz M. Trzeciak. texample.net/tikz/ examples/map-projections/, 2008. [5] Keith Wolcott. Three-dimensional graphics with PGF/TikZ. TUGboat, 33(1):102–113, 2012. tug.org/TUGboat/tb33-1/tb103wolcott.pdf. Figure 24: Reproduction of the solar system originally drawn by Kepler in 1596: detail of the Luciano Battaia  central part Via Garibaldi 4 San Giorgio Richinvelda, PN 33095 As with figure 18, one of the secrets for drawing Italy correctly is to start from the back and to end by luciano.battaia (at) unive dot it drawing the front parts of the figure. http://www.batmath.it

Luciano Battaia