def generate_points(self): self.cell_height = float(self.height) / self.nrows self.cell_width = float(self.width) / self.nrows self.bottom_left = (self.cell_width * self.nrows / 2.0)*LEFT + \ (self.cell_height * self.nrows / 2.0)*DOWN num_to_num_mob = {} self.coords_to_mobs = {} self.coords = [(n, k) for n in range(self.nrows) for k in range(n + 1)] for n, k in self.coords: num = choose(n, k) center = self.coords_to_center(n, k) num_mob = self.submob_class(n, k) #TexMobject(str(num)) scale_factor = min( 1, self.portion_to_fill * self.cell_height / num_mob.get_height(), self.portion_to_fill * self.cell_width / num_mob.get_width(), ) num_mob.center().scale(scale_factor).shift(center) if n not in self.coords_to_mobs: self.coords_to_mobs[n] = {} self.coords_to_mobs[n][k] = num_mob self.add(*[self.coords_to_mobs[n][k] for n, k in self.coords]) return self
def bezier(points): n = len(points) - 1 return lambda t: sum([((1 - t)**(n - k)) * (t**k) * choose(n, k) * point for k, point in enumerate(points)])
def combinationMobject(n, k): return Integer(choose(n, k))
def bezier(points): n = len(points) - 1 return lambda t: sum([ ((1 - t)**(n - k)) * (t**k) * choose(n, k) * point for k, point in enumerate(points) ])