Hello. Im new to the forums here and new to python. Forgive me if i do something wrong.
I have been working on this fairly simple code and can't seem to get it to print correct answers.
It's basically 3 equations (a,b,c) and three unknowns (x,y,z). The unknowns are obviously angles. I know the equations work because i have used them in matlab and arduino. Again, i'm really new to python... basically just started yesterday. Let me know what i messed up or if im going about this wrong.
Thanks.
Also the answers i constantly get are (0,-51,-58). I have no clue why and it also doesnt change when I change input values.
I have been working on this fairly simple code and can't seem to get it to print correct answers.
It's basically 3 equations (a,b,c) and three unknowns (x,y,z). The unknowns are obviously angles. I know the equations work because i have used them in matlab and arduino. Again, i'm really new to python... basically just started yesterday. Let me know what i messed up or if im going about this wrong.
Thanks.
from scipy.optimize import fsolve import math import numpy as np d=0 h=6 j=6 k=4 def equations(p): x=p[0] y=p[1] z=p[2] a=-math.cos(math.radians(x))*d*(math.cos(math.radians(y))*math.sin(math.radians(z))+math.cos(math.radians(z))*math.sin(math.radians(y)))+math.cos(math.radians(x))*(math.cos(math.radians(y))*j+k*(math.cos(math.radians(y))*math.sin(math.radians(z))+math.cos(math.radians(z))*math.sin(math.radians(y)))); b=-math.sin(math.radians(x))*d*(math.cos(math.radians(y))*math.sin(math.radians(z))+math.cos(math.radians(z))*math.sin(math.radians(y)))+math.sin(math.radians(x))*(math.cos(math.radians(y))*j-k*(math.cos(math.radians(y))*math.sin(math.radians(z))+math.cos(math.radians(z))*math.sin(math.radians(y)))); c=math.sin(math.radians(y))*j+k*(math.cos(math.radians(y))*math.cos(math.radians(z))-math.sin(math.radians(y))*math.sin(math.radians(z)))+d*(math.cos(math.radians(y))*math.cos(math.radians(z))-math.sin(math.radians(y))*math.sin(math.radians(z)))+h; return (a,b,c) p = fsolve(equations,(10,0,6)) w=round(p[0]),round(p[1]),round(p[2]) print w
Also the answers i constantly get are (0,-51,-58). I have no clue why and it also doesnt change when I change input values.