def tras_rot2(beam, p, theta): theta_grazing = np.pi / 2 - theta y = Vector(0., 1., 0.) y.rotation(-theta_grazing, 'x') x = Vector(1., 0., 0.) xp = x.vector_product(y) vrot = y.rodrigues_formula(xp, -theta_grazing) vrot.normalization() position = Vector(beam.x, beam.y, beam.z) velocity = Vector(beam.vx, beam.vy, beam.vz) position.rotation(-theta_grazing, 'x') velocity.rotation(-theta_grazing, 'x') #position = position.rodrigues_formula(xp, -theta_grazing) #velocity = velocity.rodrigues_formula(xp, -theta_grazing) velocity.normalization() beam.vx = velocity.x beam.vy = velocity.y beam.vz = velocity.z vector_point = Vector(0, p, 0) vector_point.rotation(-theta_grazing, "x") print(vector_point.info()) #vector_point = vector_point.rodrigues_formula(xp, -theta_grazing) vector_point.normalization() beam.x = position.x - vector_point.x * p beam.y = position.y - vector_point.y * p beam.z = position.z - vector_point.z * p
def test_normalization_list_vector(self): print(">> test_normalization_list_vector") x = np.ones(10) y = np.ones(10) z = np.ones(10) v = Vector(x, y, z) v.normalization() assert_almost_equal(v.x, 1 / np.sqrt(3) * np.ones(10), 15) assert_almost_equal(v.y, 1 / np.sqrt(3) * np.ones(10), 15) assert_almost_equal(v.z, 1 / np.sqrt(3) * np.ones(10), 15)
def test_normalizationvector(self): print(">> test_normalizationvector") x=1 y=1 z=1 v=Vector(x,y,z) v.normalization() print(v.info()) assert_almost_equal(v.x, 1/np.sqrt(3), 15) assert_almost_equal(v.y, 1/np.sqrt(3), 15) assert_almost_equal(v.z, 1/np.sqrt(3), 15)
def theta(): p = 0.23e-3 f = 0.23e-3 / 2 xp = 0.0127046 yp = 0.350885 m = xp / p v = Vector(xp, yp - f, 0.) v.normalization() t = Vector(xp / p, -1, 0.) t.normalization() print((np.arccos(v.dot(t))) * 180. / np.pi) return np.arccos(v.dot(t))
def set_flat_divergence_with_different_optical_axis(self, dx, dz): N = self.N x = self.vx z = self.vz y = self.vy self.vx = dx * (np.random.random(N) - 0.5) * 2 self.vz = dz * (np.random.random(N) - 0.5) * 2 self.vx = self.vx + x self.vz = self.vz + z velocity = Vector(self.vx, self.vy, self.vz) velocity.normalization() self.vx = velocity.x self.vy = velocity.y self.vz = velocity.z
def tras_rot(beam, p): velocity = Vector(beam.vx, beam.vy, beam.vz) velocity.rotation(-gamma, 'z') velocity.rotation(-alpha, 'x') velocity.normalization() beam.vx = velocity.x beam.vy = velocity.y beam.vz = velocity.z position = Vector(beam.x, beam.y, beam.z) position.rotation(-gamma, 'z') position.rotation(-alpha, 'x') beam.x = position.x beam.y = position.y beam.z = position.z beam.x -= beam.vx[0] * p beam.y -= beam.vy[0] * p beam.z -= beam.vz[0] * p
def __init__(self, N=25000): N = round(N) self.x = np.zeros(N) self.y = np.zeros(N) self.z = np.zeros(N) velocity = Vector(0.0000001, 1., 0.01) velocity.normalization() self.vx = np.ones(N) * velocity.x self.vy = np.ones(N) * velocity.y self.vz = np.ones(N) * velocity.z self.flag = np.zeros(N) self.N = N self.indices = np.arange(self.N) self.aux = np.zeros(N)
b2 = beam.y b3 = beam.z beam.y = b3 beam.z = b2 beam.z = -beam.z + f p = wolter_japanese.oe[0].p q = wolter_japanese.oe[0].q beta = np.arccos((p**2 + 4 * f**2 - q**2) / (4 * p * f)) y = -p * np.sin(beta) z = f - p * np.cos(beta) v = Vector(0., y, z - f) v.normalization() v0 = Vector(0., 0., -1.) v0.normalization() alpha = np.arccos(v.dot(v0)) t = (-v.x * beam.x - v.y * beam.y - v.z * beam.z) / (v.x * beam.vx + v.y * beam.vy + v.z * beam.vz) beam.x += beam.vx * t beam.y += beam.vy * t beam.z += beam.vz * t velocity = Vector(beam.vx, beam.vz, -beam.vy) velocity.rotation(-alpha, 'x') beam.vx = velocity.x beam.vy = velocity.y