def generate_cone_bilinear(direction_vec, lim_angle, start_num_pts): phi = np.arctan2(direction_vec[1], direction_vec[0]) theta = np.arcsin(np.sqrt(direction_vec[1]**2 + direction_vec[0]**2)) num_samp = np.ceil(np.sqrt(start_num_pts)) alpha = np.linspace(-lim_angle, 0, num_samp, endpoint=False) * np.pi / 180. angle = np.linspace(0, 2. * np.pi, num_samp, endpoint=False) (Alpha, Angle) = np.meshgrid(alpha, angle) X = np.cos(Angle) * np.sin(Alpha) Y = np.sin(Angle) * np.sin(Alpha) Z = np.cos(Alpha) x = X.reshape((1, num_samp * num_samp)) y = Y.reshape((1, num_samp * num_samp)) z = Z.reshape((1, num_samp * num_samp)) res = np.vstack((x, y, z)) rotz = rodrigues(-phi, [0, 0, 1]) rottheta = rodrigues(-theta, [1, 0, 0]) finalrot = np.dot(rottheta, rotz) res = np.dot(finalrot, res) return np.hstack((direction_vec[:, np.newaxis], res)) return res
def calculateMatrixFromTilt(self, tiltx, tilty, tiltz, tiltThenDecenter=0): if tiltThenDecenter == 0: res = np.dot( rodrigues(tiltz, [0, 0, 1]), np.dot(rodrigues(tilty, [0, 1, 0]), rodrigues(tiltx, [1, 0, 0]))) else: res = np.dot( rodrigues(tiltx, [1, 0, 0]), np.dot(rodrigues(tilty, [0, 1, 0]), rodrigues(tiltz, [0, 0, 1]))) return res
theta = np.arcsin(np.sqrt(direction_vec[1]**2 + direction_vec[0]**2)) alpha = np.linspace(-lim_angle, 0, num_pts_dir, endpoint=False) angle = np.linspace(0, 2. * np.pi, num_pts_dir, endpoint=False) (Alpha, Angle, X, Y) = np.meshgrid(alpha, angle, x, y) Xc = np.cos(Angle) * np.sin(Alpha) Yc = np.sin(Angle) * np.sin(Alpha) Zc = np.cos(Alpha) start_pts = np.vstack( (X.flatten(), Y.flatten(), np.zeros_like(X.flatten()))) cone = np.vstack((Xc.flatten(), Yc.flatten(), Zc.flatten())) rotz = rodrigues(-phi, [0, 0, 1]) rottheta = rodrigues(-theta, [1, 0, 0]) finalrot = np.dot(rottheta, rotz) final_cone = np.dot(finalrot, cone) return (start_pts, final_cone) lcobj = surfobj.rootcoordinatesystem if lck is None: lck = lcobj if kunitvector is None: # standard direction is in z in lck kunitvector = np.array([0, 0, 1])
#print("scalar product between S and local z direction: %f" % (scalar_product, )) kvec = kvectorsmat[sol_choice][0] kvectorsref = np.repeat(kvec, num_pilot_points, axis=1) kvecsol_final = np.zeros_like(kunitmat2, dtype=complex) kvecsol_final = choose_nearest(kvectorsref, kvectorsmat2) #print(kvec_turned_x) #print(kvec_turned_y) # 4x4 if use5point4x4: rotx = rodrigues(phix, [1, 0, 0]) roty = rodrigues(phiy, [0, 1, 0]) rnd_units_rx = np.einsum("ij...,j...", rotx, kunitmat).T rnd_units_ry = np.einsum("ij...,j...", roty, kunitmat).T kvec_turned_x = choose_nearest( kvec, mat.calcKNormfromUnitVector(np.zeros((3, 1)), rnd_units_rx)) kvec_turned_y = choose_nearest( kvec, mat.calcKNormfromUnitVector(np.zeros((3, 1)), rnd_units_ry)) #klock = np.array([ # [0, 0, 0, kwave*math.sin(phix), 0], # [0, 0, 0, 0, kwave*math.sin(phiy)], # [kwave, kwave, kwave, kwave*math.cos(phix), kwave*math.cos(phiy)]] #)