kalpesh77's picture
Add clean reusable generation scripts + utils
5013cf3 verified
Raw
History Blame Contribute Delete
308 Bytes
import numpy as np
def point_on_hypersphere(n, theta):
"""Unit vector on n-sphere using angle theta in first two dimensions."""
v = np.zeros(n)
v[0] = np.cos(theta)
v[1] = np.sin(theta)
return v
def normalize(v):
norm = np.linalg.norm(v)
return v if norm < 1e-12 else v / norm