本文整理汇总了Python中mobject.Mobject.rotate方法的典型用法代码示例。如果您正苦于以下问题:Python Mobject.rotate方法的具体用法?Python Mobject.rotate怎么用?Python Mobject.rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.Mobject
的用法示例。
在下文中一共展示了Mobject.rotate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_pendulum
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import rotate [as 别名]
def show_pendulum(self, arc_angle = np.pi, arc_color = GREEN):
words = TextMobject(": Instantaneous center of rotation")
words.next_to(self.c_label)
line = Line(self.p_point, self.c_point)
line_angle = line.get_angle()+np.pi
line_length = line.get_length()
line.add(self.p_dot.copy())
line.get_center = lambda : self.c_point
tangent_line = Line(3*LEFT, 3*RIGHT)
tangent_line.rotate(line_angle-np.pi/2)
tangent_line.shift(self.p_point)
tangent_line.highlight(arc_color)
right_angle_symbol = Mobject(
Line(UP, UP+RIGHT),
Line(UP+RIGHT, RIGHT)
)
right_angle_symbol.scale(0.3)
right_angle_symbol.rotate(tangent_line.get_angle()+np.pi)
right_angle_symbol.shift(self.p_point)
self.play(ShowCreation(line))
self.play(ShimmerIn(words))
self.dither()
pairs = [
(line_angle, arc_angle/2),
(line_angle+arc_angle/2, -arc_angle),
(line_angle-arc_angle/2, arc_angle/2),
]
arcs = []
for start, angle in pairs:
arc = Arc(
angle = angle,
radius = line_length,
start_angle = start,
color = GREEN
)
arc.shift(self.c_point)
self.play(
ShowCreation(arc),
ApplyMethod(
line.rotate_in_place,
angle,
path_func = path_along_arc(angle)
),
run_time = 2
)
arcs.append(arc)
self.dither()
self.play(Transform(arcs[1], tangent_line))
self.add(tangent_line)
self.play(ShowCreation(right_angle_symbol))
self.dither()
self.tangent_line = tangent_line
self.right_angle_symbol = right_angle_symbol
self.pc_line = line
self.remove(words, *arcs)
示例2: BalanceCompetingFactors
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import rotate [as 别名]
class BalanceCompetingFactors(Scene):
args_list = [
("Short", "Steep"),
("Minimal time \\\\ in water", "Short path")
]
@staticmethod
def args_to_string(*words):
return "".join([word.split(" ")[0] for word in words])
def construct(self, *words):
factor1, factor2 = [
TextMobject("Factor %d"%x).highlight(c)
for x, c in [
(1, RED_D),
(2, BLUE_D)
]
]
real_factor1, real_factor2 = map(TextMobject, words)
for word in factor1, factor2, real_factor1, real_factor2:
word.shift(0.2*UP-word.get_bottom())
for f1 in factor1, real_factor1:
f1.highlight(RED_D)
f1.shift(2*LEFT)
for f2 in factor2, real_factor2:
f2.highlight(BLUE_D)
f2.shift(2*RIGHT)
line = Line(
factor1.get_left(),
factor2.get_right()
)
line.center()
self.balancers = Mobject(factor1, factor2, line)
self.hidden_balancers = Mobject(real_factor1, real_factor2)
triangle = Polygon(RIGHT, np.sqrt(3)*UP, LEFT)
triangle.next_to(line, DOWN, buff = 0)
self.add(triangle, self.balancers)
self.rotate(1)
self.rotate(-2)
self.dither()
self.play(Transform(
factor1, real_factor1,
path_func = path_along_arc(np.pi/4)
))
self.rotate(2)
self.dither()
self.play(Transform(
factor2, real_factor2,
path_func = path_along_arc(np.pi/4)
))
self.rotate(-2)
self.dither()
self.rotate(1)
def rotate(self, factor):
angle = np.pi/11
self.play(Rotate(
self.balancers,
factor*angle,
run_time = abs(factor)
))
self.hidden_balancers.rotate(factor*angle)