Dies ist der Spaghetti-Code, den ich gemacht habe, als ich versuchte, ihn zu vereinfachen. Eine Lektion in Ironie kann man hier lernen, lol
Code: Select all
print("This program finds the coordinates of a triangle given only it's side lengths.Due to floating point approximations there can be errors but sometimes impossible coordinates may also be the result of invalid inputs.")
#mathematical denotation of a,b and c are the sides that do not touch the respective points.Hence a=bc,b=ac and c=ab
t=0
while t>=0:
c,a,b=eval(input("Enter side lengths AB,BC and AC:"))
f=c-a
n=(b-f)/2
x=f*(c+a)
z=2*b*c
w=b**2
hlftanBAC=((2*z/(x+w+z))-1)**(1/2)
tanBAC=((z/(x+w))+1)*hlftanBAC
hlftanBCA=hlftanBAC*(1+(f/n))
tanBCA=((2*a*b/(w-x))+1)*hlftanBCA
h=b/(tanBCA+tanBAC)
y=h*tanBCA
print("The coordinates are (0,0),(",b,",0) and (",h,",",y,").")
t+=1
Mobile version