Its called the Geometry "Helper" because I couldn't figure out how to find the orthocenter of a triangle using python. It solves everything up to the algebra part, that's where the human comes in. This is kinda experimental because I haven't tested everything out but so far it has 5 features.
Notes:
Known Bugs:
If you have any suggestions for the next version, please tell me
P.Son't run this in the IDLE unless you want a black window popping up every two seconds
Notes:
- Finds the slope of a line
- Can tell if a line is perpendicular or parallel to another
- Finds the orthocenter of a triangle(kinda)
- Can tell if a triangle is a right triangle
- Finds the midpoint of a line
- If you find bugs please tell me
- If you know how to use algebra in python please tell me
- It is a little sloppy, just thought that today's challenge would lead to the ease of tomorrow's geometry homework
Known Bugs:
- When finding the slope sometimes it will spit out a zero instead of a fraction or a decimal
- Has error's in finding slope when zero's are involved(It says "Cannot divide by 0" even when I solve it without having to divide by 0)
If you have any suggestions for the next version, please tell me
P.Son't run this in the IDLE unless you want a black window popping up every two seconds
Code:
import os
import platform
def clearer():
systemver=platform.release()
if systemver=='XP':
os.system("cls")
elif systemver=='Vista':
os.system("clear")
else:
os.system("clear")
def menu():
print 'To find the slope of a line, press:1'
print 'To see if a line is perpendicular or parallel to another, press:2'
print 'To find the orthocenter of a triangle, press: 3'
print 'To see if a triangle is a right triangle, press: 4'
print 'To find the midpoint of a line, press: 5'
x = int(raw_input("What do you want to do?: "))
clearer()
if x==1:
slope()
if x==2:
paraperp()
if x==3:
ortho()
if x==4:
right()
if x==5:
mid()
if x > 4:
print 'Please pick a number between 1 and 4'
raw_input('Press enter to continue')
clearer()
menu()
if x < 1:
print 'Please pick a number between 1 and 4'
raw_input('Press enter to continue')
clearer()
menu()
def slope(): #Add error handling
x1 = int(raw_input("What is the first x coordinate?:"))
clearer()
x2 = int(raw_input("What is the second x coordinate?:"))
clearer()
y1 = int(raw_input("What is the first y coordinate?:"))
clearer()
y2 = int(raw_input("What is the second y coordinate?:"))
clearer()
print 'Solving.....'
print (y2 - y1) / (x2 - x1)
raw_input('Press enter to continue')
clearer()
print 'To return to the menu, press:1'
print 'To find another slope, press:2'
x = int(raw_input("What would you like to do?:"))
clearer()
if x==1:
menu()
if x==2:
slope()
def paraperp():
print 'If you have not found your two slopes, press: 1'
print 'If you have already found your two slopes, press: Enter'
z = raw_input("What would you like to do?:")
if z==1:
clearer()
slope()
clearer()
print 'If one of your slopes are in decimal or fraction form, press:1'
print 'If not, press: 2'
a = input('What would you like to do')
clearer()
if a==1:
perp()
if a==2:
perpa()
def perp():
q = int(raw_input('What is the numerator of the fraction?:'))
w = int(raw_input('What is the denominator of the fraction?:'))
e = int(raw_input('What is the second slope?:'))
r = q / w
if r.denominator==-(e.numerator):
print 'The lines are perpendicular'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a line is perpendicular or parallel to another, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
paraperp()
if r.numerator==-(e.denominator):
print 'The lines are perpendicular'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a line is perpendicular or parallel to another, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
paraperp()
else:
print 'The lines are not perpendicular'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a line is perpendicular or parallel to another, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
paraperp()
def perpa():
x = int(raw_input("What is the first slope?:"))
clearer()
y = int(raw_input("What is the second slope?:"))
clearer()
print 'solving......'
if x==y:
print 'The lines are parallel'
raw_input('Press enter to continue')
clearer()
print 'To return to the main menu, press:1'
print 'To see if a line is perpendicular or parallel to another, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
paraperp()
if not x==y:
print 'The lines are not perpendicular or parallel'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a line is perpendicular or parallel to another, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
paraperp()
def ortho():# First point is a,b 2nd is c,d third is e,f
a = int(raw_input("What is the x coordinate of the first point?:"))# let coords a,b = point A
clearer()
b = int(raw_input("What is the y coordinate of the first point?:"))
clearer()
c = int(raw_input("What is the x coordinate of the second point?:"))# let coords c,d = point B
clearer()
d = int(raw_input("What is the y coordinate of the second point?:"))
clearer()
e = int(raw_input("What is the x coordinate of the third point?:"))# let coords e,f = point C
clearer()
f = int(raw_input("What is the y coordinate of the third point?:"))
clearer()
g = (d - b) / (c - a)#slope of line AB
h = (f - b) / (e - a)#slope of line BC
i = (f - d) / (e - c)#slope of line AC
#begin defining midpoints
j = (a + c) / 2# x,y of midpoint of line AB
k = (b + d) / 2
l = (c + e) / 2#x,y of midpoint of line BC
m = (d + f) / 2
n = (e + a) / 2#x,y of midpoint of line AC
o = (f + b) / 2
p = (m - b) / (l - a) # Slope of A and midpoint of BC
q = (o - d) / (n - c) # Slope of B and midpoint of AC
print 'This is as far as I can take you my friend, as I can not do algebra, but I will show you the path to knowledge'
print 'Let the first point you gave me = A'
print 'Let the second point you gave me = B'
print 'Let the third point you gave me = C'
print 'Let the midpoint of BC = M'
print 'Let the midpoint of AC = N'
raw_input('Write this information down, then press enter')
clearer()
print 'The slope of AM is:'
print p
print 'The slope of BN is:'
print q
print 'Use the equation y=mx+b, I will break this down for you, the equation is:'
print b
print '='
print p
print a
print '+ b'
print 'Your jobs is to solve for b, then the you have the equation of AM'
raw_input('Write this information down, then press enter')
clearer()
print 'Now use y=mx+b to find the equation for BN'
print d
print '='
print q
print c
print '+ b'
print 'Again, solve for b, then you have the equation for AM and BN'
raw_input('Write this information down, then press enter')
clearer()
print 'Finally, to find the x,y of the orthocenter'
print 'You write both equations equalling each other without the "y"(ex: mx+b=mx+b)'
print 'That solved for x, now for y:'
print 'Use one of your equations(doesnt matter which one) and plug in the x coordinate found in the last step to find y.'
raw_input('You are done, press enter to continue')
clearer()
print 'To return to the main menu, press:1'
print 'To find another orthocenter, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
ortho()
def mid():
x1 = int(raw_input("What is the first x coordinate?:"))
clearer()
x2 = int(raw_input("What is the second x coordinate?:"))
clearer()
y1 = int(raw_input("What is the first y coordinate?:"))
clearer()
y2 = int(raw_input("What is the second y coordinate?:"))
clearer()
print 'Solving.....'
x = (x1 + x2) / 2
y = (y1 + y2) / 2
print 'The x coordinate is:'
print x
print 'The y coordinate is'
print y
print 'To return to the main menu, press:1'
print 'To find another midpoint, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
mid()
def right():
a = int(raw_input("What is the x coordinate of the first point?:"))# let coords a,b = point A
clearer()
b = int(raw_input("What is the y coordinate of the first point?:"))
clearer()
c = int(raw_input("What is the x coordinate of the second point?:"))# let coords c,d = point B
clearer()
d = int(raw_input("What is the y coordinate of the second point?:"))
clearer()
e = int(raw_input("What is the x coordinate of the third point?:"))# let coords e,f = point C
clearer()
f = int(raw_input("What is the y coordinate of the third point?:"))
clearer()
g = (d - b) / (c - a)#slope of line AB
h = (f - b) / (e - a)#slope of line BC
i = (f - d) / (e - c)#slope of line AC
if g.denominator==-(h.numerator):#GH
print 'The triangle is a right triangle'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a triangle is a right triangle, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
right()
if g.numerator==-(h.denominator):
print 'The triangle is a right triangle'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a triangle is a right triangle, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
right()
if g.denominator==-(i.numerator):#GI
print 'The triangle is a right triangle'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a triangle is a right triangle, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
right()
if g.numerator==-(i.denominator):
print 'The triangle is a right triangle'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a triangle is a right triangle, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
right()
if h.denominator==-(i.numerator):#HI
print 'The triangle is a right triangle'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a triangle is a right triangle, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
right()
if h.numerator==-(i.denominator):
print 'The triangle is a right triangle'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a triangle is a right triangle, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
right()
else:
print 'The triangle is not a right triangle'
raw_input('Press enter to continue')
print 'To return to the main menu, press:1'
print 'To see if a triangle is a right triangle, press:2'
v = int(raw_input("What would you like to do?:"))
clearer()
if v==1:
menu()
if v==2:
right()
menu()