DrGeoII DSL for Euclid sketches - Summary October 2018

classic Classic list List threaded Threaded
1 message Options
HJH
Reply | Threaded
Open this post in threaded view
|

DrGeoII DSL for Euclid sketches - Summary October 2018

HJH
This post was updated on .
Hello Hilaire

Below is a summary of the DrGeoII DSL commands used for the Euclid sketches posted in this forum in September and October.

"Get a DrGeoCanvas Morph to develop the sketch, no GUI"
"Commands are terminated by a full stop."
"Comments are in double quotes."
"Assignment to variables is done with := "

c := DrGeoCanvas minimal.

"To set the extent in pixel do"
c view extent: 500@500.


"Create a new point object and assign it to a variable called ptA.
The expression 0@0 means that the x value is 0 and the y value is 0 in the coordinate system.
First the x value, then the y value."

ptA := c point: 0@0.

"To add a label to the new point"

ptA name: 'center'.



"Create a ray with origin at ptA and defined by another point at x=1 and y=0."

ray := c ray: ptA to: 1@0.


"The commands are self-explanatory to a large extent, for example to create a circle there is."
circle := c circle: ptA radius 1.

"Create line object"
line := c line: ptA to: 0@1.


"Create a new point B as the intersection of the circle and the line."

ptB := c intersection: circle and: line.

"As there often are two intersection points you get the second one with"

ptC := c altIntersection: circle and: line.
ptC name: 'C'.


"To control the formatting:"
ray dashed.
line dotted.
line large  "thick line"

"After the sketch has been created you might want to hide some helper lines or rays."

ray hide.


"If you like to have a grid and axes displayed then do"
c axesOn.
c gridOn.

"The sketch may also be scaled with"
c scale: 20.

"The display area of the coordinate grid may be changed by choosing a different center with"
c centerTo: 6@4.

This summary may serve as a kind of 'cheat sheet' which covers a lot of the needed commands to write DrGeoII sketches.


Comments?

Regards
Hannes


--------------------------------------------
List of sketches
--------------------------------------------
Book 1
http://forum.drgeo.eu/Euclid-book-I-Proposition-1-Construct-an-equilateral-triangle-given-a-straight-line-td4025447.html DONE
http://forum.drgeo.eu/Euclid-book-I-proposition-10-bisect-a-given-finite-straight-segment-td4025462.html  DONE
http://forum.drgeo.eu/Euclid-s-elements-book-I-proposition-11-td4025464.html   DONE **
http://forum.drgeo.eu/Euclid-book-I-proposition-12-td4025463.html   DONE
http://forum.drgeo.eu/Euclid-book-IV-proposition-15-td4025456.html DONE

Book 4
http://forum.drgeo.eu/Euclid-book-IV-proposition-6-7-and-8-td4025458.html
    6 DONE
    7 TODO
    8 TODO


** minor issue with showing dotted lines in Squeak 5.2.

--------------------------------------------
Source: HH-NB Aug18-p.67
--------------------------------------------

==============================================================
Below markdown, e.g. https://stackedit.io
==============================================================

# Euclid book 1
## Proposition 1

    | c ptA ptB ptC  
    circleA circleB  
    ptD ptE ptG ptH  
    segAB rayAB rayBA  
    lineAC lineCB |  
      
    c := DrGeoSketch minimal.  
    c scale: 100.
          
    "Given is a segment AB"  
    ptA := c point: -1@0.  
    ptA name: 'A'.  
      
    ptB := c point: 1@0.  
    ptB name: 'B'.
      
    segAB := c segment: ptA to: ptB.  
      
    "Use two circles to get point C"  
    circleA := c circleCenter: ptA to: ptB.  
    circleB := c circleCenter: ptB to: ptA.  
      
    ptC := c intersectionOf: circleB and: circleA.  
    ptC name: 'C'.  
      
    "The equilateral triangle is given by the points A,B and C.  
    thus construct the segments."  
    c segment: ptA to: ptC.  
    c segment: ptB to: ptC.  
      
      
    "-- get additional points D, E, G and H with hidden helper lines"  
    rayBA := c ray: ptB to: ptA.  
    ptD := c altIntersectionOf: circleA and: rayBA.  
    ptD name: 'D'.  
    rayBA hide.  
      
    rayAB := c ray: ptA to: ptB.  
    ptE := c altIntersectionOf: circleB and: rayAB.  
    ptE name: 'E'.  
    rayAB hide.  
      
    lineAC := c line: ptA to: ptC.  
    ptG := c intersectionOf: circleA and: lineAC.  
    ptG name: 'G'.  
    lineAC hide.  
      
    lineCB := c line: ptB to: ptC.  
    ptH := c intersectionOf: circleB and: lineCB.  
    ptH name: 'H'.  
    lineCB hide.
    
    "second intersection point of the circles"  
    ptF := c altIntersectionOf: circleB and: circleA.  
    ptF name: 'F'.
    
    c view area extent: 700@700.
    c view area color: Color white.
    c view area openInWorld.



## Proposition 10
https://mathcs.clarku.edu/~djoyce/elements/bookI/propI10.html

Let AB be a given straight segment. 

    | c ptA ptB ptC ptD ptE 
    circleA circleB
    segAB segCE  |
    
     c := DrGeoSketch minimal.
     c scale: 100.
    
     "Given is a segment AB"
     ptA := c point: -1@0.
     ptA name: 'A'.
    
     ptB := c point: 1@0.
     ptB name: 'B'.
    
     segAB := c segment: ptA to: ptB.
    
     "Use two circles to get point C" 
     circleA := c circleCenter: ptA to: ptB.
     circleB := c circleCenter: ptB to: ptA.
    
     ptC := c intersectionOf: circleB and: circleA.
     ptC name: 'C'.
    
     ptE := c altIntersectionOf: circleB and: circleA.
     ptE name: 'E'.
    
     segCE := c segment: ptC to: ptE. 
     ptD := c intersectionOf: segAB  and: segCE.
     ptD name: 'D'.
    
     c view area extent: 700@700.
     c view area color: Color white.
     c view area openInWorld.



The markdown code above translated to GNU TexInfo with
http://pandoc.org/try/

@node Top
@top Top

@menu
* Euclid book 1::
@end menu

@node Euclid book 1
@chapter Euclid book 1
@anchor{#euclid-book-1}
@menu
* Proposition 1::
* Proposition 10::
@end menu

@node Proposition 1
@section Proposition 1
@anchor{#proposition-1}

@verbatim
| c ptA ptB ptC  
circleA circleB  
ptD ptE ptG ptH  
segAB rayAB rayBA  
lineAC lineCB |  
  
c := DrGeoSketch minimal.  
c scale: 100.
      
"Given is a segment AB"  
ptA := c point: -1@0.  
ptA name: 'A'.  
  
ptB := c point: 1@0.  
ptB name: 'B'.
  
segAB := c segment: ptA to: ptB.  
  
"Use two circles to get point C"  
circleA := c circleCenter: ptA to: ptB.  
circleB := c circleCenter: ptB to: ptA.  
  
ptC := c intersectionOf: circleB and: circleA.  
ptC name: 'C'.  
  
"The equilateral triangle is given by the points A,B and C.  
thus construct the segments."  
c segment: ptA to: ptC.  
c segment: ptB to: ptC.  
  
  
"-- get additional points D, E, G and H with hidden helper lines"  
rayBA := c ray: ptB to: ptA.  
ptD := c altIntersectionOf: circleA and: rayBA.  
ptD name: 'D'.  
rayBA hide.  
  
rayAB := c ray: ptA to: ptB.  
ptE := c altIntersectionOf: circleB and: rayAB.  
ptE name: 'E'.  
rayAB hide.  
  
lineAC := c line: ptA to: ptC.  
ptG := c intersectionOf: circleA and: lineAC.  
ptG name: 'G'.  
lineAC hide.  
  
lineCB := c line: ptB to: ptC.  
ptH := c intersectionOf: circleB and: lineCB.  
ptH name: 'H'.  
lineCB hide.

"second intersection point of the circles"  
ptF := c altIntersectionOf: circleB and: circleA.  
ptF name: 'F'.

c view area extent: 700@700.
c view area color: Color white.
c view area openInWorld.
@end verbatim

@node Proposition 10
@section Proposition 10
@anchor{#proposition-10}
https://mathcs.clarku.edu/~djoyce/elements/bookI/propI10.html

Let AB be a given straight segment.

@verbatim
| c ptA ptB ptC ptD ptE 
circleA circleB
segAB segCE  |

 c := DrGeoSketch minimal.
 c scale: 100.

 "Given is a segment AB"
 ptA := c point: -1@0.
 ptA name: 'A'.

 ptB := c point: 1@0.
 ptB name: 'B'.

 segAB := c segment: ptA to: ptB.

 "Use two circles to get point C" 
 circleA := c circleCenter: ptA to: ptB.
 circleB := c circleCenter: ptB to: ptA.

 ptC := c intersectionOf: circleB and: circleA.
 ptC name: 'C'.

 ptE := c altIntersectionOf: circleB and: circleA.
 ptE name: 'E'.

 segCE := c segment: ptC to: ptE. 
 ptD := c intersectionOf: segAB  and: segCE.
 ptD name: 'D'.

 c view area extent: 700@700.
 c view area color: Color white.
 c view area openInWorld.
@end verbatim