예제 #1
0
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
예제 #2
0
 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
예제 #3
0
 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'))
예제 #4
0
 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]
예제 #5
0
 def out_coordinates(rho, phi, theta):
     return from_spherical(rho, phi, theta, mode='radians')
예제 #6
0
 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])
예제 #7
0
 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
예제 #8
0
 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])
예제 #9
0
 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])
예제 #10
0
 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
예제 #11
0
def spherical(rho, phi, theta, mode):
    return from_spherical(rho, phi, theta, mode)