Home
User Guide
Contents
1. Polygon Polygon MMM Create a polygon defined by n points The user selects n 1 points defining the polygon submits The first and last ones are the same point it indicates to DR GEO the selection is over Mobile point can be added on polygon but it is not possible to compute an intersection with another line However geometric transformation of polygon are allowed Polygon regular Regular polygon Create a regular polygon defined by two points and a numeric value The user selects its center one vertex and a value indicating the number of vertices If the value selected is not an integer it is truncated to the next lower integer 1 1 3 Transformation tools Reflection Reflection M Transform an object by a reflection The user clicks on the object to transform and the axis straight line of the reflection When the object to transform is a straight line the first clicked is the axe of the reflection Symmetry symmetry Transform an object by a central symmetry The user clicks on the object to transform and the centre of symmetry a point When the object to transform is a point the first clicked is the centre of the symmetry Translation Translation mm Transform an object by translation The user clicks on the object to transform and a vector When the object to transform is a vector the first clicked is the vector of translation 8 CHAP
2. 4 1 Workspaca J a a a a a a a 75 Debugger M 78 7 1 3 nspectorl Bo 78 Introduction Preliminary DR GEO permits its users to create geometric figures called sketches within Dr Geo and to manipulate them interactively observing assigned geometric constraints It also offers a gentle path into programming DR GEO is usable in teaching situations from the primary to advanced levels Its user interface is designed as a harmonious combination of simplicity and ease of use with advanced capabilities The DR GEO user interface under the form of great simplicity allows the beginner to get acquainted very quickly with the basic functions of the software Then as the user progresses the more advanced aspects of the interface and the capabiities of DR GEOwill become apparent such as multiple methods of construction of each kind of object macro construction multiple recording scripts Smalltalk sketches and inheritance of Smalltalk in DR GEO These advanced features generate little overload on the interface which is why DR GEO is very pleasant for use in primary education however they also make it very interesting for use in high school and university In the following sections we explain the basic tools Then the advanced features are presented in detail We begin with a blank sketch Open Dr Geo revealing a menu bar a tool bar and the welcome message Welcom
3. in order not to overload the user s perception with background constructions Once executed DR GEO gives the following sketch The hypotenuse length of each triangle is the square root of an integer in the interval 2 5 52 68 CHAPTER 6 DIDACTIC APPLICATIONS Figure 6 7 Teodoro spiral The same spiral with intermediate items shown exposes how difficult it will be to hand construct such a sketch Figure 6 8 Teodoro spiral with hidden item revealed As a bonus here is an animated version of the previous Smalltalk sketch To do this we send to the canvas the messages do and update They are documented in the chapter 4 27 Note the use of the class Delay to slow down the construction sketch triangle delayl sketch DrGeoCanvas new fullscreen triangle 1 p2 p3 n 51 82 53 perp circle p4 51 sketch segment to p2 S2 sketch segment p2 to p3 color Color red s3 sketch segment p3 to pl perp sketch perpendicular s3 at p3 circle sketch circleCenter p3 to p2 6 4 BARAVELLE SPIRAL 69 p4 sketch altIntersection0f circle and perp sketch update Delay forMilliseconds 200 wait perp hide circle hide p4 hide gt 0 ifTrue triangle value pi value p3 value p4 value n 1 sketch do triangle value 000 value 100 value 1 1 value 50 6 4 Baravelle spiral As we saw previously in Smalltalk sketches it is easy to construct intuit
4. 1 center 004 factor 5 02 CHAPTER 5 DR GEO SMALLTALK SKETCH transformed item canvas symmetry item center centre item point segment line ray vector circle arc polygon centre point or coordinates symmetry centre gt transformed object Example canvas a canvas DrGeoCanvas new a canvas point 4 2 canvas symmetry center 000 item point segment line ray vector circle arc polygon axe line symmetry axis gt transformed object Example canvas a d polygon canvas DrGeoCanvas new a canvas polygon 000 200 302 004 d canvas line 1 1 to 4 1 canvas reflect axis d transformed item canvas translate item vector vector item point segment line ray vector circle arc polygon vector vector or coordinates gt transformed object Example canvas u a canvas DrGeoCanvas new u canvas vector canvas point 101 to canvas point 302 a canvas translate canvas point 201 vector u Example canvas u canvas DrGeoCanvas new a canvas translate canvas point 201 vector 201 Locus of a point locus canvas locusOf when m m mobile point on a line c fixed point depending on the mobile point m gt locus Example canvas locusOf c when mobile Vector lt vector gt canvas vector to o point or coordinates vector origin e point or coordinates v
5. The locus tool 9995 Lines gt Locus gives the curve after selecting our two points Slope at a point of the function s curve We calculate an approximation of the slope at a given point thus f x 0 001 f x i 0 001 This is directly translated in the script slope with a single argument the point at which to approximate the slope slope item Compute the slope at the given x point position for myFunction La f self myFunction X item point x f value x 0 001 f value x 0 001 Next we insert this script in the construction Note e The declaration of temporary variables f x As explained variables are not typed so only the name is required e A reference to block of code in a variable f self myFunction The symbol to assign a value to a variable is e The parenthesis Smalltalk has no concept of operator priority in fact operators do not exist in this language The reader is encouraged to study the section about Smalltalk messages in the book Pharo Example Calculate and display the tangent to a curve To construct our tangent we need two points one on the curve we have it already and a second one on the line For this last one we use the previously calculated slope Let s write second script computing this second point s coordinates pointN item Given an initial point calculate the coordinates of a point on the tangent px p self slop
6. The mouse wheel offers this same service press simultaneously the keyboard key to speed up the scaling 1 2 3 Moving an object a Ta v An object is moved by clicking and dragging with the mouse The whole sketch is then recomputed and redrawn to respect the constraints specified Almost all geometric objects can be moved If necessary DR GEO moves the associated free points For example when the user drags a line defined by two points the points are moved simultaneously In this mode it is possible to change the nature of a point from e a free point on the plane e free point on a curve e intersection point to a point as e free point on the plane e a free point on a curve e an intersection point For example transforming a free point on the plane into an intersection point However there is one constraint it is not possible to mutate a point toward a younger line as free on the line or intersection with the line Younger line means created chronologically after the point 14 CHAPTER 1 BASIC FUNCTIONALITY Pressing the keyboard key while grabbing a point will display a balloon help text about the point you can mutate and the possible destinations Pressing down the Shift key you can drag and change the nature of free point or intersection point Figure 1 10 Pressing Shift to mutate a point 1 2 4 Merging points Two free points can be merged to do so drag one point over the second
7. canvas canvas DrGeoCanvas new a canvas point 105 canvas freeValue 4 canvas circleCenter radius canvas circleCenter 404 radius 5 Arc arc canvas arc to p2 to p3 pi point or coordinates 1 extremity of the arc p2 point or coordinates representing a point on arc p3 point or coordinates 2 extremity of the arc arc defined by its extremities and a point Example canvas canvas DrGeoCanvas new a canvas point 1 5 b canvas point 005 canvas arc a to b to 1 Q 2 arc canvas arcCenter 0 from A to B 0 point or coordinates centre of the arc A point or coordinates origin of the arc B point or coordinates so the angle is arc defined by its centre and angle AOB Example canvas a b canvas DrGeoCanvas new a canvas point 105 b canvas point 005 canvas arcCenter a from b to 1 2 Polygon polygon canvas polygon collection collection collection of points or coordinates summits of the polygon gt polygon defined by its summits Example 5 2 REFERENCE METHODS FOR THE DR GEO SMALLTALK SKETCH ol canvas b canvas DrGeoCanvas new b canvas point 103 canvas polygon 1102 b 000 d lt polygon gt canvas regularPolygonCenter center vertex summit sides number center point or coordinates centre of the polygon summit point or
8. 2 1 The DR GEOsession dialog box In this dialog the list of all active documents is presented in column Each line is prefixed with a tag Fig or Macro according to the document type the second part is the name of the document As for now a session knows about two types of document 2D interactive sketch and macro construction The user selects the documents to integrate in the session then provides a name for the composite file and clicks The menu File gt Save multiple is the only method for saving a macro construction in a file 2 5 Save a macro construction To save one or several macro constructions in a file proceed the same way as for saving a session multiple save From the dialog box to save a session select one or several macro construction to save then input the file name That s all Therefore it is possible to build macro construction libraries one per file or several per file following a given theme 2 6 Open a file Whenever the user saved an individual sketch or a session in a file the procedure to open it is the same from the menu File gt Open If the session contains macro constructions they are automatically added to the macro menus and player ready to use in any existing DR GEO window Part Il Advanced functionalities Introduction In this part we present features to extend DR GEO capabilities or to adapt it to a given pedagogical situation The first feature i
9. 3 2 Play a macro construction 4 6 4 42S Neo SSH SDR 305 d deos 3 2 1 With the dialog box 3 2 2 With the macro construction menul 4 Dr Geo Smalltalk script 4 1 Script by 4 1 1 Script without parameter 4 1 2 Script with one input parameter 4 1 3 Script with two input parameters 4 CONTENTS CT 33 8 AUN RU 36 4 2 1 Math Item 36 D cub oe eee ae oe hee eee eee oe ee eee 37 ee ee ee ee PME 38 ee ee ee 39 228 DERMEI amp s g ek hd RE Rex BEG 40 om 39 Cee eee eee ee ee ee eee ee 40 e ee epee RS RS URP EUN SU 40 A eee eee eee ee ee 41 5 Dr Geo Smalltalk sketch 43 TOTNM TM 43 5 2 Reference methods for the DR GEO Smalltalk sketch A 45 5 2 1 Various messages D 45 x 55 Leu iM N D 58 A 58 5 3 1 Animate a figurel 4 58 5 3 2 Sierpinski triangle Wy B 59 Applications 61 6 Didactic applications 63 NM oou 9359 xk ROS 63 TIPPS ASS 64 63 Irrational numbers m Noe RR 66 6 4 Baravelle spiralf WW Nee ee 69 ev Nou eSI x 70 6 6 rclculus NN 71 75 ee RS So vss oou ee ES RUBORE eR 75
10. Example item center Q lt float gt item radius item circle or arc radius of the circle or arc Example item radius H float item length item circle arc or polygon gt length of the circle arc or polygon Example l arc length 4 2 7 Value float item valueltem item value gt value of this item Example 1 item2 valueltem 2 item2 valueltem ni n2 D B item valueltem v H ct D Eh lt 20 c me ct v decimal number Action modify the value of a free value item 4 2 REFERENCE METHODS FOR DR GEO SCRIPTS Example item valueltem 5 2 item value aPoint coordinates x y of a point Action displace at the screen the position of a value item Example item position 0 502 4 2 8 Angle integer angle degreeAngle angle angle oriented or geometric gt measure of this angle item in degrees Example anglei al degreeAngle lt float gt angle radianAngle angle angle oriented or geometric gt measure of this angle item in radians Example anglei al radianAngle 41 42 CHAPTER 4 DR GEO SMALLTALK SCRIPT lt S i Chapter 5 Dr Geo Smalltalk sketch DR GEO Smalltalk sketches DSS are sketches entirely defined in the Smalltalk lan guage This is not about constructing a sketch with the DR GEO graphical interface but about describing
11. How to place a point by specifying its coordinates possibility is to place two free values in the sketch tool Numerics section p 8 then build the point with these two values as coordinates tool point defined by its coordinates section 1 1 1 p This possibility has an advantage over the previous one for some purposes The point so constructed cannot be directly moved with the mouse The point is constrained in its position Create a point defined by its coordinates The user selects a script returning a pair of x y coordinates section 4 1 4 p a4 or two values the first one is the abscissa the x coordinate and second one the ordinate the y coor dinate How to construct a point constrained by its coordinates This function is mainly used to construct a locus of point This construction supposes beforehand the existence of two values section 1 1 4 p 8 the point is then constructed by selecting these two values 1 1 2 Line tools Line Line Create a straight line defined by two points The user clicks on two points or clicks on one point and drags to another Parallel line Parallel Create aline parallel to a given direction and going through a point The user clicks a point and a direction i e straight line ray segment or vector Perpendicular line Perpendicular Create a line perpendicular to a given direction and going through a point The user clicks
12. The canvas is displaced so the point given by the argument is at the centre of the canvas window Example canvas centerTo 500 gt canvas scale anlnteger anInteger Scale of the canvas Action modify the scale of the canvas Example canvas scale 10 Point point canvas point aPoint aPoint coordinates x y free point in the plane with coordinates aPoint Example canvas point 502 point canvas pointX vl Y v2 1 value object v2 value object point determined by its coordinates in the form of values placed in the sketch Example canvas pointX canvas freeValue 2 hide Y canvas freeValue 5 hide lt point canvas pointOnCurve curve at abscissa curve line straight line ray segment etc abscissa curvilinear abscissa of the free point abscissa in interval 0 1 free point on a line Example myPoint canvas pointOnCurve s1 at 0 5 point canvas middleOf pil and p2 1 point item or coordinates p2 point item or coordinates gt middle of two points Example canvas a i canvas DrGeoCanvas new a canvas point 101 canvas middleOf and 404 point canvas middleOf s segment gt middle of a segment 0 5 2 REFERENCE METHODS FOR THE DR GEO SMALLTALK SKETCH 4T Example canvas middleOf 5 point canvas intersectionOf 11 and 12 11 line 12 line gt point of
13. a point and a direction i e straight line ray segment or vector Perpendicular bisector Perpendicular bisector C Create a perpendicular bisector given a segment or two points The user clicks on a segment or two points or clicks and drags Angle bisector Angle bisector OM Create the angle bisector of an angle formed by three points The users clicks on a geometric angle defined by three points or clicks on three points The line will bisect the angle at the second point 6 CHAPTER 1 BASIC FUNCTIONALITY Ray Create ray defined by two points The user clicks on two points The first is the origin the second one a point on the ray Segment Segment Create segment given two points Vector Vector Create a vector given two points The user select two points the origin the second one the terminal point Once the vector is created it can be moved independently of the two points This remains true when the vector is built from a transformation section 1 1 2 Circle Circle Create a circle The user can create it from different selections 10 the centre and a point on the circle 11 the centre and a number the radius 12 the centre and segment whose length is the radius Arc by trois points Arc Create an arc going through three points The first one is the starting point the third
14. an inscribed regular polygon 6 6 CALCULUS 3 Arguments the polygon and the circle diameter Array with poly length d length with poly length d length Float pi abs As we increase the number of sides of the polygon how quickly does this process approach the true value How far can we go 74 CHAPTER 6 DIDACTIC APPLICATIONS S i Chapter 7 Various tips Due to DR GEO integration with the Pharo Smalltalk environment there are a few genies we can invoke Most of them are hidden to the user It is not that we want to restrain their use but that we don t want to overload the user when discovering DR GEO we will show in the following sections these genies can be invoked from menus keyboard shortcuts or Smalltalk code 7 1 Programming In this section we present a few tools to use when writing Smalltalk scripts or composing sketches beginning with the workspace the debugger and the inspector 7 1 1 Workspace To show a workspace click on the DR GEO environment background then do A workspace at first glance is like a text editor But it is in fact a console to edit Smalltalk code to write it to compile it and to execute it It is of course possible to paste in code copied from somewhere else After invoking a workspace paste the source code of the Smalltalk sketch below sketch function p integral summits function x x x summits OrderedCollection new
15. m with the maximum precision available in Smalltalk pi Float pi This returns 3 141592653589793 ore Float e This returns 2 718281828459045 These returned values are usable in the same way as any other value generated by DR GEO Even for such small things the script is your friend But it can do much more interesting things when it receives input parameters Indeed so far the scripts have had no arguments so that it was not necessary to select items in the sketch when inserting the script in the construction Of course the real interest in scripts comes from returning the values of numerical computation pinned in the sketch for use with other constructions or scripts In the following sections we show the use of scripts in cascade 4 1 2 Script with one input parameter The procedure to create a script with one input parameter is mostly the same 4 1 SCRIPT BY THE EXAMPLE 33 31 When editing the script Numeric Edit a script the argument is inserted in the first line with the script name For example to calculate the distance from the origin to a point we write the following script distanceToOrigin item Return the distance from origin to a point item point dist 000 few explanations e itemis the argument of our script which must be a point It is in fact an instance of the class DrGPointItem e DrGPointItem has an instance method s point returning its coordinates Thus from the argume
16. of it e references to it e selectors containing it e method strings with it e method source with it e class names containing it e class comments with it e change sets with it Each one opens the tool specified on the text selected or on an object that that text names if any If there is none a message may appear saying so Some of the functions of these development tools can be discovered through exploration clicking on every button to see what happens For further details see Pharo Smalltalk documentation The Workspace menu 4 1 Script by the example There are two phases to using scripts e creating the script e inserting the script in a sketch one or more times with different parameters The tool to create or edit a script is on the menu Numeric gt Edit a script It is also reachable from the toolbar The tool to use a script is on the menu Numeric gt Use a script It is also reachable from the toolbar script can be defined to receive 0 or more arguments input parameters After selecting a script to insert in the sketch the user clicks on the items used as arguments Then a final click somewhere in the background sets the location for the returned value In the following section we present a few script examples so that the function and power of scripting will be more easily understood The script and the macro construction give a 30 CHAPTER 4 DR GEO SMALLTALK SCRIPT special dimension to DR GEO with a d
17. sketch with the Smalltalk language We provide nice programming interface with an easy and light syntax 5 1 Smalltalk sketches by example Smalltalk itself is a high level language carefully crafted iteratively for about 10 years at Xerox Parc Research Labs When a sketch is defined with it we can use all the power of the language to build a sketch or to position some objects randomly to get a slightly different sketch at each execution of its Smalltalk code Therefore a Smalltalk sketch is freed from the constraints of the graphic user interface while reinforced by the Smalltalk language A Smalltalk sketch is source code to execute in a workspace which is a text editor where source code can be written and executed To open one use the shortcut when no window is selected or click on the background and in the menu select Tools Workspace It is possible to paste text in with the shortcut CTRL V Read section 7 1 1 learn more about this tool Smalltalk sketches are not saved within DR GEO They must be pasted to an external text editor and saved to external files in order to be available for reuse in DR GEO Then the text must be copied from the external file and pasted into a DR GEOworkspace in order to be executed again To introduce the concepts of Smalltalk sketches we will study a few examples Each one will be written in a workspace and its source code will be selected with mouse then executed with the shortcut to
18. then begin without any extraneous scripts While it is possible to put scripts for a sketch into new category for creating them it is not possible to select by category when using a script Furthermore in the use a script dialog scripts seem to be offered in random order It is certainly not alphabetical or temporal order Scripts in DR GEOare executed in the Pharo Smalltalk environment The user thus benefits from the excellent developer tools of the environment class browser inspector debugger etc The user wishing to explore the power of scripts is invited to study the book Pharo By Example where he or she will learn the Smalltalk language and its environment For our purposes in this chapter it is necessary mainly to understand how to use a Workspace Open a new Workspace by clicking in the background and selecting Tools gt Workspace The workspace provides e Dasic text editing capability e Syntax highlighting e Context sensitive selector method name completion e Access to a menu of editing commands and development tools Text editing capabilities in a Workspace consist of the usual Cut Copy and Paste Find and Replace Undo and Do again An Extended search function displays information about selected items using various development tools There are also Accept and Cancel functions Typing in the Workspace causes a highlight to appear at the upper right of the window Accept checkpoints the contents of the window e
19. view is updated automatically whenever the inspected object changes In our previous example suppose we want to see the contents of the summits collection In this case we very simply add a line of code to send the message inspect to summits The place in the code where we put it is not very important It can be at the beginning or the end because we do not have a breakpoint or step by step execution sketch point 1 0 p hide summits add p summits inspect 1 to 1 by Mi do L Z sketch point x function value x summits add p hide 3For obvious reasons we must avoid adding it in the loop 7 1 PROGRAMMING 5 The inspector on the variable summits 19 80 CHAPTER 7 VARIOUS TIPS S o7 Index Angle Geometric Oriented Arc Centre 6 Length Three points l6 Circle 6 Perimeter Curve Clone Debugger Edit Property Style Eraser Free point curve Property Property Free value Property Grid Display Magnet Inspector Line Angle bisector Distance Parallel Perpendicular Perpendicular bisector Slope Locus l6 Script Macro construction Introduction macro construction 9 Create Execute Dialog box Menu Open Save Misc tools 9 Network Share Sketch Number Free value Object Delete Hide Move Property Rename Style Point Coordinates 9 Defined by coordinates Free In
20. 0 m Example canvas a b c angle canvas DrGeoCanvas new a canvas point 000 canvas point 004 C canvas point 300 5 2 REFERENCE METHODS FOR THE DR GEO SMALLTALK SKETCH angle canvas angle b to a to angle show value canvas angle vito v2 vi vector v2 vector gt oriented angle given two vectors in the interval 7 7 Example canvas vi v2 a b c angle canvas DrGeoCanvas new a canvas point 000 b canvas point 004 canvas point 300 vi canvas vector a to V2 canvas vector a to angle canvas angle v2 to vi angle show Equation equation canvas equation0f LineUrCircle lineOrCircle line or circle equation of the line or circle Example canvas ed canvas DrGeoCanvas new d canvas line 0 0 to 15013 e canvas equation0f d e show 5 2 2 Modification of object attributes 99 To modify object attributes we send messages to the objects So the attributes are always modified after creating the objects item color aColor item any object in the canvas aColor a Color see methods in this class for existing colors Color black Color red Color blue Color orange Color yellow Action modify the item color Example pointA color Color green item name aString aString a string text Action rename item Example segment name AB item a
21. 23 for a vector it is its norm 24 for a circle it is its perimeter 25 for an arc it is its length 26 for a line it is its slope 27 for a point and a line it is the distance between these two 28 a mouse click on the background creates a free value initially 0 that the user can edit newly created free value can be edited by clicking it Later on it can be edited by clicking the property button on the toolbar described below and then selecting the value This last possibility is very interesting for some situations It lets the user set an arbitrary value to use for a given length the radius of a circle an angle measure in radians or the coordinates of a point The value is then used by other specific tools to construct a circle a rotation or a point defined by its coordinates 1 1 TOOLS FOR CONSTRUCTION 9 Angle Angle Compute the angle defined by three points or two vectors In the first case the angle is considered as non oriented i e angle whose measure belongs to the interval 0 180 In the second case the angle is oriented and its measure belongs to the interval 180 180 Coordinates Coordinates equation C snnnt n 9 Create the coordinates abscissa and ordinate of a point or vector Free text Text Add block of text in the sketch The user clicks at the desired position then edits the text To edit the text again the user click
22. Do it Let s start with the simplest possible Smalltalk sketch to DrGeoCanvas new When executing it it simply creates a new empty sketch The DR GEO canvas displayed is simplified as there is no toolbar only the menu bar A second example that begins to do something c item c DrGeoCanvas new item c point 1 2 2 item name A Alternatively this is the entry to select in the contextual menu of the workspace 48 44 CHAPTER 5 DR GEO SMALLTALK SKETCH Here we define a sketch containing a free point A of coordinates 1 2 2 An object is added to the construction by sending a message to the canvas here point to create a free point given its coordinates The result is a point object We can also modify the point by sending a message to it Here we rename it A Let s continue with a third more interesting example c triangle ourRandom m n p triangle 1 p2 p3 c segment 1 to p2 segment p2 to p3 c segment p3 to 1 ourRandom 6 11 atRandom c DrGeoCanvas new m c point ourRandom value 0 n c point 5 0 point ourRandom value 3 triangle value m value n value p This example shows us three interesting things 33 34 39 The introduction of more elaborate constructions not initially implemented in DR GEO Here we define block of code triangle between the square brackets given t
23. EX omalltalk sketch Symmetry Translation Value Lock Vector l6 Coordinates 9 Norm Workspace Compiling code Executing step by step Pasting code Profiling code 83
24. FirstScript circumfrenceFromArc angle oneThird The comment of my first script Figure 4 3 Select a script Once the script selected click on the sketch at the place to pin it In this example the script only returns the message Hello World The returned value is always printed in the sketch If necessary it is converted to a text representation 32 CHAPTER 4 DR GEO SMALLTALK SCRIPT In the following examples we only give the source code of the Smalltalk scripts To use them in DR GEO just follow the steps explained previously A random number generator and more If you need a simple random generator for numbers between 1 and 10 the following script exactly does that random I return a random number continuously updated 10 atRandom At each sketch update it generates a different random number in the interval 0 10 Updates occur when the sketch is changed by dragging an object In case you prefer a random decimal number in the interval 0 1 use this script random2 I return a random decimal number continuously updated from O to 1 101 atRandom 1 100 1 Some details e The value returned by the script is the result of the expres sion after the e The returned value can be of any class DR GEO prints its text representation a string e To return the value of a variable it is enough to put its name after the symbol Calculate common values To access an approximate value of
25. Point tools Free point Point _ Create a free point in the plane or on a line object segment ray straight line arc circle locus 6 In the first case the created point can be moved anywhere in the plane of the sketch To create it the user simply clicks in the background 7 In the second case the point can move freely only in the line where it was created it is stuck on the object create this type of point the user clicks on a line i e straight line ray segment circle arc etc Middle Middle Create the middle point between two points or the midpoint of a segment 8 In the first case the user selects two points 9 In the second case the user selects a segment To create one intersection point between two lines i e straight line ray segment arc circle select Points gt Intersection then the two lines in turn DR GEOwill throw an error if the user tries to find an interection with a locus It is enough to click in the intersection of these Moreover DR GEOindicates it by the help bubble ntersection Intersection Intersection C R Create one or several intersection s of two lines i e straight line ray segment arc circle The user has to select two lines When one or both of the chosen lines is an arc or a circle then two intersection points may be created 1 1 TOOLS FOR CONSTRUCTION 5 Point defined by coordinates Coordinates
26. TER 1 BASIC FUNCTIONALITY Rotation Rotation Transform an object by a rotation The user clicks on the object to rotate a centre point and an angle When the object to transform is a point the first clicked is the centre The rotation angle can be defined by three different means e numeric value the angle is therefore the value interpreted in radians Examples of numeric value free value distance between two points segment length a coordinate a value returned by a DR GEO script etc e a geometric angle defined by three points its measure is displayed in degrees Beware in this case the measure ranges only in the interval 0 180 The angle has to be put in numeric form using the angle function described below e an oriented angle between two vectors its measure is displayed in degrees in the interval 180 180 The angle has to be put in numeric form using the angle function described below Homothety scale Transform an object by scaling it The user clicks on the object to transform the centre and the factor i e a number When the object to transform is a point the first clicked is the centre 1 1 4 Numerics and text tools Distance length amp value Distance length value 9 Create a numeric value The value depending on the user selection may be computed or user edited 21 for two points it is the distance between these two 22 for a segment it is its length
27. USER GUIDE Hilaire Fernandes January 15 2014 The electronic version of this book can be found at http drgeo eu hilaire drgeo eu This document is published under Free Document License Author Hilaire Fernandes Peer review Contents Introduction Getting started 1 Basic functionality R s 1 1 1 Point tools Mh 1 1 2 Limetoolsd Na 1 1 3 Transformation tools ener 1 1 4 Numerics and text tools seen 1 1 5 macro construction tools im Wy LLL 1 16 Misctools sh 1 2 Misc functions N V 9 1 2 1 Moving the Sketch W 4 1 2 2 Scaling the fketCN d 1 2 3 Moving object 9 em 1 2 4 Mergifie Maints Jel A7 1 2 5 Cloning 1 246__ 2 Files and documents 2 1 Avemame a sketch WV 4 2 oes 22 sketch W uuo oe ee Ro RO Xo X ovo X ox eG ORR 2 3 ExporWAsketch tJ Lua mu oe BS RUE E A eens eee 2 6 II Advanced functionalities 3 Macro Construction 3 1 Creating a macro construction
28. alue 3 Figure 5 1 Triangle de Sierpinski Part ILI Applications Chapter 6 Didactic applications This chapter is an aid to studying DR GEO using didactic examples Although in the previous chapters several examples were presented here the approach is little more concrete while still very original This chapter was created using contributions from various cultural sources 6 1 Perimeter and area One possible didactic use of DR GEO is through its Smalltalk script system to resolve classic geometry exercises As an example we will show the solution of the following classic problem involving the Pythagorean theorem A right trapezoid ABCD where the bases and height are known Calculate its perimeter and area Solution First we construct the DR GEO sketch as follows are 239 00 perimetre 12 61 Figure 6 1 Right trapezoid The sketch contains the data to use to resolve the problem First we can answer the question of the area To do so we write a Smalltalk script with arguments the two bases and the height 63 64 CHAPTER 6 DIDACTIC APPLICATIONS areaTrapezoidBasei b1 base2 b2 height h Calculate the area of a right trapezoid given its bases and one height h length 61 length b2 length 2 To calculate the perimeter we write script where we calculate the length of BC with the Pythagorean theorem perimeterTrapezoidBaseil b1 base2 b2 height h Calculate the area of a
29. and center Given three points I construct the circle going through these three points and its center Figure 3 6 The fourth page with the name and description of the macro construction If the selections of the input and output objects do not match DR GEO cannot extract a construction sequence because an output depends on an object not selected as an input the macro construction cannot be created In this case the user needs to reconsider the input and output parameters He or she can step back to the second or third page in the dialog box to adjust the choices 23 24 CHAPTER 3 MACRO CONSTRUCTION this stage the macro construction is created and recorded in DR GEO In the next section we will see how to use it 3 2 Play a macro construction 3 2 1 With the dialog box To execute a macro construction the user clicks on the Cemed button in the toolbar or selects the menu macro construction gt Execute macro in the sketch window A dialog box describing the procedure appears On the second page of this dialog box the user selects the macro construction in the upper list and then the input parameters in the sketch Once all are selected the macro construction is executed automatically and the output parameters are built and displayed in the sketch Select a macro construction then the figure items Title Tangentes un cercle Circle and center v Description Given three point
30. and to press the key combination control b choose Tools gt System Browser from the menu The system browser that appears lets the user explore and modify DR GEO source code while it is running This access to the source code is part of the DR GEO DNA it is part of the free software philosophy as well for a completely open approach unlocked with great opportunities for learners Far be it from us to pretend that DR GEOis enough for building mental capacity but it certainly can help Free Software is software under a Free license such as GPL which requires that its source code be made available for study modification and redistribution under the same license ii ConfigurationOfMetace DraPointHomothetyiter a all ConfigurationOfXMLSup DrGPointintersectionite updating Deprecated12 DrGPointltem xml writing DrGeoll Core App DrGPointMiddle2ptsiter DrGeoll Core Builder DrGPoin DrGeoll Core Commanc DrGPointOncurveltem DrGeoll Core Factory DrGPointReflexionitem DrGeoll Core Jtem DrGeoll Core Item View self doParentsExist ifTrue self point parents first origin parents first direction 2 Figure 2 System browser opened on the DR GEO source code from DR GEO itself With this same spirit of openness programmed sketches and scripts presented in the advanced tools section rely on an advanced set of developer tools browser debugger inspector and more In the following we wi
31. boolean indicating if the aPoint is on curve Example curve contains 001 ifTrue Yes 4 2 4 Line ray segment vector point item origin item line ray segment or vector coordinates of the origin of this item Example ct D d H 09 D lt vector gt item direction item line ray segment or vector gt vector x y indicating the item direction Example item direction slope v y v x lt vector item normal item line ray segment or vector unit vector normal to the item direction Example item normal D 4 2 5 Segment lt float gt item length item segment gt length of the segment Example segment canvas segment 000 to 505 segment length lt point gt item extremityl item segment gt coordinates of the extremity 1 Example segment canvas segment 000 to 505 segment extremityl 39 CHAPTER 4 DR GEO SMALLTALK SCRIPT point item extremity2 item segment gt coordinates of the extremity 2 Example segment canvas segment 000 to 505 segment extremity2 point item middle item segment gt coordinates of the middle of the segment Example segment canvas segment 000 to 505 m segment middle 4 2 6 Circle arc polygon point item center item circle or arc coordinates of the centre of the circle or arc
32. cognitive load in the user interface while offering a significant expansion of capabilities 11 INTRODUCTION Dr Geo 2013 07 21 CO File Edit Points v Transformations Numerics mis v Macro construction E DISSI C n 555 Lines Transformations Numerics Animate Macro construction Figure 1 DR GEO window with a blank figure a distinct window opens with its own menu and toolbar The user can then create points lines circles and so on and control their properties Philosophy of the application DR GEO II is Free Softward for interactive geometry on multiple platforms It is complete rewrite of DR GEO 1 1 in Pharo Smalltalk DR GEO 1 1 was written in C and integrated with Scheme interpreter for writing scripts to make interactive programmed sketches DR GEO II also provides the integration of scripts in geometric sketches so that interactive sketches can be written in a programming language The rewrite in Smalltalk was motivated by its unique dynamic qualities it in fact allows us to push very far in our investigations of the interactive possibilities between the user and the application So DR GEO is not only a convivial interactive geometry application but it is also as distributed a complete programming environment to study to modify and to improve it For get an idea of these capabilities the user is invited to click in the background of DR GEO outside any window
33. construction you send message to the canvas The resulting constructed object can be modified as well by sending messages to it So before adding any object to a canvas we need to create the canvas with the command DrGeoCanvas new 5 2 1 Various messages canvas DrGeoCanvas new gt Return a canvas and open it The result is normally assigned to a variable for later use to add constructions Example canvas canvas DrGeoCanvas new canvas fullscreen Action The sketch is set to fill the DR GEOwindow Example canvas canvas DrGeoCanvas new canvas fullscreen canvas do block block Smalltalk block of code with instructions for construction and or animation of the sketch Action Execute the block of code in a specific background process Use it when a con struction needs to be done step by step in front of the user or when the sketch is animated Example canvas point canvas DrGeoCanvas new canvas fullscreen point canvas point 000 canvas do 5 to 5 by Oo x point moveTo x x cos 3 Delay forMilliseconds 100 wait canvas update LL canvas update Action Update the canvas after some objects were modified Used mainly for animation or for modifications that do not cause an update themselves Action Display the grid in the canvas CHAPTER 5 DR GEO SMALLTALK SKETCH canvas centerTo aPoint aPoint Coordinates of a point Action
34. coordinate a summit of the polygon number value item or numeric value number of summits of the polygon gt regular polygon defined by its centre one summit and number of summits Example canvas b canvas DrGeoCanvas new b canvas point 103 canvas regularPolygonCenter b vertex 101 sides 7 Geometric transformations Geometric transformations are to transform any kind of geometric objects point segment line ray vector circle arc and polygon transformed item canvas rotate item center centre angle angle item point segment line ray vector circle arc polygon item object to transform centre point or coordinates rotation centre angle value item or numeric value rotation angle gt transformed object Example canvas kef canvas DrGeoCanvas new C canvas point 505 k 3 14159 l canvas line 000 to 505 canvas rotate 1 center angle k canvas rotate 1 center 000 angle Float pi 3 transformed item canvas scale item center centre factor item point segment line ray vector circle arc polygon item object to transform centre point or coordinates homothety centre k value item or numeric value homothety factor gt transformed object Example canvas c k 1 canvas DrGeoCanvas new C canvas point 005 K uper l canvas line 000 to 505 canvas scale 1 center factor canvas scale
35. de distance itemi to item2 Calculate the distance between two points itemi point dist item2 point itemi and item2 are the names of the two parameters which can be chosen freely To use this script proceed as in the previous example select two points in the construction and click somewhere in the sketch to pin the result of the script 4 1 4 Detailed example with several scripts In the following section we present a more complex sketch integrating cascading use of scripts to construct the curve of a function and its tangent at a mobile point of the curve 34 CHAPTER 4 DR GEO SMALLTALK SCRIPT Move me 924 098 x x cos 019 824 079 Figure 4 4 Curve and tangent to a point The final sketch is on the DR GEO folder examples it is named Curve and slope fgeo In new empty sketch we construct a horizontal segment then add to this segment a free point named Move me This point will be the base to construct the curve as a locus Define a function A script can return any type of object so that our first construction simply defines a function To do so we use a Smalltalk object named block of code an anonymous function in Scheme and some other languages We name this script myFunction without parameter myFunction Definition of our function x x cos Next we insert the function in the sketcl So the block of code returned by myFunction expects one argument x and it returns the cosine
36. destination point and hold for a few seconds 1 2 5 Cloning curve Various type of curve can be cloned to quickly duplicate identical objects To do so press and hold the mouse button over the curve to clone The curve will blink and then a cloned curve is displayed slightly offset from the original ready to be positioned as the user chooses 1 2 6 Grid The scale of the grid adjusts itself when the sketch is enlarged or shrunk When saving a sketch the grid state is saved as well When creating or moving points it is possible to constrain them to snap to the grid Ca activate the magnet tool from the T button in the toolbar Chapter 2 Files and documents Sketches are saved in two different ways one sketch per file or a set of sketches and macro constructions in one file i e a DR GEosession We recall that documents are saved with the extension fgeo When providing the file name you don t need to write this extension DR GEO will do it for you 2 1 Rename a sketch From the menu File gt Change title the user changes the name and the title of the active window This function is useful when the user saves a set of sketches in a single session file 2 2 Save a sketch From the menu File gt Save the sketch of the active window is saved The user is prompted for a name DR GEO can work with several sketches at the same time user switches from one sketch to another one with the task bar in the botto
37. e item X item point x 1 x item point y p With the protocol of the class Point message sent to point this script can be written in one line pointN item Given an initial point calculate the coordinates of a point on the tangent item point 10 self slope item 36 CHAPTER 4 DR GEO SMALLTALK SCRIPT We use this script with argument the point on the curve We get as result the coordinates of the second point on the tangent With these inputs we construct the second point The tangent is the line defined by this point and the point on the curve When moving the point Move me the tangent is recomputed Equally interesting modifying the script myFunction updates the whole construction accordingly few exam ples of modifications to this script E x x x 10 x x cos 10 x sinl x x 5 cos x abs 4 2 Reference methods for Dr Geo scripts An argument passed to a script is always a reference to an instance of a class from the hierarchy DrGMathItem the base class of all items used in a construction So to know about the messages you can send to an argument passed to a script it is wise to examine the hierarchy of DrGMathItem It contains more than 80 classes but because of class inheritance only a few classes are interesting to explore e DrGMathItem e DrGpointItem e DrGDirectionItem for segment line ray vector e DrGArcItem e DrGCircleItem e DrGLocus2p
38. e method call ata time In the bottom area of the debugger window at the right the local variables are shown with type information Other buttons allow other refinements in step by step execution You should explore them before looking at Smalltalk documentation UndefinedObject gt gt Dolt anObject Dolt in SmalltalkEditor gt gt debugrecelverin self value Processor terminateActive in BlockClosure gt gt newProcess figure fonction p integrale sommets fonction x x sommets OrderedCollection new figure DrGeoCanvas new figure point 1 0 p hide sommets add p thisContext all inst vars stack top all temp vars figure fonction P integrale Figure 7 4 The DR GEO debugger 18 CHAPTER 7 VARIOUS TIPS 7 1 2 Debugger As shown in the previous section the debugger lets you execute the code step by step In the DR GEO environment you can invoke the debugger on any selected code in a workspace with the keyboard shortcut Aur D Moreover the debugger can be invoked in the source code by adding a line self halt like a breakpoint In our previous example we modify the source code as follow sketch point 1 0 p hide summits add p self halt 1 to 1 by 0 1 do ix sketch point x function value x summits add p hide 1 1 3 Inspector In the inspector dialogue the user examines the attributes of an instance or a variable The information in the
39. e to GNU Dr Geo Free interactive geometry by OFSET Click the new sketch button at the left of the toolbar The layout of the interface is as follows 1 A menu bar with File Edit Points Lines Transformations Numerics Animate macro construction 2 editing toolbar New figure open and save figures undo last action redo last action display grid snap to grid mode toggle for single or multiple object creation select and move an object erase an object modify the style of an object modify object properties 3 construction toolbar which groups the tools for constructing objects in several tabs It has the same functions as corresponding items on the menu bar 4 In the right bottom corner two wheels for moving the sketch horizontally and verti cally 5 In the right top corner a wheel for scaling the sketch To create a new sketch the user selects the New command in the File menu We will indicate such menu choices in the form File New from here on For each new sketch A particular command can create an object from different parameters For example with the command for constructing a circle the user can specify its centre and a point on the circumference or the length of its radius among other options Of course this command is represented only by one button with DR GEO anticipating the construction intended by the user from the context The immediate effect is thus a decrease of the
40. ector extremity 5 2 REFERENCE METHODS FOR THE DR GEO SMALLTALK SKETCH 53 gt vector Example canvas b canvas DrGeoCanvas new b canvas point 005 canvas vector b to 1 0 2 lt vector gt canvas vector p p point or coordinates the vector coordinates gt vector from 0 0 to point Example canvas p canvas DrGeoCanvas new canvas point 505 canvas vector canvas vector 5 5 Number When applying a method to a canvas that creates a numeric value the value is placed as a DR GEOmath item somewhat at random in the sketch and is initially hidden It can be revealed with the show command described below lt point gt pointltem coordinates pointltem point gt coordinates static of pointItem Example canvas c p segment canvas DrGeoCanvas new segment canvas segment 000 to 3 5 canvas point nCurve segment at 0 5 p coordinates canvas freeValue c x value canvas abscissaUf pointOrVector pointOrVector point or vector item gt abscissa dynamic item of pointOrVector Example canvas m x canvas DrGeoCanvas new m canvas middleOf 1005 and 708 X canvas abscissa 0f m The abscissa of a point is its x coordinate The abscissa of a vector is the difference between the x coordinates of its initial and final points value canvas ordinateUf point rVector pointOrVector point or vector
41. erties only apply to particular kinds of line as in the case of marks and arrowheads on segments Style of value The lateral panel for style of value is for all kinds of numeric value free value edited by the user measure computed results from a DR GEO Smalltalk script Colour label and visibility are adjusted from here The value can also be locked 1 1 TOOLS FOR CONSTRUCTION 11 Figure 1 4 Lateral pa Object property A Some objects num points on the pl tool then ch Figure 1 5 Edit the coordinates of a free point Free point on curve Selecting a free point on curve a dialog box let you edit its curvi linear abscissa It is normalised in the interval 0 1 This allows a curve to be treated as a parametric curve 12 CHAPTER 1 BASIC FUNCTIONALITY Free value Selecting a free value a dialog box let you edit its value 10 2 1 2 Figure 1 8 Edit a script Text Selecting a script a dialog box let you edit it The text can be formatted in several lines with carriage return keyboard key RETURN 1 2 MISC FUNCTIONS 13 Edit this text Edit this text Hello Iam a bloc of text Figure 1 9 Edit a text 1 2 Misc functions 1 2 1 Moving the Sketch The sketch can be moved with the wheels in the right bottom corner or directly with the right mouse button 1 2 2 Scaling the sketch The sketch scale can be adjusted with the wheelon the top right of the window
42. he quotient of the perimeter of that hexagon by the diameter of the circle Clearly since the side of the hexagon is the same length as the radius of the circle the resulting initial approximation of 7 is 3 In second step we construct an inscribed dodecagon To construct the previous regular hexagon we used the DR GEO tool to construct a regular polygon with 6 vertices To construct the dodecagon we just need to change this free value item to 12 and the polygon 72 CHAPTER 6 DIDACTIC APPLICATIONS T approx 3 00 Figure 6 11 Inscribed regular hexagon will update automatically We calculate the perimeter then an approximation of 7 as the quotient of the perimeter by the diameter of the circle small script is written to calculate this quotient its arguments are the polygon and the circle diameter approxPIpolygon poly diameter d PI approximation given an inscribed regular polygon Arguments the polygon and the circle diameter poly length d length Now apply this script to the constructed polygon and its diameter the segment we started with and pin the result in the sketch T approx 3 11 Figure 6 12 approximation When increasing the number of sides of the polygon by editing the free value we improve the approximation To display both the approximation of and its accuracy we can modify the script to display them together approxPIpolygon poly diameter d PI approximation given
43. his code an interactive programmed sketch Figure 7 2 Result after executing the source code the integral of the function in 1 1 When executing complex Smalltalk code running it with a profiling option let you see its bottlenecks To do so in the contextual menu invoke the command Profile it The source code is executed the sketch is built and then a profile window informs you about the execution time in different part of the code and the various invoked methods It is a wonderful way to navigate the execution tree of the code and look for methods consuming too many cycles 7 1 PROGRAMMING 77 38 tallies 39 msec Process 40s 575930368 nil 71 1 28ms UndefinedObject gt gt Dolt 526 21ms DrGeoCanvas gt gt point 526 21ms DrGeoCanvas gt gt finalizePoint 50 0 20ms DrGeoDomain gt gt createFromMathitemNoStack 1447 17ms DrGeoDomain Object gt gt triggerEventwith 1447 17ms DrGeoDomain Object gt gt triggerEventwithArguments I 44 7 1 ou geo E point aPoint self preProcessing self finalizePoint DrGPointFreeltem newWith aPoint Figure 7 3 DR GEO profiling Last refinement stepping through code This is done through the debugger Select the code to debug then in the contextual right click menu choose the command Debug it The debugger is invoked on the first line of the selected source code which is executed step by step with the button Over on
44. hree points construct a triangle We can compare this to the macro construc tion method but with a different approach programming oriented The definition of a block of code ourRandom to give us integer random number between 5 and 5 It is used for random positioning of the points Therefore each time the sketch is executed it is slightly different Assigning the result of a construction the object we got when sending a construction message to the canvas is not mandatory We do it when we need to keep a reference to the constructed object for later use Here in the block of code triangle we don t keep references to the constructed segments However concerning the defined points we keep references in the local variables m n and p for later use as arguments when executing the block of code triangle To finish with this introduction by example here is the last one c a b d DrGeoCanvas new a point 100 b c point 500 d c line a to b a color Color yellow round large b hide d dashed Two points and a line are constructed Then messages are sent to them to modify their styles including hiding one We have finished our small guided tour of DR GEO Smalltalk sketches In the following sections we expose the commands available 5 2 REFERENCE METHODS FOR THE DR GEO SMALLTALK SKETCH 45 5 2 Reference methods for the Dr Geo Smalltalk sketch To add an object to
45. ifferent positioning to let the user go into areas that the software was not initially planned for It is important to understand that most Pharo Smalltalk resources are accessible in scripts This is particularly true for the class and method which we will use lot 4 1 1 Script without parameter First example The procedure to create a script without an input parameter is as follows 29 Edit the script a Select Numeric gt Edit a script in the menu to open the script editor eoo DrGeoUserScripts DrGeoUserScripts Class all coordinate examples coordinate2 9 scripts distance to private example1 4 Browse j Senders Implementors Versions gt i Ve nessageSelectorAndArgumentNames comment stating purpose of message temporary variable names statements Figure 4 1 Script editor Within the script editor window there are three panes e In the top left the script categories to keep in good order examples private and scripts It is in this last one that you put your scripts e In the top right the script names in the selected category When selecting one its source code is displayed in the editor pane at the bottom e In the bottom the source code editor for the selected script It is there you create or modify the scripts To accept a modification press the keyboard keys Crus b In the script editor select the category scripts The text edi
46. ing the Pythagorean theorem we have OB equal to the square root of 2 Now with the sketch we construct another right triangle with the sides OB and BC so that BC 1 Still using the Pythagorean theorem it is clear the hypotenuse OC of OBC has a length equal to the square root of 3 The process can be repeated without limit to get the square roots of all positive integers The iterative nature of this construction can be naturally represented in a Smalltalk sketch 6 3 IRRATIONAL NUMBERS 67 racine 3 1 Figure 6 6 Construction of the square root of Let s consider the following Smalltalk sketch source code sketch triangle sketch DrGeoCanvas new fullscreen triangle 1 p2 p3 51 82 53 perp circle p4 51 sketch segment pi to p2 S2 Sketch segment p2 to p3 color Color red s3 sketch segment p3 to pl perp sketch perpendicular 53 at p3 hide circle sketch circleCenter p3 to p2 hide p4 sketch altIntersectionO0f circle and perp hide gt 0 ifTrue triangle value pi value p3 value p4 value n 1 triangle value 000 value 1 0 value 1 1 value 50 The triangle at the beginning is defined by the coordinates of its vertices The source code is a direct transcription of the logic of the construction integrating its iterative nature with recursive loop We use the hide message several times to mask intermediate constructions
47. intersection of two lines Example canvas intersectionOf linel and 1 2 point canvas altIntersectionOf 11 and 12 11 line 12 line second point of intersection of two lines when it exists Example canvas altIntersectionOf line and circle point canvas point block parent item block block of code returning coordinates item math item gt pointBlocklItem whose coordinates are calculated with the block of code with item as argument Example figure s mobile c block figure DrGeoCanvas new figure fullscreen s figure segment figure point 500 to figure point 500 mobile figure pointOnCurve s at O 1 block mathItem x x mathItem point x x x x 25 c figure point block parent mobile figure locusOf c when mobile lt point gt canvas point block parents itemCollection block block of code returning coordinates itemCollection math item collection point whose coordinates are calculated with the block of code with itemCollection as argument Example figureabdmp igure DrGeoCanvas new figure point 2 1 figure point 303 figure line to b color Color blue figure point 10 1 YM gt OO CHAPTER 5 DR GEO SMALLTALK SKETCH figure point parents parents first closestPointTo parents second point parents d m Le This example uses array
48. item gt ordinate dynamic item of pointOrVector Example canvas m x canvas DrGeoCanvas new 54 CHAPTER 5 DR GEO SMALLTALK SKETCH m canvas middleOf 1005 and 708 X canvas ordinateOf m The ordinate of a point is its y coordinate The ordinate of vector is the difference between the y coordinates of its initial and final points value canvas freeValue v v initial value free value item initially hidden randomly placed Example canvas freeValue 1 arcCos v Show lt value canvas lengthOf segment circle l arc vector segment circlelarclvector segment circle arc or vector number item the item length Example canvas lengthOf vi lt value gt canvas distance line point to point2 line point line or point point2 point gt number distance between two points or a point and a line Example canvas distance 11 to a value canvas slopeUf line line line gt number slope of the line Example canvas p canvas DrGeoCanvas new canvas slopeDf d DR GEOdoes not handle infinite slope for vertical lines well If a slope is placed in a sketch and then the lineis made vertical the slope disappears from the sketch and its value does not update in the data pane Angle value canvas angle a to b to c point b point angle summit point gt geometric angle abc in the interval
49. ively and simply sketches to visualise recursive or iterative situations in programming We can go one step further by modifying the previous Smalltalk code used to construct irrational numbers to get a famous sketch of the mathematics literature the Baravelle spiral constructed from similar equilateral right triangles The code to construct this spiral is as follows sketch triangle sketch DrGeoCanvas new fullscreen triangle 1 p2 p3 n lt 1 52 53 perp circle p4 51 sketch segment pl to p2 52 sketch segment p2 to ps 53 sketch segment p3 to pl m Sketch middleOf pi and p3 hide perp sketch perpendicular 53 at p3 hide circle sketch circleCenter p3 radius sketch distance m to 3 hide hide p4 sketch altIntersectionOf circle and perp hide n 0 ifTrue triangle value m value p3 value p4 value n 1 triangle value sketch point 005 value sketch point 505 value sketch point 500 value 9 triangle value sketch point 0 5 value sketch point 5 5 value sketch point 500 value 9 With this sketch and the corresponding Smalltalk code we clearly perceive the recursive nature of the construction mechanism An interesting problem for the reader is to establish when the two branches of the spiral converge 10 CHAPTER 6 DIDACTIC APPLICATIONS Figure 6 9 The Baravelle spiral after executing the Smalltalk code 6 5 Pap
50. ll not distinguish between the application names DR GEO II or DR GEO iv INTRODUCTION Dr Geo on the web DR GEO has its own web site at http drgeo eu Here you will find the following information e how to get DR GEO e software documentation e information about the DR GEO project e reference material on applications of DR GEOin teaching Part I Getting started Chapter 1 Basic functionality This chapter describes the tools used to construct a geometric sketch 1 1 Tools for construction These tools are ordered on six tabs Clicking any of these tabs brings up an appropriate toolbar Numerics Lines length line ray free value segment circle arc angle parallel perpendicular coordinates bissectors free text Macro construction vector polygon edit script build macro locus use script execute macro Points Transformations Numerics Animate Macro construction Points Transformations Animate free symetry Animate a mobile point middle reflection on a curve with intersection translation various speed according to coordinates rotation homothety scale Figure 1 1 Tool categories and the descriptions DR GEodefaults to a functional mode of operation The user must click on a function 4 CHAPTER 1 BASIC FUNCTIONALITY tab and then a function button or select a function from a menu before selecting the object or objects to apply it to and exec
51. llowing situation where the quadrilateral is not convex AD BC BC AD 26 13 AC 13 68 Figure 6 3 Ptolemy s theorem non convex inscribed quadrilateral In this case the theorem is not true and the previous text of the theorem is inaccurate It should be reformulated as follow Given an inscribed CONVEX quadrilateral the sum of the products of its opposite sides is equal to the product of its diagonals Now a additional conjecture can be stated is the theorem still valid when the convex quadrilateral is non inscribed With DR GEO we verify this conjecture is false with the following counterexample bellow build this counterexample we have just detached the point from the circle by dragging it with the touch pressed at the same time The reader will easily use DR GEO to construct additional didactic examples perhaps more famous relative to the Pythagorean and Euclidean theorems This is only a numerical example not a proof 66 CHAPTER 6 DIDACTIC APPLICATIONS AD BC BC AD 39 76 AC BD 39 09 Figure 6 4 Counterexample of the conjecture 6 3 Irrational numbers classic construction of irrational numbers known as the Teodoro spiral gives the geometric construction of integer square roots It begins with an isosceles right triangle Let s start with the triangle where AB OB Racine 2 Figure 6 5 Construction of the square root of 2 Us
52. ltalk script DR GEO is dynamic application written in Pharo Smalltalk This means that it is possible to modify it within itself as it is running We have exploited this feature with the Numerics gt Use a script command to define sketch items in DR GEO which are in fact Smalltalk scripts code snippets to extend the possibilities of DR GEOdynamically without limit But what exactly is Smalltalk Smalltalk is an object oriented dynamically typed reflective programming lan guage Smalltalk was created as the language to underpin the new world of computing exemplified by human computer symbiosis Tt was designed and cre ated in part for educational use more so for constructionist learning at the Learning Research Group LRG of Xerox Palo Alto Research Center PARC by Alan Kay Dan Ingalls Adele Goldberg Ted Kaehler Scott Wallace and oth ers during the 1970 The language was first generally released as Smalltalk 80 Smalltalk like languages are in continuing active development and have gathered loyal communities of users around them ANSI Smalltalk was ratified in 1998 and represents the standard version of Smalltalk In this definition object oriented means that everything in Smalltalk is an object defined in a class with its behavior determined by methods defined in that class This is in contrast with the notion of a variable associated with a data type in most programming languages where the type system sets fe
53. m of the DR GEO environment With the menu File gt Save as the user saves the document under another name The documents are saved in the DR GEO application structure in the folder DrGeo app MySketches To save at an arbitrary location in the hard disk structure use the menu File gt Save at When saving document a network option is available in the dialog box If selecting this option the user must also provide a network share name arbitrarily chosen by the user and the document name This option lets a group of networked users share sketches 2 3 Export a sketch The menu File gt Export as bitmap exports the sketch of the active window in a picture file bitmap in the standard format pd The pictures are saved in the DR GEO structure application in the folder DrGeo app MyExports http www w3 org Graphics PNG 15 16 CHAPTER 2 FILES AND DOCUMENTS 2 4 Save a session session is a set of DR GEO documents sketches and macro constructions the user saves in one file It eases the preparation of pedagogical sequences From the menu File gt Save multiple the users accesses a dialog box to select the document to integrate in the session file Save Multiple Select the sketches and macros you want to save _ Fig Dr Geo 2013 07 19 _ Fig Dr Geo 2013 07 20 _ Fig Dr Geo 2013 07 23 Macro Bissectrice Macro Tangentes un cercle Figure
54. mple a small point medium m O S 3 ct m Eg c n do B N m ge za e Example a medium point large point point Action large sized point Example a large item moveTo point ct D d ct zm lt m c Ei D point coordinates Action move the item to the given position if its constraints permit Example canvas a canvas DrGeoCanvas new canvas point 000 a moveTo 505 canvas update f 58 CHAPTER 5 DR GEO SMALLTALK SKETCH 5 2 3 Complementary methods The DrGeoCanvas class proposes in the category helpers complementary methods to ease the computation of complex interactive sketches canvas plot aBlock from 0 to 1 aBlock block of code with one argument to describe a function on an interval x0 number lower boundary of the function s domain x1 number upper boundary of the function s domain Action display the curve representing the function described by the block of code in the interval x0 xl and display a free point on the x axis together with a relative point on the curve representing the value of the function at that point Example canvas plot x x from 3 to 3 lt block gt canvas float floati at aPoint from float2 to float3 name aStri floati initial value aPoint left position of the ruler float2 minimum value float3 maxim
55. mpties the undo stack and causes the highlight to disappear Editing and then cancelling takes the window back to the last checkpoint without having to undo each action individually When editing object names appear in blue method names and symbols such as in black and unrecognized text in red This includes incomplete names undeclared local variables and also syntax errors When the user is typing a selector a menu appears showing selectors starting with the typed text that are usable in the current context that is for the object that will receive this message Move up or down in the menu with the arrow keys and accept the highlighted selector by pressing the tab key If the selector has more than one part all of the parts are entered into the workspace Development tools provided on the workspace menu accessed by right clicking in the workspace are 4 1 SCRIPT BY THE EXAMPLE 29 e Do it Execute the selected text or the current line otherwise e Print it Execute text and display the result Inspect it Open an Inspector on a selected class name or execute selected text and open an Inspector on the results Explore it Open on object Explorer on a selected class name or execute selected text and open an Explorer on the results Debug it Open a Debugger on selected code e Profile it Open a Profiler on selected code Development tools accessible in the Extended search menu are the following e browse it e senders
56. notation to provide the collection needed Line line canvas line pl to p2 pi point or coordinates p2 point or coordinates line passing through these two points Example canvas 1 canvas DrGeoCanvas new pi canvas point 000 canvas line pi to 102 Note that if one or both arguments are given as literals those points are not drawn and are not available in the sketch to click and drag The direction of the line thus cannot be changed interactively line canvas parallel d at p d direction line segment vector p point or coordinates line parallel to direction d and passing through point p Example canvas a d canvas DrGeoCanvas new a canvas point 105 d canvas line 2 01 to 303 canvas parallel d at a line canvas perpendicular d at p p point or coordinates d direction line segment vector line perpendicular to direction d and passing through point p Example canvas perpendicular d at 105 line canvas perpendicularBisector s segment perpendicular bisector to s Example canvas perpendicularBisector canvas segment 000 to 404 line canvas perpendicularBisector a to b a point or coordinates b point or coordinates gt perpendicular bisector to segment joining a and b 5 2 REFERENCE METHODS FOR THE DR GEO SMALLTALK SKETCH 49 Example canvas perpendicularBisector 000
57. nt coordinates Action modify the coordinate of item Example pointItem point 502 float item abscissa H ct D Ep e D ct D e z curvilinear abscissa of this point in the interval 0 1 Example pointItem abscissa ray item abscissa ct D B p O O Le 2 ct v z D a decimal number in the interval 0 1 Action modify the curvilinear abscissa of a free point on a line Example m5 TO H D ct I ct D f Oo n Q H n item moveAt aPoint item geometric point aPoint coordinates where to displace item Action displace item to the given position Example point moveAt 201 A Ww Un ee 09 g e e c lt cL p float curve abscissa 0f aPoint curve straight or curved line aPoint coordinates x y of a point gt number in 0 1 curvilinear abscissa of aPoint on curve Example gt curve abscissa0f 201 point curve pointAt anAbscissa curve straight or curved line anAbscissa number in 0 1 coordinates of a point on curve with curvilinear abscissa equal to anAbscissa 4 2 REFERENCE METHODS FOR DR GEO SCRIPTS Example myPoint curve pointAt 0 5 boolean curve contains aPoint curve straight or curved line aPoint coordinates x y of a point
58. nt we can extract information here its coordinates and calculate with it e 000 is an instance of the class Point with coordinates 0 0 e dist is a keyword message 5 fromsthe class Point expecting as its unique argument another instance of Point It calculates the distance between these two instances It can be understood as distance between item point and 0 0 The keyword message syntax is very specific to Smalltalk The arguments are declared in the message name line of a method 32 To use a script Numeric gt Use a script DR GEO expects from the user to click on appropriate objects then somewhere in the sketch Attention If an item other than a point is selected when a point is expected DR GEO throws an error opening a debugger window stating the problem and offering further information The debugger window can be safely closed To continue select the script again Depending on the type of argument received by the script various methods are available to get its value its coordinate etc A list of the methods you can use are presented in section p below 4 1 3 Script with two input parameters Let s say we want to calculate the distance between two points do so we create a script with two input parameters inserted on the name line of the script We name it distance to where each indicates the place of the parameter Therefore in the script editor we write the following source co
59. ny item 56 CHAPTER 5 DR GEO SMALLTALK SKETCH item show item any item Action show an item Example value show line small line line item straight line ray circle lieu etc Action Set thickness of line to small Example circle small line normal line line item straight line ray circle lieu etc Action Set thickness of line to normal Example arc normal line large line line item straight line ray circle lieu etc Action Set thickness of line to large Example polygon large line plain line line item straight line ray circle lieu etc Action plain undotted style line Example polygon plain IP 5 v by H B line item straight line ray circle lieu etc Action dash style line Example polygon dashed line dotted line line item straight line ray circle lieu etc Action dotted style line Example arc dotted point cross point point item 5 2 REFERENCE METHODS FOR THE DR GEO SMALLTALK SKETCH of Action cross shape for point Example a cross point round O He D ct EX Action round shape for point Example a round point square 5 5 ct F z ct c Action square shape for point Example a square point small 5 ct z ct c Action small sized point Exa
60. of that argument We see later how to manipulate this script Image of a value by function Now we calculate the coordinates of a point on the curve We use our point Move me abscissa and our function previously defined Our script will have one unique point argument as we will see we do not need to pass myFunction as argument pointM item Return a point on the curve of myFunction and driven by item point item point x self myFunction value item point x The point returned by this script has the same abscissa as the argument and its ordinate is the image of that abscissa by the function Note e the direct access to the function self myFunction 5 learn about the protocol of this class write its name in a workspace select it with the mouse then press the keys CTRL 8 class browser opens on this class to navigate in its protocol and source code 6 As we can see because its name ends in TIt is important to add it to the construction to get it included in the file when the sketch is saved 4 1 SCRIPT BY THE EXAMPLE 39 e the way to pass an argument to a block of code it can be understood as myFunction item point x Now we use this script pointM with the point Move me as argument the result of this script is of the form 1 200 5 representing a pair of coordinates With the tool Coordinates Points Coordinates we create a point with its coordinates specified by the result of this script
61. oining two points are returned as an array containing the two points In contrast the parents of a free point are returned as nil item move vector item mathematics item vector a vector x y representing the displacement Example circle move 2 1 Move an item in a given direction while respecting its constraints lt point gt curve closestPointTo aPoint curve mathematics curve aPoint coordinates coordinates of the point on curve the closest to aPoint Example position segment closestPointTo 201 Example position arc closestPointTo 201 This works when the curve is a line a segment a vector an arc a circle a polygon or a locus 4 2 2 Point point item point object defined in a DR GEO construction passed as argument to a script is a complex object It can be a free point on the plane on a line an intersection etc few methods can be useful in scripts point item point item point item gt coordinates of this item Example abscissa pointltem point x CO 8 CHAPTER 4 DR GEO SMALLTALK SCRIPT For example with this script showO rdinate aDrGeoPoint ordinate of point aDrGeoPoint point y The user would invoke this script pick a point and pin the result in the sketch showing et D Lane 5 ct T ct a DN a O ct S D ET item point aPoint item point item aPoi
62. oint is displayed in its new position after each move second example with a more elaborate sketch figure s r u pause figure DrGeoCanvas new fullscreen S figure segment 00 1 to 40 1 r figure pointOnCurve s at 0 8 s figure segment 0 0 to 001 u u 1 figure pointOnCurve s at 0 7 round small color Color blue to 100 do nl figure point parents ly tl y parents first point y t parents second point x n 5 0 t y 1 y parents u r u round small color Color blue pause Delay forSeconds 0 1 figure do O to 1 by 0 05 do r mathltem setCurveAbscissa x figure update pause wait 5 8 2 Sierpinski triangle This example largely relies on a recursive block of code for drawing triangles and subdividing them to a specified number of levels triangle c triangle Wei s2 153 n segment si to s2 segment s2 to s3 segment s3 to sl n gt O ifTrue triangle value si value c middleOf si and s2 hide value middleOf si and s3 hide value n 1 triangle value middleOf si and s2 hide value s2 value c middleOf s2 and s3 hide value n 1 triangle value c middleOf si and s3 hide value middleOf s2 and s3 hide value s3 60 CHAPTER 5 DR GEO SMALLTALK SKETCH value n 1 c DrGeoCanvas new triangle value c point O Q 3 value c point 4 3 value c point 4 3 v
63. ommand Objects that depend on the deleted object will also disappear When deleting a curve the points used to define it remain behind The action is undoable with the undo button in the toolbar or the undo menu item in the Edit menu Change the style of an object EH Each geometric object has its own style attributes which can include colour line style thickness label size and shape and properties such as Fill Translucent and Hidden An object that is hidden remains in the sketch but is not seen except when editing properties so that it can be found Hiding intermediate construction is often useful to avoid clutter in the sketch All these attributes are edited from a side panel displayed when the user enters style mode To do so click the 2 button from the toolbar and then select a particular item in the sketch Style of point The lateral panel for style of point is for points within every kind of object Name Colour shape x dot or block size visibility and locking are adjusted from there Only the position of free points on the plane or on a curve is lockable Name A Colour Shape lv Size X lv Hide Lock Figure 1 2 Side panel to edit style of point Style of line The side panel for style of line is for straight lines rays segments vectors circles arcs loci and polygons Name colour thickness solid or dashed styles and visibility are adjusted from there Some prop
64. one is the end point and the second one is a point on the arc Arc centre Arc center M Create an arc defined by its center and by starting and ending points The first one is the centre the second one is the starting point and the third one is the end point Locus Locus Locus defined by two points The user selects two points one free on a line the other one depending on it so that moving the first point makes the location of the second point change This dependent point is called a relative point For example we can construct an ellipse based on its property that the sum of the distances from each point on the ellipse to two given points is constant 13 Create free points O and A which will be the given points 14 With center O and radius greater than the length OA create a circle 15 Create a free point B on the circle 1 1 TOOLS FOR CONSTRUCTION 7 16 Join the segments OA and OB 17 Construct the point C the midpoint of AB 18 Create a perpendicular bisector to AB 19 Construct the point D the intersection of OB and the perpendicular bisector to AB 20 Construct the locus with free point B and relative point D Since CD is the perpendicular bisector of AB the triangles ACD and BCD are congruent side angle side Therefore AD BD Then AD DO BD DO which is the radius BO which is constant D lies on the ellipse Moving B all around the circle moves D all around the ellipse
65. onstruction He activates the function Build a macro from the toolbar or from the menu macro construction gt Build macro In the newly displayed dialog box the user selects the input and output objects and enters a name and description of the macro construction Figure 3 3 Introduction page in the dialog box to construct a macro construction The second page in the dialog box lets the user select the input objects In our example it is the three initial points The user just needs to go to this second page and then click on the three points A B and C in the sketch The selected points blink and the names are displayed in the dialog box In the third page the user selects the output objects In our example we want the circle and its centre as the result of the macro construction The user clicks on these two objects in the sketch When selected they blink and their names are displayed in the dialog box In the fourth page the user inputs name and a description for the macro construc tion This information is displayed when the user plays a macro construction It helps to disambiguate macro constructions Next the user validates the definition of the macro construction by pressing the Apply button and examining the results He can also step back to the previous steps to adjust the parameter objects 3 1 CREATING A MACRO CONSTRUCTION Wu Figure 3 5 Th d page _the circle and the centre selected Circle
66. pus Chain Another classic use of a Smalltalk programmed sketch is based on its numeric ability to reproduce a geometric sketch knowing its analytic characteristics The example we propose is the famous Pappus Chain The successive circles centres and radii are analytically known and in fact rational It is therefore easy to reproduce this sketch by programming sketch circle a o ml sketch DrGeoCanvas new fullscreen circle n r sketch freeValue 15 n squared 6 hide sketch point 15 n squared 6 5 15 n squared 6 n 2 c small round sketch circleCenter c radius gt 0 ifTrue circle value n 1 circle value 10 a 7 sketch point 500 name A 7 sketch point 000 name 0 m Sketch middleOf o and sketch point 1500 name B m name Sketch circleCenter m to o circleCenter a to o line a to o The source code is relatively intuitive and it does not require any comment non trivial exercise for the reader consists of determining a ruler and compass con struction for the figure 6 6 CALCULUS 71 Figure 6 10 Catena di Pappo 6 6 calculus The approximation of 7 played an important role in the history of mathematics Numerous methods were proposed offering a variety of improvements over time from elementary geometry to calculus We will examine one of the earliest approaches
67. rce platform for professional software development and a robust and stable platform for research and development into dynamic languages and environments DR GEO uses the Smalltalk environment to create a comfortable environment for writ ing scripts providing access to the programming interfaces for geometric objects These interfaces are the set of methods in the definitions of the types of the objects Thus the user can write scripts to manipulate the sketch items and as scripts pinned in the sketch are also sketch items they do not need to be in separate files but can be saved in the sketch file Scripts are not edited as sketch items but as methods stored globally in Smalltalk Using a script and pinning the result in a sketch makes it part of the sketch so that it can be saved and reloaded with the sketch However there is no way to keep scripts in different sketches separate if they are open at the same time This is a design bug because users will often have all of their work polluted with scripts meant to be used in other sketches unless they exercise great care to avoid this In fact the default state of DR GEOcontains a number of useless scripts that could have been put into the examples category or even omitted so that any new session would start with an empty scripts category A workaround is to close DR GEOand open a new session after working with a sketch containing multiple scripts and before creating any new sketch which can
68. right trapezoid given its two bases and one height hb bc hb b2 length bi length abs bc hb squared h length squared sqrt b1 length b2 length h length bc It is not difficult if you follow the same model to develop other similar examples 6 2 Theorem and conjectures With Smalltalk scripts one can solve exercises but can also understand theorems more deeply and verify conjectures In this section we start to analyse Ptolemy s theorem Given an inscribed quadrilateral the sum of the products its opposite sides is equal to the product of its diagonals We construct the sketch as below where we implemented two scripts to calculate respec tively the sum of the products of its opposite sides and the product of its diagonals B AD BC BC AD 31 92 AC BD 31 32 Figure 6 2 Ptolemy s theorem inscribed quadrilateral The first script ptolemySumS1 ab s2 bc s3 cd s4 ad Select the four consecutive sides of the quadrilateral then the location for the result ad length bc length ab length cd length The second script 6 2 THEOREM AND CONJECTURES 65 ptolemyProductD1 ac 42 bd Select the two diagonals of the quadrilateral then the location for the result ac length bd length As we can see the values returned by the scripts as stated by Ptolemy s theorem are equal When we dynamically modify the sketch the script values are always equal except in the fo
69. s I construct the circle going through these three points and its center Cancel M previous M next Figure 3 7 The user selects the input parameters in the sketch In our example the macro construction expects three input parameters three points and constructs a circle and its centre Therefore to execute it you need a sketch with at least three points Figure 3 8 Sketch with three points Once we feed three points to the macro we get the expected circle and centre 3 2 2 With the macro construction menu The macro constructions loaded in memory are listed in the window menu macro construction Selecting macro construction from this menu let you execute it directly After choosing one in the menu select the input parameters in the sketch The macro construction is executed as soon as all the input parameters are selected It is a dialog less mode of execution 3 2 PLAY A MACRO CONSTRUCTION 25 Figure 3 9 A final sketch with the circle and its centre As described in the Files and documents chapter to save a macro or collection of macros to a single file select File Save multiple and then select the items to include in the saved file The same process works for saving a sketch with multiple macros To add a macro from a saved file to sketch create or open the sketch and open a file containing just the macro 26 CHAPTER 3 MACRO CONSTRUCTION lt S i Chapter 4 Dr Geo Smal
70. s the macro construction It lets the user record a sequence of con struction steps in a single command Once recorded it can be replayed and saved in a file to be opened later in another sketch The DR Smalltalk script is another feature to extend DR GEO behaviour script appears as a sketch item like any other As input it expects zero one or more references to geometric items from the sketch and it returns a reference whose print representation is placed in the sketch It is in fact a programmed methodP placed in a sketch and evaluated each time the whole sketch is updated i e when the sketch need to be redrawn A DR GEO Smalltalk script may be useful for its returned object or for its side effects depending on the wishes of the user Going a step further DR GEO offers Smalltalk sketches In this case the whole inter active geometry sketch is described in Smalltalk source code Its interest is the functional approach to describing a sketclf compared to the linear declarative method of constructing a sketch with the mouse Comparable to a procedure for users of other programming languages For example recursively 19 Chapter 3 Macro Construction macro construction is similar to a programmed procedure or function receiving as input items from the sketch and providing as outputs another set of items in the sketch macro is built according to a model defined by the user That means that the user fir
71. s the property button described below then the text Inserting a Smalltalk script Use a script u Insert a DR GEO Smalltalk script in the sketch The script expects a number of objects as arguments and requires target to attach the output to It returns an object whose text representation is printed in the sketch at the position clicked by the user A script can be used for its side effects or for the value it returns ready to be used for subsequent constructions See the Smalltalk Script chapter for more details Editing a Smalltalk script Edit a script Edit or create a Smalltalk script script editor is opened for the user to edit any existing script or to create a new script The DR GEO Smalltalk scripting system is reviewed in detail in the chapter on advanced functionalities specifically in the section 4 1 1 5 macro construction tools Create a macro construction Build macro P M Extract a construction sequence from the sketch and compile it as a macro construction macro constructions are covered in detail in the section 3 p Play a macro construction Execute Macro R AG a Execute a macro construction The macro construction can be newly created or loaded from a file 10 CHAPTER 1 BASIC FUNCTIONALITY 1 1 6 Misc tools Delete an object An object can be deleted using the eraser tool or the Edit gt Eraser c
72. sketch DrGeoCanvas new sketch point 1 0 p hide Summits add p 1 to 1 by 0 1 do p sketch point x function value x summits add p hide p sketch point 1 0 summits add hide integral sketch polygon summits integral color Color blue Depending one your system replace by Aur 2To paste a text try with the shortcut or from its contextual menu right click 19 16 sommets add p 1 to 1 by 01 do x p figure point x fonction value x CHAPTER 7 VARIOUS TIPS eoe Edit Do it d figure fonction p integrale sommets Print it p Inspect it i fonction x x x sommets OrderedcCollection new E figure DrGeoCanvas new Debug D p fiqure point 1 0 E Profile it p hide a Find f A Find again 9 A Extended search 9 Do again j sommets add hide Undo 2 p figure point 1 g0 Cut x sommets add p hide Paste y integrale figure polygon sommets Paste integrale color Color blue f Accept 5 Cancel I Figure 7 1 Your workspace with the pasted source code and its contextual menu To compile and to execute this source code just select it with the mouse and invoke Do it d in the contextual menu These two operations can also be done at the keyboard to select all the source code then to execute it You immediately get the result of t
73. st needs to do the complete construction sequence in the sketch then ask to DR GEO to record it in a macro construction The macro construction can then be replayed and saved in a file like any sketch To record a construction sequence DR GEO needs to know the initial items of the sequence and the final output items Of course the final items must depend only on the input items otherwise DR GEO cannot deduce the final items from the initial ones Thus DR GEO traces the logic of the construction sequence for the specified outputs and records it in a macro construction Then the user can repeat this sequence When playing the macro construction it only asks for the initial items of the types specified in the sketch and constructs the resulting output items Intermediate invisible items are constructed by the macro con struction They are necessary to reproduce to complete the con struction sequence and the resulting output items To illustrate the use of macro construction we take the example of a circle going through three points Figure 3 1 The initial sketch Before creating the macro construction the user has to construct the final sketch to serve as a model as shown in the figure below 3 1 Creating a macro construction The user now tells DR GEO he wants to define a macro construction from this sequence 21 22 CHAPTER 3 MACRO CONSTRUCTION Figure 3 2 The sketch with the final c
74. tersection Lock Merge Middle Mutate Rename Polygon Regular Ray Rename Object Script 19 random value 32 API abscissa 38 abscissa f abscissa 38 center closestPointTo 82 contains degreeAngle direction exist extremityl extremity2 length middle move moveAt normal origin parents point pointAt point position radianAngle radius safeName valueItem valueltem Coordinates Point Curve Tangent Edit 9 Examples Complex Ptolemy s theorem Simple Tangent to a curve Function Image Introduction Parameter s 0 1 2 Property Use 9 Segment l6 Length Mark Session Open Save Share Network Sketch Sketch Export Move New INDEX Open Rename Save Network Session Scale Smalltalk sketch Complementary methods Creating object Angle Arc Circle Equation Geometric transformation Line straight 48 Locus Number distance coordinates 53 Object attributes Point Polygon Ray Segment Vector Examples Animation Baravelle spiral Pappus Chain Sierpinski triangle Teodoro spiral Execute Run Various messages Style Line Point Polygon Script Segment Mark Value Text 9 Property Tools Debugger Breakpoint Inspector Profiling Workspace Transformation Homothety Reflection Rotation Scale IND
75. to 404 a geometric angle defined by three points gt angle bisector of the angle a Example canvas angleBisector angle line canvas angleBisectorSummit sidel b side2 a b c points defining a geometric angle bac gt angle bisector of the angle bac Example canvas angleBisectorSummit 000 sidel 1 0 side2 001 20 ray canvas to o point or coordinate the origin p point or coordinates point anywhere on the ray ray defined by its origin and a second point Example canvas a canvas DrGeoCanvas new a canvas point 105 canvas ray 000 to a un D 09 D e segment canvas segment to p2 pi points or coordinates p2 points or coordinates segment defined by two points Example canvas a canvas DrGeoCanvas new a canvas point 505 canvas segment 10010 to a Circle circle canvas circleCenter to p point or coordinates centre of the circle p point or coordinates point on the circle gt circle defined by its centre and a point Example 90 CHAPTER 5 DR GEO SMALLTALK SKETCH canvas a canvas DrGeoCanvas new a canvas point 105 canvas circleCenter a to 1004 circle canvas circleCenter radius c point or coordinates centre of the circle r numeric item or numeric value radius gt circle defined by its centre and radius Example
76. to the problem originally carried out by Archimedes called although this phrase is not precisely accurate the method of exhaustion This approach has however the advantage of exposing the essence of the methodology Archimedes described a simple uler and compass construction of regular polygons in scribed inside and outside a circle and laborious calculations of the lengths of their sides doubling the number of sides at each step up to 96 In modern terms this gives three dig its of precision approximately 3 14 We however can proceed much more simply letting Dr GEOdo the hard work and continuing to polygons of more than a million sides which takes us nearly to the limits of ordinary computer arithmetic that is 16 decimal places for floating point numbers 3 141592653589793 Using much more advanced methods on supercomputers has made it possible to calculate ten trillion digits of 7 We start with the construction of an inscribed regular hexagon Create a numeric value and set it to 6 Create a segment the diameter and bisect it to get the center Create a circle with the given center through one of the endpoints of the segment Create a regular polygon with the given center one of the endpoints as a vertex and the numeric value as the number of sides The idea of the of the exhaustion method starts with approximating the length of the circle with the perimeter of the Po hexagon then to calculate an approximation of 7 as t
77. tor in the bottom will display script source code template such as the one shown in figure 4 1 c Input the source code as below and as shown in figure 4 2 myFirstScript Hello World is the traditional first program in any language It simply displays a text message Hello World 3A macro construction is geometry oriented whereas a script is numerically computation oriented For example mathematical functions 41 SCRIPT BY THE EXAMPLE 31 Save the script with CTRL S DR GEO will ask your last name and first name to track the history of the script modifications The first script line myFirstScript is the name of the script followed by the source code It is followed by an optional comment of one or more lines between quotation marks The comment should usually explain the purpose of the script what are the expected parameters and what are the conditions for its use We strongly encourage you to document carefully to prevent confusion and error DrGeoUserScripts approxPIpolygon diameter circumfrenceFromArc angle The comment of my first script A Hello Figure 4 2 My first script The script editor can now be closed 30 Using the script in the sketch Select Numeric Use a script in the menu In the displayed dialogue box choose the script myFirstScript Note each time a script is selected its descriptive comment is displayed in the bottom of the dialogue slope my
78. tsItem e DrGPolygonNptsItem e DrGValueItem To explore these classes open a workspace after a click in the background of the environment input and mouse select the class name to explore then press the shortcut CTRL B to open a class browser on it The following sections contain descriptions of some useful messages ordered by class 4 2 1 Math Item The protocol of the class DrGMathItem concerns all types of argument passed to a script string item safeName item mathematics item gt text representing the item name Example name 1 safeName name asUppercase To use this method in a script create a DR GEOmath item and give it a name with the style function Then create the script 8Tool Points Coordinates 4 2 REFERENCE METHODS FOR DR GEO SCRIPTS 37 myName item item safeName and use it as usual clicking on the point and then place to put the result Note that changing the name of the item and then forcing an update for example by moving the item updates the result of the script lt boolean gt item exist item mathematics item gt boolean indicating whether the item exists in the current state of the sketch Example line exist ifTrue position line origin collection item parents item mathematics item gt collection of the parents of this item Example pointi segment parents first In this example the parents of a segment j
79. um value aString name of the value gt block of code returning the current value of the ruler Action construct a ruler at the given position with a decimal value in the interval float float3 Example canvas AF canvas DrGeoCanvas new canvas float 1 at 1004 from to 10 name F canvas integer 3 at 1003 from O to 10 name F showValue true A value F value There are other variants some for integer values 5 9 Gallery of examples To illustrate the use of DR GEO Smalltalk sketches we present below a small set of exam ples It shows you some possibilities that we hope will inspire you for your own needs For each example for which we give the Smalltalk source code we encourage you to copy and paste it into DR GEO workspace and run the code 5 3 1 Animate a figure These examples rely on time handling and background processes We begin with a simple animation in order to understand the concept figure p pause figure DrGeoCanvas new NN figure point 0 0 pause Delay forSeconds 0 2 figure do 100 timesRepeat p mathItem moveTo p mathItem point 0 1 0 figure update 5 3 GALLERY OF EXAMPLES 99 pause wait The Delay class supports setting time intervals for pausing DR GEO The do and timeRepeat control structures repeat a code block that moves its argument item across the sketch The update is necessary so that the p
80. uting the function once At this point the application returns to its default state in which the user can select and move objects The user can abort any function before making the final selection with the Select and move button on the toolbar or the Edit gt Select and Move command This is in contrast to a modal application in which clicking a function button puts the application into a mode that allows the command to be used multiple times in succession The commands for editing object styles and properties are always modal allowing any number of objects to be modified without having to select the function repeatedly to apply it to each one The user has to explicitly exit them for example by returning to the select and move mode or starting some other command There is mode toggle button for single multiple creation which switches from this functional mode to this modal mode in which function selection is persistent That is selecting the line function allows the user to create multiple lines without having to select that function over again for each one When the user clicks one of these tabs an additional toolbar displays immediately It groups functions of the same family From left to right we have access to tools to build points and lines use transformations calculate values animate sketches and manage macro construction and execution These functions also appear in the menus at the top of every DR GEO window 1 1 1
81. w limits on what can be done with values In statically typed languages the type of variable has to be declared before it can be used and that type cannot be changed within the program In particular the sizes of arrays and other composite data structures must be declared in advance In dynamically typed languages a variable name can be repurposed to refer to an object of a different class with a simple assignment items can be added to or removed from data structures at will and the class definition can be changed while program is running Reflection in programming languages refers to the ability to examine and modify prop erties of objects within the live system rather than having to read the source code in which variables are declared to determine their types and infer their properties Reflection tools in Smalltalk include the system browser the inspector the object explorer and the method finder This abstract from the book preface Pharo By describes the Smalltalk envi ronment used by DR GEO Pharo is a modern Open Source development environment for the classic Smalltalk 80 programming language Wikipedia Smalltalk article http en wikipedia org wiki Smalltalk Page view the 24 Jully 2013 Contents under the license CC BY SA 3 0 http creativecommons org licenses by sa 3 0 deed fr http pharobyexample org 27 28 CHAPTER 4 DR GEO SMALLTALK SCRIPT Pharo strives to offer a lean Open Sou
Download Pdf Manuals
Related Search
Related Contents
Tecumseh AKA4460YXA Drawing Data Documento en PDF - Oxigenoterapia DermaOxy Cooper Lighting Halo L5300 User's Manual pertinence et mode d`emploi Input device including a scroll wheel assembly for manipulating an Manual de usuario Aplicación Técnica 2/2008. TARGET2 100a, 200a ul 98 non fusible disconnect switches Copyright © All rights reserved.
Failed to retrieve file