Eq is x*sin(theta) + y * cos(theta) = r
let's calculate r
--------------------------------------------------------------------
import numpy as np
def getpos(x,y,theta):
return x*np.sin(theta) + y * np.cos(theta)
output1 = []
output2 = []
output3 = []
for i in xrange(-90,90,20):
output1.append(getpos(6,1,i))
output2.append(getpos(4,2,i))
output3.append(getpos(1,4,i))
--------------------------------------------------------------------
output1 is [6,1]
output2 is [4,2]
output3 is [1,4]
Lets Draw Graph
--------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
def getpos(x,y,theta):
return x*np.sin(theta) + y * np.cos(theta)
output1 = []
output2 = []
output3 = []
for i in xrange(-90,90,20):
output1.append(getpos(6,1,i))
output2.append(getpos(4,2,i))
output3.append(getpos(1,4,i))
ThetaList = np.arange(-90,90,20)
print len(ThetaList)
print len(output1)
plt.plot(ThetaList,output1,ThetaList,output2,ThetaList,output3)
plt.show()
--------------------------------------------------------------------
This is Code For analysis and Save data
--------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import math
def getpos(x,y,theta):
return x*np.sin(theta) + y * np.cos(theta)
output1 = []
output2 = []
output3 = []
for i in xrange(-90,90,20):
output1.append(getpos(6,1,i))
output2.append(getpos(4,2,i))
output3.append(getpos(1,4,i))
ThetaList = np.arange(-90,90,20)
print len(ThetaList)
print len(output1)
plt.plot(ThetaList,output1,ThetaList,output2,ThetaList,output3)
plt.show()
AcArray1 = np.zeros((len(output1),len(ThetaList)),dtype='byte')
AcArray2 = np.zeros((len(output2),len(ThetaList)),dtype='byte')
AcArray3 = np.zeros((len(output3),len(ThetaList)),dtype='byte')
AcarrayList = [AcArray1,AcArray2,AcArray3]
OutputList = [output1,output2,output3]
for j in range(3):
for i in range(len(ThetaList)):
ycor = ycor1 = math.trunc(OutputList[j][i]) + 9
if ycor < 10 and ycor > -10 and ycor != 0:
if ycor > 0:
AcarrayList[j][i][ycor -1] += 1
else:
AcarrayList[j][i][ycor] += 1
print AcArray1
print AcArray2
print AcArray3
total = AcArray1 + AcArray2 + AcArray3
print total
print "----"
np.savetxt("test.txt",total,fmt = '%1.0f')
--------------------------------------------------------------------