I have three datasets (numpy arrays) of coordinates (X, Y and X) representing a planar surface. I need to create a line that is perpendicular to the plane surface.
I got the data from another file, because I can't share it easily with you, I created a random pandas dataset the code I used to generate the data surface is as following:
cor_CTV = pd.DataFrame(np.random.randint(0,100,size=(100, 3)), columns = list('xyz'))
linear_data = np.c_[cor_CTV["x"], cor_CTV["y"], cor_CTV["z"]]
mn = np.min(linear_data, axis=0)
mx = np.max(linear_data, axis=0)
X,Y = np.meshgrid(np.linspace(mn[0], mx[0], 20), np.linspace(mn[1], mx[1], 20))
XX = X.flatten()
YY = Y.flatten()
A = np.c_[linear_data[:,0], linear_data[:,1], np.ones(linear_data.shape[0])]
C,_,_,_ = scipy.linalg.lstsq(A, linear_data[:,2])
Z = C[0]*X + C[1]*Y + C[2]
I would be very grateful if anyone can help me.