Project

Forward kinematics

import math
import matplotlib.pyplot as plt

#inputs
n_theta = 10
theta_start = 0
theta_end = math.pi/2
x0=0
y0=0
l1=1
l2=0.5
q=0
theta1=[]

for i in range(0,n_theta):
	a = theta_start + i*(theta_end - theta_start)/(n_theta-1)
	theta1.append(a)
	theta2 = theta1
	
#print(theta1)
#print(theta2)

for i in theta1:
	for j in theta2:
		x1 = l1*math.cos(i)
		y1 = l1*math.sin(i)
		x2 = x1 + l2*math.cos(j)
		y2 = y1 + l2*math.sin(j)
		q=q+1
		figurename = str(q) + \'.png\'
	
		
		plt.figure()
		plt.plot([x0,x1],[y0,y1])
		plt.plot([x1,x2],[y1,y2])
		plt.xlim([0,2])
		plt.ylim([0,2])
		plt.savefig(figurename)
		#plt.show()

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.