def to_radius(r, v, c): x,y,z = v x0,y0,z0 = c v = x-x0, y-y0, z-z0 rho, phi, theta = to_spherical(v, "radians") x,y,z = from_spherical(r, phi, theta, "radians") return x+x0, y+y0, z+z0
def evaluate(self, u, v): rho = self.radius phi = u theta = v x, y, z = from_spherical(rho, phi, theta, mode="radians") point = np.array([x, y, z]) + self.center return point
def evaluate(self, x, y, z): v1 = self.sfield1.evaluate(x, y, z) v2 = self.sfield2.evaluate(x, y, z) v3 = self.sfield3.evaluate(x, y, z) if self.coords == 'XYZ': return np.array((v1, v2, v3)) elif self.coords == 'CYL': return np.array(from_cylindrical(v1, v2, v3, mode='radians')) else: # SPH: return np.array(from_spherical(v1, v2, v3, mode='radians'))
def evaluate_grid(self, xs, ys, zs): v1s = self.sfield1.evaluate_grid(xs, ys, zs) v2s = self.sfield2.evaluate_grid(xs, ys, zs) v3s = self.sfield3.evaluate_grid(xs, ys, zs) if self.coords == 'XYZ': return v1s, v2s, v3s elif self.coords == 'CYL': vectors = np.stack((v1s, v2s, v3s)).T vectors = np.apply_along_axis(lambda v: np.array(from_cylindrical(*tuple(v), mode='radians')), 1, vectors).T return vectors[0], vectors[1], vectors[2] else: # SPH: vectors = np.stack((v1s, v2s, v3s)).T vectors = np.apply_along_axis(lambda v: np.array(from_spherical(*tuple(v), mode='radians')), 1, vectors).T return vectors[0], vectors[1], vectors[2]
def out_coordinates(rho, phi, theta): return from_spherical(rho, phi, theta, mode='radians')
def normal(self, u, v): rho = self.radius phi = u / (rho * np.cos(self.theta1)) theta = v / rho + self.theta1 x, y, z = from_spherical(rho, phi, theta, mode="radians") return np.array([x, y, z])
def evaluate(self, u, v): rho = self.radius phi = u / (rho * cos(self.theta1)) theta = v / rho + self.theta1 x, y, z = from_spherical(rho, phi, theta, mode="radians") return np.array([x, y, z]) + self.center
def normal(self, u, v): rho = self.radius phi = u theta = v x, y, z = from_spherical(rho, phi, theta, mode="radians") return np.array([x, y, z])
def normal(self, u, v): rho = self.radius phi = u * sqrt(2) / rho theta = 2 * atan(v / (rho * (1 + sqrt(2) / 2))) + pi / 2 x, y, z = from_spherical(rho, phi, theta, mode="radians") return np.array([x, y, z])
def evaluate(self, u, v): rho = self.radius phi = u theta = np.arcsin(v) x, y, z = from_spherical(rho, phi, theta, mode="radians") return np.array([x, y, z]) + self.center
def spherical(rho, phi, theta, mode): return from_spherical(rho, phi, theta, mode)