def __init__(self, **kwargs): digest_config(self, kwargs) if self.leftmost_tick is None: self.leftmost_tick = -int(self.numerical_radius - self.number_at_center) self.left_num = self.number_at_center - self.numerical_radius self.right_num = self.number_at_center + self.numerical_radius Mobject1D.__init__(self, **kwargs)
def __init__(self, radius = SPACE_WIDTH+1, interval_size = 0.5, tick_size = 0.1, *args, **kwargs): self.radius = int(radius) self.interval_size = interval_size self.tick_size = tick_size Mobject1D.__init__(self, *args, **kwargs)
def __init__(self, radius = max(SPACE_HEIGHT, SPACE_WIDTH), interval_size = 1.0, subinterval_size = 0.5, *args, **kwargs): self.radius = radius self.interval_size = interval_size self.subinterval_size = subinterval_size Mobject1D.__init__(self, *args, **kwargs)
def __init__(self, center = (0, 0, 0), radius = DEFAULT_RADIUS, *args, **kwargs): center = np.array(center) if center.size == 1: raise Exception("Center must have 2 or 3 coordinates!") elif center.size == 2: center = np.append(center, [0]) self.center_point = center self.radius = radius Mobject1D.__init__(self, *args, **kwargs)
def __init__(self, start, end, density=DEFAULT_POINT_DENSITY_1D, *args, **kwargs): self.start = np.array(start) self.end = np.array(end) density *= max(self.get_length(), 0.1) Mobject1D.__init__(self, density=density, *args, **kwargs)
def __init__(self, center=(0, 0, 0), radius=DEFAULT_RADIUS, *args, **kwargs): center = np.array(center) if center.size == 1: raise Exception("Center must have 2 or 3 coordinates!") elif center.size == 2: center = np.append(center, [0]) self.center_point = center self.radius = radius Mobject1D.__init__(self, *args, **kwargs)
def construct(self): curve = HilbertCurve(order=1) grid = Grid(2, 2, stroke_width=1) self.add(grid, curve) for order in range(2, 6): self.dither() new_grid = Grid(2**order, 2**order, stroke_width=1) self.play(ShowCreation(new_grid), Animation(curve)) self.remove(grid) grid = new_grid self.play(Transform(curve, HilbertCurve(order=order))) square = Square(side_length=6, color=WHITE) square.corner = Mobject1D() square.corner.add_line(3 * DOWN, ORIGIN) square.corner.add_line(ORIGIN, 3 * RIGHT) square.digest_mobject_attrs() square.scale(2**(-5)) square.corner.highlight( Color(rgb=curve.rgbs[curve.get_num_points() / 3])) square.shift( grid.get_corner(UP+LEFT)-\ square.get_corner(UP+LEFT) ) self.dither() self.play(FadeOut(grid), FadeOut(curve), FadeIn(square)) self.play(ApplyMethod(square.replace, grid)) self.dither()
def generate_discrete_path(self): points = self.cycloid.points tops = list(self.layer_tops) tops.append(tops[-1]-self.layer_thickness) indices = [ np.argmin(np.abs(points[:, 1]-top)) for top in tops ] self.bend_points = points[indices[1:-1]] self.path_angles = [] self.discrete_path = Mobject1D( color = YELLOW, density = 3*DEFAULT_POINT_DENSITY_1D ) for start, end in zip(indices, indices[1:]): start_point, end_point = points[start], points[end] self.discrete_path.add_line( start_point, end_point ) self.path_angles.append( angle_of_vector(start_point-end_point)-np.pi/2 ) self.discrete_path.add_line( points[end], SPACE_WIDTH*RIGHT+(self.layer_tops[-1]-1)*UP )
def __init__(self, point = (0, 0, 0), direction = (-1, 1, 0), tail = None, length = 1, tip_length = 0.25, normal = (0, 0, 1), density = DEFAULT_POINT_DENSITY_1D, *args, **kwargs): self.point = np.array(point) if tail is not None: direction = self.point - tail length = np.linalg.norm(direction) self.direction = np.array(direction) / np.linalg.norm(direction) density *= max(length, 0.1) self.length = length self.normal = np.array(normal) self.tip_length = tip_length Mobject1D.__init__(self, density = density, **kwargs)
def __init__(self, point=(0, 0, 0), direction=(-1, 1, 0), tail=None, length=1, tip_length=0.25, normal=(0, 0, 1), density=DEFAULT_POINT_DENSITY_1D, *args, **kwargs): self.point = np.array(point) if tail is not None: direction = self.point - tail length = np.linalg.norm(direction) self.direction = np.array(direction) / np.linalg.norm(direction) density *= max(length, 0.1) self.length = length self.normal = np.array(normal) self.tip_length = tip_length Mobject1D.__init__(self, density=density, **kwargs)
def generate_discrete_path(self): points = self.cycloid.points tops = [mob.get_top()[1] for mob in self.layers] tops.append(tops[-1] - self.layers[0].get_height()) indices = [np.argmin(np.abs(points[:, 1] - top)) for top in tops] self.bend_points = points[indices[1:-1]] self.path_angles = [] self.discrete_path = Mobject1D(color=WHITE, density=3 * DEFAULT_POINT_DENSITY_1D) for start, end in zip(indices, indices[1:]): start_point, end_point = points[start], points[end] self.discrete_path.add_line(start_point, end_point) self.path_angles.append( angle_of_vector(start_point - end_point) - np.pi / 2) self.discrete_path.add_line( points[end], SPACE_WIDTH * RIGHT + (tops[-1] - 0.5) * UP)
def __init__(self, radius = 1.0, **kwargs): self.radius = radius Mobject1D.__init__(self, **kwargs)
def __init__(self, start, end, **kwargs): self.set_start_and_end(start, end) Mobject1D.__init__(self, **kwargs)
def __init__(self, function, **kwargs): self.function = function Mobject1D.__init__(self, **kwargs)
def __init__(self, center_point = ORIGIN, **kwargs): digest_locals(self) Mobject1D.__init__(self, **kwargs)
def __init__(self, radius=1.0, **kwargs): self.radius = radius Mobject1D.__init__(self, **kwargs)
def __init__(self, rows, columns, **kwargs): digest_config(self, kwargs, locals()) Mobject1D.__init__(self, **kwargs)
def __init__(self, *vertices, **kwargs): assert len(vertices) > 1 digest_locals(self) Mobject1D.__init__(self, **kwargs)
def __init__(self, *points, **kwargs): assert len(points) > 1 digest_locals(self) Mobject1D.__init__(self, **kwargs)
def __init__(self, function, x_range = [-10, 10], *args, **kwargs): self.function = function self.x_min = x_range[0] / SPACE_WIDTH self.x_max = x_range[1] / SPACE_WIDTH Mobject1D.__init__(self, *args, **kwargs)
def __init__(self, height=2.0, width=2.0, **kwargs): self.height, self.width = height, width Mobject1D.__init__(self, **kwargs)
def __init__(self, height = 2.0, width = 2.0, **kwargs): self.height, self.width = height, width Mobject1D.__init__(self, **kwargs)
def __init__(self, start, end, **kwargs): digest_config(self, kwargs) self.set_start_and_end(start, end) Mobject1D.__init__(self, **kwargs)
def __init__(self, start, end, density = DEFAULT_POINT_DENSITY_1D, *args, **kwargs): self.start = np.array(start) self.end = np.array(end) density *= max(self.get_length(), 0.1) Mobject1D.__init__(self, density = density, *args, **kwargs)
def __init__(self, angle, **kwargs): digest_locals(self) Mobject1D.__init__(self, **kwargs)