# Analytic Geometry 1

These are found in the first chapter of an old analytic geometry book.

# Euclid Book 1 Proposition 3

Proposition 3 looks simple, but it uses Proposition 2 which uses Proposition 1. Prop 3 is in turn used by many other Propositions through the entire work.

For debugging it was handy to have a consistent not random pair of given lines, so I made a definite parameter start procedure, selected to look similar to the traditional start points.

```Sub prime_pr3()
'given two unequal lines AB and GH

Dim ptA(0 To 2) As Double
Dim ptB(0 To 2) As Double
Dim ptG(0 To 2) As Double
Dim ptH(0 To 2) As Double

Dim Ax As Double, Ay As Double
Dim Bx As Double, By As Double
Dim Gx As Double, Gy As Double
Dim Hx As Double, Hy As Double

Ax = rnddbl(0, 5)
Ay = rnddbl(0, 5)
Bx = rnddbl(15, 25)
By = rnddbl(0, 10)
Hx = rnddbl(-5, 0)
Hy = rnddbl(12, 18)
Gx = rnddbl(5, 5)
Gy = rnddbl(12, 18)

Call pt(ptA, Ax, Ay, 0)
Call pt(ptB, Bx, By, 0)
Call pt(ptG, Gx, Gy, 0)
Call pt(ptH, Hx, Hy, 0)

Call pr3_sub(ptA, ptB, ptG, ptH)

End Sub

Sub pump_pr3()
'hardwiring two unequal lines AB and GH

Dim ptA(0 To 2) As Double
Dim ptB(0 To 2) As Double
Dim ptG(0 To 2) As Double
Dim ptH(0 To 2) As Double

Call pt(ptA, 1, 1, 0)
Call pt(ptB, 10, 2, 0)
Call pt(ptG, 3, 8, 0)
Call pt(ptH, -3, 9, 0)

Call pr3_sub(ptA, ptB, ptG, ptH)

End Sub

Sub pr3_sub(ptA() As Double, ptB() As Double, ptG() As Double, ptH() As Double)

Dim r As Double
Dim intpts As Variant

Dim ptD(0 To 2) As Double
Dim ptE(0 To 2) As Double

'i copied sub for prop2 and only added object deletes
'at the bottom otherwise this is same as pr2
'pr2 calls its own pr1
Call pr3_pr2_sub(ptA, ptG, ptH)

'vertex found
ptD(0) = ptG1(0)
ptD(1) = ptG1(1)
ptD(2) = ptG1(2)

r = distance(ptA, ptD)

intpts = lineAB.IntersectWith(circF, acExtendNone)
Call intpts_eval(intpts)

'should only be one
ptE(0) = intpts(0)
ptE(1) = intpts(1)
ptE(2) = intpts(2)

lineAB.Delete
'circF.Delete

'labels
Dim th As Double
th = 1#

Call txt_h("A", ptA, th)
Call txt_h("B", ptB, th)
Call txt_h("D", ptD, th)
Call txt_h("E", ptE, th)

End Sub
```

# Euclid Book 1 Proposition 2

Euclid’s 2nd proposition draws a line at point A equal in length to a line BC. It uses proposition 1 and is used by proposition 3. I tried to make a generic program I could use for both the primary job of illustrating the theorem and for the purpose of being used by subsequent theorems, but it is simpler to separate those into two sub procedures. The programming was pretty easy except when a line is extended to meet a circle, there are two intersections, and one of them has to be selected. A good illustration with labeled objects helps keep it straight.

In autocad 1-2 is not a problem. The solution would be to copy or move the line endpoint to endpoint. In Euclid, lines cannot be moved. The compass cannot be used to transfer a distance by being picked up off the page. In autocad items are rigid. When two objects the same are copied to the same location they exactly coincide. Euclid’s 4th Axiom is “Things that coincide with one another are equal to one another”. This has caused remarks as to its real meaning. If you cannot move an object to super-impose, how would you know, and even if you could move them, no physical object will perfectly cover another. This common belief, things that are the same coincide, is intended to point to ideal form, like we have in a cad program.

```Sub prime_pr2()
'given ptA and lineBC call proposition2

Dim ptA(0 To 2) As Double
Dim ptB(0 To 2) As Double
Dim ptC(0 To 2) As Double

Dim Ax As Double, Ay As Double
Dim Bx As Double, By As Double
Dim Cx As Double, Cy As Double

Ax = rnddbl(0, 5)
Ay = rnddbl(0, 5)
Bx = rnddbl(6, 10)
By = rnddbl(0, 10)
Cx = rnddbl(6, 20)
Cy = rnddbl(15, 25)

Call pt(ptA, Ax, Ay, 0)
Call pt(ptB, Bx, By, 0)
Call pt(ptC, Cx, Cy, 0)

Call pr2(ptA, ptB, ptC)
End Sub

Sub pr2(ptA() As Double, ptB() As Double, ptC() As Double)

Dim r As Double
Dim intpts As Variant

Dim ptD(0 To 2) As Double
Dim ptG(0 To 2) As Double
Dim ptL(0 To 2) As Double

'now we need Euclid 1-1 to draw equilateral triangle
Call pr2_pr1_sub(ptA, ptB)

'vertex found
ptD(0) = ptG1(0)
ptD(1) = ptG1(1)
ptD(2) = ptG1(2)

'find ptG, do lineBG
r = distance(ptB, ptC)
intpts = lineBD.IntersectWith(circH, acExtendThisEntity)
Call intpts_eval(intpts)

'want ptG intersection farthest from ptD
If distance(ptD, ptG1) > distance(ptD, ptG2) Then
ptG(0) = ptG1(0)
ptG(1) = ptG1(1)
ptG(2) = ptG1(2)

Else
ptG(0) = ptG2(0)
ptG(1) = ptG2(1)
ptG(2) = ptG2(2)
End If

'now find ptL, do lineAL
r = distance(ptD, ptG)

Call intpts_eval(intpts)

'going to take the lesser y value
If ptG1(1) > ptG2(1) Then
ptG1(0) = ptG2(0)
ptG1(1) = ptG2(1)
ptG1(2) = ptG2(2)
End If

ptL(0) = ptG1(0)
ptL(1) = ptG1(1)
ptL(2) = ptG1(2)

'ptG1 is same as ptL
End Sub

Sub pr2_pr1_sub(ptA() As Double, ptB() As Double)
'just the bare necessities - no drawing - calculate vertex

Dim r As Double
r = distance(ptA, ptB)

r = distance(ptB, ptA)

Dim intpts As Variant
intpts = circD.IntersectWith(circE, acExtendNone)
Call intpts_eval(intpts)

'going to take positive y value
'this is how i am passing back found vertex
If ptG2(1) > ptG1(1) Then
ptG1(0) = ptG2(0)
ptG1(1) = ptG2(1)
ptG1(2) = ptG2(2)
End If

circD.Delete
circE.Delete

End Sub

```