You are on page 1of 2

import math

accepting = True
state = 0

while accepting:
if state == 0:
side = input("Side (L/R): ").lower()
if side == "l":
side = 1
state = 1
elif side == "r":
side = -1
state = 1
else:
pass
elif state == 1:
try:
part_a_w = float(input("Root part width: "))
state = 2
except ValueError:
print("Input must be a number!")
elif state == 2:
try:
part_a_h = float(input("Root part height: "))
state = 3
except ValueError:
print("Input must be a number!")
elif state == 3:
try:
part_a_x = float(input("Root part x: "))
state = 4
except ValueError:
print("Input must be a number!")
elif state == 4:
try:
part_a_y = float(input("Root part y: "))
state = 5
except ValueError:
print("Input must be a number!")
elif state == 5:
try:
part_a_z = float(input("Root part z: "))
state = 6
except ValueError:
print("Input must be a number!")
elif state == 6:
if part_a_z < 0:
part_a_z += 360
accepting = False
accepting_2 = True

w_b = math.sin(math.radians(part_a_z)) * (part_a_w / 2)


w_a = math.cos(math.radians(part_a_z)) * (part_a_w / 2)

h_b = math.sin(math.radians(part_a_z)) * part_a_h


h_a = math.cos(math.radians(part_a_z)) * part_a_h

if side == 1:
root_x = part_a_x - h_b - w_a
root_y = part_a_y + h_a - w_b
elif side == -1:
root_x = part_a_x - h_b + w_a
root_y = part_a_y + h_a + w_b

state = 1

while accepting_2:

if state == 1:
try:
part_b_w = float(input("Secondary part width: "))
state = 2
except ValueError:
print("Input must be a number!")
elif state == 2:
try:
part_b_z = float(input("Secondary part z: "))
state = 3
except ValueError:
print("Input must be a number!")
elif state == 3:
if part_b_z < 0:
part_b_z += 360
accepting_2 = False

w_b = math.sin(math.radians(part_b_z)) * (part_b_w / 2)


w_a = math.cos(math.radians(part_b_z)) * (part_b_w / 2)

part_x = root_x + w_a * side


part_y = root_y + w_b * side

print(round(part_x, 6))
print(round(part_y, 6))

while True:
if input("Press any key to exit... "):
break

You might also like