In [1]:
import matplotlib.pyplot as plt 
import proofofConcept as poc
import numpy as np
import math as m

In [2]:
#define path 
path = "C://Users//Ymubarak//Documents//ME102B//me102b_lane_painter//ImageProcessing//squigly.txt"

In [3]:
# Make Image Object 
Im = poc.Image(path)
nodelist= Im.getNodes()

In [4]:
# seeing whole map shape  


x1 = [n.xloc for n in nodelist]
x2 = [n.yloc for n in nodelist]
plt.scatter(x1,x2)  
plt.show()



In [5]:
#testing the get neighbors function 

random_node = 30
n_size =4
n0 =nodelist[random_node]
ns = n0.findneighbors(nodelist,n_size) 
x = [n.xloc for n in ns]
y = [n.yloc for n in ns]
plt.scatter(x,y)    
plt.scatter(n0.xloc , n0.yloc)

close= Im.NearestNode([n0.xloc, n0.yloc])
ind = close[1]
closenode= close[0]
plt.scatter(closenode.xloc, closenode.yloc)
plt.show()



In [6]:
# #trying the least squares approach 
        
[n,error,x,y]=n0.gettangent(ns)

n
error

ran = np.array(list(range(-2,2))) 
yhat = n[0]*ran 
plt.scatter(x,y)
#plt.scatter(ran,yhat)
plt.show() 

op_adj = n[0][0]
m.atan(op_adj**-1) * 180/3.142


Out[6]:
-22.616932382545226

In [7]:
#Im.getNextStates(n_size) 
#ns = n0.findneighbors(nodelist,n_size) 
#Im.nodelist
n0.findneighbors(Im.getNodes(),n_size)

In [8]:
n0.where(nodelist)


Out[8]:
[30]

In [ ]:


In [ ]:


In [ ]: