so I am new to python, im using it for a couple classes, I am making programs to run calculations. here I have my code for 3 dimensional vectors, I ran into an issue however when I input a vector with Fx=0 Fy=-6 and Fz=8, it gave me a math domain error when computing the variable s. I tried the math by hand, works fine, had it print all the variables used for s just prior to the error and did the line of math code by hand using the numbers and it checks out, and it works for just about every other 3d vector ive thrown at it, im not sure why it crashes there. also if you have any advice on how to do it better, I am all ears (though I appreciate any links to code or pips to import, I have to write the code itself to be able to use it for class). code below:
#blue triangle
#if else
import math
a=input('what is the altitude angle theta z:')
s=input('what is the swing angle phi:')
F=input('what is the magnitude:')
Fx=input('what is the Fx component:')
Fy=input('what is the Fy component:')
Fz=input('what is the Fz component:')
#Blue triangle functions (Magnitude, Theta z, phi)
if a !='' and s!='' and F!='':
print('---------------------------------------------------------------------------------------')
#a = input('what is the altitude angle theta z:')
#s = input('what is the swing angle phi:')
#F = input('what is the magnitude:')
a=float(a)
s=float(s)
F=float(F)
Sa = math.sin(math.radians(a))
Ca = math.cos(math.radians(a))
Ss = math.sin(math.radians(s))
Cs = math.cos(math.radians(s))
Fx = F*Sa*Cs
Fy = F*Sa*Ss
Fz = F*Ca
print(' Fx=',Fx)
print(' Fy=',Fy)
print(' Fz=',Fz)
print(' Unit vector <',round(Fx/F,4), round(Fy/F,4), round(Fz/F,4), '>')
Fx=''
#Blue triangle functions (Fx,Fy,Fz)
if Fx!='' and Fy!='' and Fz!='':
print('---------------------------------------------------------------------------------------')
Fx=float(Fx)
Fy=float(Fy)
Fz=float(Fz)
F=math.sqrt((Fx**2)+(Fy**2)+(Fz**2))
a=math.degrees(math.acos(Fz/F))
s=math.degrees(math.asin((Fy/(F*math.sin(math.radians(a))))))
print(' Force=',F)
print(' Altitude of theta z=',a)
print(' planar swing angle phi=',s)
print(' Unit vector <',round(Fx/F,4), round(Fy/F,4), round(Fz/F,4), '>')
print('done')