Skip to content

Instantly share code, notes, and snippets.

# @ is explicit operator for the dot product
def proj_matrix(v):
return v @ np.linalg.inv(v.T@v) @ v.T
def proj(vector, plane):
return proj_matrix(vector) @ plane
import numpy as np
#create the vectors
x = np.array([3,5])
s = np.array([3,2])
#use the formula
projection_x_on_s = (np.dot(x,s)/np.dot(x,x))*s
print(projection_x_on_s)
### Keybase proof
I hereby claim:
* I am toyballz on github.
* I am toyballz (https://keybase.io/toyballz) on keybase.
* I have a public key ASDOQTH6n30d7e07_vBfQLditFh2KyFTrsh_X7ZTFqGKrAo
To claim this, I am signing this object: