def add_treds_to_tires(self): for tire in self.get_tires(): radius = tire.get_width() / 2 center = tire.get_center() tred = Line( 0.7 * radius * consts.RIGHT, 1.1 * radius * consts.RIGHT, stroke_width=2, color=Color('BLACK') ) tred.rotate(consts.PI / 5, about_point=tred.get_end()) for theta in np.arange(0, 2 * np.pi, np.pi / 4): new_tred = tred.copy() new_tred.rotate(theta, about_point=consts.ORIGIN) new_tred.shift(center) tire.add(new_tred) return self
def get_lines_parallel_to_axis(self, axis1, axis2, freq, ratio): line = Line(axis1.get_start(), axis1.get_end()) dense_freq = (1 + ratio) step = (1 / dense_freq) * freq lines1 = VGroup() lines2 = VGroup() ranges = ( np.arange(0, axis2.x_max, step), np.arange(0, axis2.x_min, -step), ) for inputs in ranges: for k, x in enumerate(inputs): new_line = line.copy() new_line.move_to(axis2.number_to_point(x)) if k % (1 + ratio) == 0: lines1.add(new_line) else: lines2.add(new_line) return lines1, lines2