def computeNz(N): Nx, Ny = N[:, 0], N[:, 1] Nxy_sq = l2NormVectors(Nx) + l2NormVectors(Ny) Nz_sq = 1.0 - Nxy_sq Nz_sq = np.clip(Nz_sq, 0.0, 1.0) Nz = np.sqrt(Nz_sq) Nz = np.clip(Nz, 0.0, 1.0) N_new = np.array(N) N_new[:, 2] = Nz return N_new
def NxyToNz(N_32F): N = N_32F.reshape(-1, 3) Nx, Ny = N[:, 0], N[:, 1] Nxy_sq = l2NormVectors(Nx) + l2NormVectors(Ny) Nz_sq = 1.0 - Nxy_sq Nz_sq = np.clip(Nz_sq, 0.0, 1.0) Nz = np.sqrt(Nz_sq) Nz = np.clip(Nz, 0.0, 1.0) N_new = np.array(N) N_new[:, 2] = Nz return N_new.reshape(N_32F.shape)