-------- Коды Matlab -----------------------------
theta=[0:pi/180:2*pi]; %set theta from 0(degree) to 360(degree)
ab=10.5;bc=42;cd=24;dx=42;dy=-17;ef=5;be=65;alpha=-90*pi/180;
p=2*cd*(dx-ab*cos(theta));
q=2*cd*(dy-ab*sin(theta));
r=dx^2+dy^2+ab^2+cd^2-bc^2-(2*ab*(dx*cos(theta)+dy*sin(theta)));
cosphi=((-p.*r)-(q.*sqrt((p.^2)+(q.^2)-(r.^2))))./(p.^2+q.^2);
sinphi=((-q.*r)+(p.*sqrt((p.^2)+(q.^2)-(r.^2))))./(p.^2+q.^2);
phi=atan2(sinphi,cosphi); %use atan2 code
cospsi=(dx+(cd*cos(phi))-(ab*cos(theta)))/bc;
sinpsi=(dy+(cd*sin(phi))-(ab*sin(theta)))/bc;
psi=atan2(sinpsi,cospsi);
fx=ab*cos(theta)+be*cos(psi)+ef*cos(psi+alpha);
fy=ab*sin(theta)+be*sin(psi)+ef*sin(psi+alpha); %get the coordinates from the variables above
plot(fx,fy); grid on
result=[theta*180/pi,fx,fy] %can get the data
приведенные выше коды работают в Matlab и дают сюжет. введите описание изображения здесь Я пытаюсь заменить Matlab на Python. Но я только начал Python (базовый c уровень), и мне очень сложно это сделать ...
Это Python коды, с которыми у меня проблемы.
import math
from matplotlib import pyplot as plt
import numpy as np
dx=42; dy=-17; ab=10.5; bc=42; cd=24; be=65; ef=5;
ml = np.arange(0, 2*math.pi, math.pi/180)
alpha = -90*math.pi/180;
P=2*cd*(dx-ab+math.cos(theta));
Q=2*cd*(dy-ab+math.ain(theta));
R=(dx**2)+(dy**2)+(ab**2)+(cd**2)-(bc**2)-(2*ab+(math.cos(theta))+dy+(math.sin(theta)));
math.cos(phi)=((-P*R)-(Q*math.sqrt((P**2)+(Q**2)-(R**2))))/((P**2)+(Q**2));
math.sin(phi)=((-Q*R)+(P*math.sqrt((P**2)+(Q**2)-(R**2))))/((P**2)+(Q**2));
phi=math.atan2(sinphi,cosphi);
math.cospsi=((dx+cd+(math.cos(phi)))-(ab+math.cos(theta)))/bc;
math.sinpsi=((dy+cd+(math.sin(phi)))-(ab+math.sin(theta)))/bc;
psi=math.atan2(math.sinpsi,math.cospsi);
Fx=ab*math.cos(theta)+be*math.cos(psi)+ef*math.cos(psi+alpha);
Fx=ab*math.sin(theta)+be*math.sin(psi)+ef*math.sin(psi+alpha);
plt.plot(Fx,Fy)
plt.show()
Data=[theta*180/math.pi,Fx,Fy];
File "<ipython-input-21-3dae4fe9fe6e>", line 5
math.cos(phi)=((-P*R)-(Q*math.sqrt((P**2)+(Q**2)-(R**2))))/((P**2)+(Q**2));
^
SyntaxError: can't assign to function call
* Я работаю над Jupyter Notebook.