def draw_visual(self,c): '''Draws an ellipse in VPython. Ideally would only draw the top half of the ellipse, but draws the entire ellipse. This disadvantage makes it seem as if the head is more "round" than it actually is. ''' ax = self.RotMat * np.array([[0],[0],[1]]) vis.ellipsoid(pos = (self.pos[0,0],self.pos[1,0],self.pos[2,0]), axis = (ax[0,0],ax[1,0],ax[2,0]), length=self.height, height=self.radius*2, width=self.radius*2, color=c)
def main(): if len(argv) < 3: raise Exception('>>> ERROR! Please supply values for black hole mass [>= 1.0] and spin [0.0 - 1.0] <<<') m = float(argv[1]) a = float(argv[2]) horizon = m * (1.0 + sqrt(1.0 - a * a)) cauchy = m * (1.0 - sqrt(1.0 - a * a)) # set up the scene scene.center = (0.0, 0.0, 0.0) scene.width = scene.height = 1024 scene.range = (20.0, 20.0, 20.0) inner = 2.0 * sqrt(cauchy**2 + a**2) ellipsoid(pos = scene.center, length = inner, height = inner, width = 2.0 * cauchy, color = color.blue, opacity = 0.4) # Inner Horizon outer = 2.0 * sqrt(horizon**2 + a**2) ellipsoid(pos = scene.center, length = outer, height = outer, width = 2.0 * horizon, color = color.blue, opacity = 0.3) # Outer Horizon ergo = 2.0 * sqrt(4.0 + a**2) ellipsoid(pos = scene.center, length = ergo, height = ergo, width = 2.0 * horizon, color = color.gray(0.7), opacity = 0.2) # Ergosphere if fabs(a) > 0.0: ring(pos=scene.center, axis=(0, 0, 1), radius = a, color = color.white, thickness=0.01) # Singularity else: sphere(pos=scene.center, radius = 0.05, color = color.white) # Singularity ring(pos=scene.center, axis=(0, 0, 1), radius = sqrt(isco(a)**2 + a**2), color = color.magenta, thickness=0.01) # ISCO curve(pos=[(0.0, 0.0, -15.0), (0.0, 0.0, 15.0)], color = color.gray(0.7)) #cone(pos=(0,0,12), axis=(0,0,-12), radius=12.0 * tan(0.15 * pi), opacity=0.2) #cone(pos=(0,0,-12), axis=(0,0,12), radius=12.0 * tan(0.15 * pi), opacity=0.2) #sphere(pos=(0,0,0), radius=3.0, opacity=0.2) #sphere(pos=(0,0,0), radius=12.0, opacity=0.1) # animate! ball = sphere() # Particle counter = 0 dataLine = stdin.readline() while dataLine: # build raw data arrays rate(60) if counter % 1000 == 0: ball.visible = False ball = sphere(radius = 0.2) # Particle ball.trail = curve(size = 1) # trail data = loads(dataLine) e = float(data['v4e']) if e < -120.0: ball.color = color.green elif e < -90.0: ball.color = color.cyan elif e < -60.0: ball.color = color.yellow elif e < -30.0: ball.color = color.orange else: ball.color = color.red r = float(data['r']) th = float(data['th']) ph = float(data['ph']) ra = sqrt(r**2 + a**2) sth = sin(th) ball.pos = (ra * sth * cos(ph), ra * sth * sin(ph), r * cos(th)) ball.trail.append(pos = ball.pos, color = ball.color) counter += 1 dataLine = stdin.readline()
def __init__(self, body, pos, radius, color, material, texture, showTrail, rings): Particle.__init__(self, body, pos, radius, color, material, texture, showTrail) self.rings = rings if rings: self.rings = vs.ellipsoid(pos=self.pos, size=(self.radius * 4, 0.01, self.radius * 4), opacity=0.95) width = 512 # must be power of 2 height = 512 # must be power of 2 image = Image.open(rings) image = image.resize((width, height), Image.ANTIALIAS) material = vs.materials.texture(data=image, mapping="cubic") self.rings.material = material
def build_LH(self, hand): print 'Building Left Hand..' self.leftHand = hand sz = (0.8, 1, 5) f1 = vp.ellipsoid(pos=(-2., 1.5, 6.2), size=sz, opacity=0.9, color=(.7, 0.3, 0.3)) f2 = vp.ellipsoid(pos=(-1., 1.5, 4.2), size=sz, opacity=0.9, color=(.7, 0.3, 0.3)) f3 = vp.ellipsoid(pos=(0., 1.5, 4), size=sz, opacity=0.9, color=(.7, 0.3, 0.3)) f4 = vp.ellipsoid(pos=(1., 1.5, 4.1), size=sz, opacity=0.9, color=(.7, 0.3, 0.3)) f5 = vp.ellipsoid(pos=(2., 1.5, 4.5), size=sz, opacity=0.9, color=(.7, 0.3, 0.3)) palm = vp.ellipsoid(pos=(0, 1.6, 10), size=(9.6, 2., 6), opacity=0.3, color=(.5, 0, 0)) palm.rotate(angle=-0.1) palm.rotate(angle=-0.1, axis=(0, 1, 0)) self.vpLH = [palm, f1, f2, f3, f4, f5] for limb in self.vpLH: limb.x *= -2.5 limb.pos += (16.5 * 3. + 1, 0, 0)
q_dot = Q.dot(w).tolist() return q_dot q0 = [0.0, 0.0, 0.0, 1.0] t = linspace(0.0, total_time, num_samples) quaternions = odeint(d_dt_q, q0, t) rotation_matrices = [array([[q[3] ** 2 + q[0] ** 2 - q[1] ** 2 - q[2] ** 2, 2.0 * (q[0] * q[1] - q[3] * q[2]), 2.0 * (q[0] * q[2] + q[3] * q[1])], [2.0 * (q[0] * q[1] + q[3] * q[2]), q[3] ** 2 - q[0] ** 2 + q[1] ** 2 - q[2] ** 2, 2.0 * (q[1] * q[2] - q[3] * q[0])], [2.0 * (q[0] * q[2] - q[3] * q[1]), 2.0 * (q[1] * q[2] + q[3] * q[0]), q[3] ** 2 - q[0] ** 2 - q[1] ** 2 + q[2] ** 2]]) for q in quaternions] scene.background=(1,1,1) scene.up = vector(0, 0, 1) asteroid_3d = ellipsoid(pos=(0.0, 0.0, 0.0), up=(0.0, 0.0, 1.0), length=2.0 * sim_params[0], width=2.0 * sim_params[1], height=2.0 * sim_params[2], color=(153.0 / 255.0, 76.0 / 255.0, 0.0)) spacecraft = box(pos=tuple(states[0][0:3]), size=(100, 100, 100), make_trail=True, color=(0.0, 128.0 / 255.0, 1.0), up=(0.0, 0.0, 1.0)) spacecraft.trail_object.color = color.gray(0.0) height = arrow(pos=spacecraft.pos-states[0][3:7], axis=tuple(states[0][3:7]), shaftwidth=20.0, color=color.orange, up=(0.0, 0.0, 1.0)) if reference_frame == "body": ground_position = sphere(pos=height.pos, radius=5.0, make_trail=True, color=(0.0, 0.0, 204.0 / 255.0)) ground_position.trail_object.color = (255.0 / 255.0, 255.0 / 255.0, 255.0 / 255.0) else: