 examples - Maple Help

Example Use of the Geometry Package Description

 • To view the output from the following examples in the Standard Worksheet interface, click the Open the current help page in a worksheet window icon. Click the Execute the entire worksheet icon. Examples

The following shows how to use the geometry package to illustrate theorems in Euclidean geometry.

Reference: Eves, Howard. A Survey of Geometry. Allyn and Bacon, 1972.

Theorem: (Feuerbach's Theorem) The nine-point circle of a triangle is tangent to the incircle and to each of the excircles of the triangle

 > $\mathrm{with}\left(\mathrm{geometry}\right):$

Define triangle ABC

 > $\mathrm{triangle}\left(T,\left[\mathrm{point}\left(A,0,0\right),\mathrm{point}\left(B,3,-1\right),\mathrm{point}\left(C,6,2\right)\right]\right):$

Find the incircle $\mathrm{inc}$ of ABC

 > $\mathrm{incircle}\left(\mathrm{inc},T,'\mathrm{centername}'=\mathrm{II}\right):$

Find the excircles $\mathrm{ex1}$, $\mathrm{ex2}$, $\mathrm{ex3}$ of ABC

 > $\mathrm{excircle}\left(\mathrm{obj},T,\left[\mathrm{ex1}\left(\mathrm{I1}\right),\mathrm{ex2}\left(\mathrm{I2}\right),\mathrm{ex3}\left(\mathrm{I3}\right)\right]\right):$

Find the nine-point circles $\mathrm{ec}$ of ABC

 > $\mathrm{EulerCircle}\left(\mathrm{ec},T,'\mathrm{centername}'=X\right):$

Check if $\mathrm{inc}$, $\mathrm{ex1}$, $\mathrm{ex2}$, $\mathrm{ex3}$ are tangent to $\mathrm{ec}$

 > $\mathrm{AreTangent}\left(\mathrm{ec},\mathrm{inc}\right);$$\mathrm{AreTangent}\left(\mathrm{ec},\mathrm{ex1}\right);$$\mathrm{AreTangent}\left(\mathrm{ec},\mathrm{ex2}\right)$
 > $\mathrm{AreTangent}\left(\mathrm{ec},\mathrm{ex3}\right)$
 > $\mathrm{draw}\left(\left[\mathrm{inc}\left(\mathrm{color}=\mathrm{yellow}\right),\mathrm{ec}\left(\mathrm{color}=\mathrm{plum}\right),\mathrm{ex1}\left(\mathrm{color}=\mathrm{green}\right),T\left(\mathrm{color}=\mathrm{blue},\mathrm{filled}=\mathrm{false}\right)\right],\mathrm{filled}=\mathrm{true},\mathrm{title}=\mathrm{Illustration of Feuerbach\text{'}s Theorem}\right)$

Theorem: In triangle A1A2A3 let M1, M2, M3 be the midpoints of the sides A2A3, A3A1, A1A2, H1, H2, H3 the feet of the altitudes on these sides, N1, N2, N3 the midpoints of the segments A1H, A2H, A3H, where H is the orthocenter of the triangle. Then the nine points M1, M2, M3, H1, H2, H3, N1, N2, N3 lie on a circle whose center N is the midpoint of the segment joining the orthocenter H to the circumcenter O of the triangle, and whose radius is half the circumradius of the triangle.

 > $\mathrm{with}\left(\mathrm{geometry}\right):$

Define the triangle A1A2A3

 > $\mathrm{triangle}\left(T,\left[\mathrm{point}\left(\mathrm{A2},0,0\right),\mathrm{point}\left(\mathrm{A1},2,4\right),\mathrm{point}\left(\mathrm{A3},7,0\right)\right]\right):$

Find the midpoints of A2A3, A1A3, A1A2

 > $\mathrm{midpoint}\left(\mathrm{M1},\mathrm{A2},\mathrm{A3}\right):$$\mathrm{midpoint}\left(\mathrm{M2},\mathrm{A3},\mathrm{A1}\right):$$\mathrm{midpoint}\left(\mathrm{M3},\mathrm{A1},\mathrm{A2}\right):$

Find the orthocenter and circumcenter of ABC

 > $\mathrm{orthocenter}\left(H,T\right):$$\mathrm{circumcircle}\left(c,T,'\mathrm{centername}'=\mathrm{O}\right):$

Find the altitudes of ABC

 > $\mathrm{altitude}\left(\mathrm{A1H1},\mathrm{A1},T,\mathrm{H1}\right):$$\mathrm{altitude}\left(\mathrm{A2H2},\mathrm{A2},T,\mathrm{H2}\right):$
 > $\mathrm{altitude}\left(\mathrm{A3H3},\mathrm{A3},T,\mathrm{H3}\right):$

Define the points N1, N2, N3

 > $\mathrm{midpoint}\left(\mathrm{N1},\mathrm{A1},H\right):$$\mathrm{midpoint}\left(\mathrm{N2},\mathrm{A2},H\right):$$\mathrm{midpoint}\left(\mathrm{N3},\mathrm{A3},H\right):$
 > $\mathrm{circle}\left(\mathrm{c1},\left[\mathrm{midpoint}\left(N,H,\mathrm{O}\right),\frac{1}{2}\mathrm{radius}\left(c\right)\right]\right):$

Check if M1, M2, M3, H1, H2, H3, N1, N2, N3 are on circle c1

 > $\mathrm{IsOnCircle}\left(\mathrm{M1},\mathrm{c1}\right);$$\mathrm{IsOnCircle}\left(\mathrm{M2},\mathrm{c1}\right);$$\mathrm{IsOnCircle}\left(\mathrm{M3},\mathrm{c1}\right)$
 > $\mathrm{IsOnCircle}\left(\mathrm{H1},\mathrm{c1}\right);$$\mathrm{IsOnCircle}\left(\mathrm{H2},\mathrm{c1}\right);$$\mathrm{IsOnCircle}\left(\mathrm{H3},\mathrm{c1}\right)$
 > $\mathrm{IsOnCircle}\left(\mathrm{N1},\mathrm{c1}\right);$$\mathrm{IsOnCircle}\left(\mathrm{N2},\mathrm{c1}\right);$$\mathrm{IsOnCircle}\left(\mathrm{N3},\mathrm{c1}\right)$
 > $\mathrm{draw}\left(\left[\mathrm{c1}\left(\mathrm{filled}=\mathrm{true},\mathrm{color}='\mathrm{COLOR}'\left(\mathrm{RGB},1.00000000,1.00000000,0.8000000000\right)\right),c\left(\mathrm{filled}=\mathrm{true},\mathrm{color}=\mathrm{green}\right),T\left(\mathrm{color}=\mathrm{blue}\right),N,\mathrm{M1},\mathrm{M2},\mathrm{M3},\mathrm{H1},\mathrm{H2},\mathrm{H3},\mathrm{N1},\mathrm{N2},\mathrm{N3},H\right],\mathrm{axes}=\mathrm{none}\right)$

The following shows how to use geometry package to construct curves based on the method called an envelope of circles.

Reference: Pedoe, Dan. Geometry And The Liberal Arts. St. Martin's Press, 1978.

cardioid:

 > $\mathrm{with}\left(\mathrm{geometry}\right):$

Define the base circle

 > $\mathrm{circle}\left(\mathrm{c0},\left[\mathrm{point}\left(o,0,0\right),1\right]\right):$

Generate a random point A0 on the circle which is the cusp of

the cardioid

 > $\mathrm{randpoint}\left(\mathrm{A0},\mathrm{c0}\right):$

Generate 80 circles which envelope the constructed cardioid

 > $i≔1:$$n≔80:$
 > $\mathbf{while}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i\le n\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{randpoint}\left(A‖i,\mathrm{c0}\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathbf{if}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{evalf}\left(\mathrm{HorizontalCoord}\left(\mathrm{A0}\right)-\mathrm{HorizontalCoord}\left(A‖i\right)\right)\ne 0\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{then}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{circle}\left(c‖i,\left[\mathrm{A0},A‖i\right]\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}i≔i+1\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{if}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$$\mathrm{draw}\left(\left\{\mathrm{seq}\left(c‖i,i=0..n\right)\right\},\mathrm{printtext}=\mathrm{false},\mathrm{title}=\mathrm{construction of a cardioid}\right)$

limacon de monsieur Pascal

 > $\mathrm{with}\left(\mathrm{geometry}\right):$

Define the base circle

 > $\mathrm{circle}\left(\mathrm{c0},\left[\mathrm{point}\left(o,0,0\right),1\right]\right):$

Pick a point outside the circle

 > $\mathrm{point}\left(\mathrm{A0},2,0\right):$

Generate 80 circles which envelope the constructed limacon

 > $i≔1:$$n≔80:$
 > $\mathbf{while}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i\le n\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{randpoint}\left(A‖i,\mathrm{c0}\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathbf{if}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{evalf}\left(\mathrm{HorizontalCoord}\left(\mathrm{A0}\right)-\mathrm{HorizontalCoord}\left(A‖i\right)\right)\ne 0\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{then}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{circle}\left(c‖i,\left[\mathrm{A0},A‖i\right]\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}i≔i+1\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{if}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$$\mathrm{draw}\left(\left\{\mathrm{seq}\left(c‖i,i=0..n\right)\right\},\mathrm{printtext}=\mathrm{false},\mathrm{title}=\mathrm{construction of a limacon de monsieur Pascal}\right)$

limacon without an inner loop

 > $\mathrm{with}\left(\mathrm{geometry}\right):$

Define the base circle

 > $\mathrm{circle}\left(\mathrm{c0},\left[\mathrm{point}\left(o,0,0\right),2\right]\right):$

Pick a point which is inside the circle c0

 > $\mathrm{point}\left(\mathrm{A0},1,0\right):$

Generate 80 circles which envelope the constructed limacon

 > $i≔1:$$n≔80:$
 > $\mathbf{while}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i\le n\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{randpoint}\left(A‖i,\mathrm{c0}\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathbf{if}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{evalf}\left(\mathrm{HorizontalCoord}\left(\mathrm{A0}\right)-\mathrm{HorizontalCoord}\left(A‖i\right)\right)\ne 0\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{then}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{circle}\left(c‖i,\left[\mathrm{A0},A‖i\right]\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}i≔i+1\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{if}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$$\mathrm{draw}\left(\left\{\mathrm{seq}\left(c‖i,i=0..n\right)\right\},\mathrm{printtext}=\mathrm{false},\mathrm{title}=\mathrm{construction of a limacon without an inner loop}\right)$

nephroid

 > $\mathrm{with}\left(\mathrm{geometry}\right):$

Define the base circle

 > $\mathrm{circle}\left(\mathrm{c0},\left[\mathrm{point}\left(o,0,0\right),1\right]\right):$

Pick a diameter of c0

 > $\mathrm{line}\left(l,\left[\mathrm{point}\left(M,0,-2\right),\mathrm{point}\left(N,0,2\right)\right]\right):$

Generates 100 points on the circle, and for each point

Ai, construct a circle with center Ai that touches the line l

 > $n≔100:$
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}n\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{randpoint}\left(A‖i,\mathrm{c0}\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{circle}\left(c‖i,\left[A‖i,\mathrm{distance}\left(A‖i,l\right)\right]\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$$\mathrm{draw}\left(\left\{\mathrm{seq}\left(c‖i,i=1..n\right)\right\},\mathrm{printtext}=\mathrm{false},\mathrm{title}=\mathrm{construction of a nephroid}\right)$

The following shows the use of transformations (translation, rotation and dilatation).

 > $\mathrm{with}\left(\mathrm{geometry}\right):$

An example of translation, rotation, and dilatation of circles

 > $\mathrm{angle}≔\mathrm{table}\left(\right):$
 > $n≔8:$
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}n\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{angle}\left[i\right]≔\frac{2\mathrm{\pi }i}{n}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$$\mathrm{dsegment}\left(\mathrm{dseg},\mathrm{point}\left(A,0,0\right),\mathrm{point}\left(B,4,0\right)\right):$$\mathrm{point}\left(o,0,0\right):$$\mathrm{circle}\left(c,\left[o,1\right]\right):$$\mathrm{homothety}\left(\mathrm{c1},c,\frac{3}{2},\mathrm{point}\left(M,-1,0\right)\right):$$\mathrm{homothety}\left(\mathrm{c2},c,2,\mathrm{point}\left(M,-1,0\right)\right):$$\mathrm{homothety}\left(\mathrm{c3},c,\frac{5}{2},\mathrm{point}\left(M,-1,0\right)\right):$$\mathrm{translation}\left(t,c,\mathrm{dseg}\right):$$\mathrm{translation}\left(\mathrm{tt},\mathrm{c1},\mathrm{dseg}\right):$$\mathrm{translation}\left(\mathrm{ttt},\mathrm{c2},\mathrm{dseg}\right):$$\mathrm{translation}\left(\mathrm{tttt},\mathrm{c3},\mathrm{dseg}\right):$$\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}8\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{rotation}\left(t‖i,t,\mathrm{angle}\left[i\right],\mathrm{counterclockwise},o\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{rotation}\left(\mathrm{tt}‖i,\mathrm{tt},\mathrm{angle}\left[i\right],\mathrm{counterclockwise},o\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{rotation}\left(\mathrm{ttt}‖i,\mathrm{ttt},\mathrm{angle}\left[i\right],\mathrm{counterclockwise},o\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{rotation}\left(\mathrm{tttt}‖i,\mathrm{tttt},\mathrm{angle}\left[i\right],\mathrm{counterclockwise},o\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$$\mathrm{square}\left(\mathrm{sqr},\left[\mathrm{point}\left(A,-8,-8\right),\mathrm{point}\left(B,8,-8\right),\mathrm{point}\left(C,8,8\right),\mathrm{point}\left(E,-8,8\right)\right]\right):$$\mathrm{draw}\left(\left[\mathrm{seq}\left(\mathrm{op}\left(\left[t‖i\left(\mathrm{color}=\mathrm{red}\right),\mathrm{tt}‖i\left(\mathrm{color}=\mathrm{green}\right),\mathrm{ttt}‖i\left(\mathrm{color}=\mathrm{blue}\right),\mathrm{tttt}‖i\left(\mathrm{color}=\mathrm{plum}\right)\right]\right),i=1..n\right),\mathrm{sqr}\left(\mathrm{color}='\mathrm{COLOR}'\left(\mathrm{RGB},1.00000000,1.00000000,0.8000000000\right)\right)\right],\mathrm{printtext}=\mathrm{false},\mathrm{filled}=\mathrm{true},\mathrm{axes}=\mathrm{none},\mathrm{title}=\mathrm{An example of translation, rotation, dilatation of a circle}\right)$ References

 Eves, Howard.  A Survey of Geometry. Allyn and Bacon, 1972.
 Pedoe, Daniel.  Geometry and the Liberal Arts. St. Martin's Press, 1978.