def __init__(self, fig, slowness): super().__init__(fig) self.index = 0 self.slowness = slowness self.ring = cg_objects.circle(cg_objects.Vector.i_hat * 2.5) \ .rotate_y(math.pi / 2) self.base_frame = cg_objects.Frame.unit \ .translate(cg_objects.Vector(0, -6, 0)) self.lower = cg_objects.Frame.unit \ .translate(cg_objects.Vector(0, 3, -3)) self.upper = cg_objects.Frame.unit \ .translate(cg_objects.Vector(0, 3, 3))
def model(self): position = self.gravity.project_onto(self.incline_frame.x) * \ ((self.time_1 ** 2) / 4) angle = abs(position) / self.radius self.tangent_frame = self.incline_frame.translate(position) self.model_frame = self.tangent_frame \ .local.translate(cg_objects.Vector(0, 0, self.radius)) \ .local.rotate_y(angle) return self.model_frame @ self._model
def __init__(self, fig, slowness): super().__init__(fig) self.index = 0 self.slowness = slowness self.fig = fig self._model = cg_objects.cube() self.frame = cg_objects.Frame.unit \ .translate(cg_objects.Vector(-5, 2, -2)) \ .local.scale(3) \ .local.rotate_x(-math.pi / 8)
def __init__(self, fig): super().__init__(fig) self.time_0 = None self.time_1 = 0 self.gravity = cg_objects.Vector.k_hat * -9.80665 self.radius = 1 self._model = cg_objects.circle(cg_objects.Vector(self.radius, 0, 0)) \ .rotate_x(math.pi / 2) self.height = 2 self.run = 10 self.incline = cg_objects.Vector(self.run, 0, -self.height) self.angle = cg_objects.Vector.i_hat.angle(self.incline) self.incline_frame = cg_objects.Frame.unit \ .rotate_y(self.angle) \ .translate(cg_objects.Vector(0, 0, self.height)) self.tangent_frame = self.incline_frame self.model_frame = self.tangent_frame
def __init__(self, fig): super().__init__(fig) self.outer = cg_objects.Frame.unit.scale(3) # Each cube is a third smaller, in the middle of its parent cube, and # rotated 30 degrees from its parent about its own center self.inner = cg_objects.Frame.unit \ .translate(cg_objects.Vector(1, 1, 1)) \ .scale(1 / 3) \ .local.rotate_axis( math.pi / 6, through=cg_objects.Point(.5, .5, 0) ) self.cube = cg_objects.cube()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.model = cg_objects.t_pose() self.start = cg_objects.Frame.unit \ .translate(cg_objects.Vector(0, 0, 200)) self.frame = self.start self.time_0 = None self.time_1 = 0 acceleration = cg_objects.Vector.k_hat * -9.80665 velocity = cg_objects.Vector.zero position = self.start.origin - cg_objects.Point.origin self.position = functools.partial(self._physics_position, acceleration, velocity, position)
def plot_minimums(self, r): cube = cg_objects.Frame.unit \ .translate(cg_objects.Vector(-r, -r, -r)) \ @ cg_objects.cube(cg_objects.Vector(0, 0, 2 * r)) self.plot_vertices(cube, c='w', marker='.')
def plot_minimums(self, r): cube = cg_objects.cube(cg_objects.Vector(0, 0, r)) self.plot_vertices(cube, c='w', marker='.')
def model(self): return self.frame.local.rotate_axis( self.k * math.tau, cg_objects.Vector(1, 1, 0), cg_objects.Point(1, 1, 2)) \ @ self._model