3b1b / 3b1b/manim

Triangles don't fit exactly inside square after rotation

オープン
#683 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
93.9k
フォーク
7.7k
平均マージ
2日 13時間
マージ済み PR(30日)
4

説明

Steps to reproduce
1) Copy source code:
```
class Pythagoras(Scene):
def construct(self):
title = TextMobject("Pythagorean Theorem")
title.to_edge(UL)

pre_square = Polygon(
[-2, 2, 0],
[2, 2, 0],
[2, -2, 0],
[-2, -2, 0],
color=WHITE
)

self.wait()

square2 = Polygon(
[-1.41, 1.41, 0],
[1.41, 1.41, 0],
[1.41, -1.41, 0],
[-1.41, -1.41, 0]

)
square2.rotate(PI/6)

triangle1 = Polygon(
[-2, 2, 0],
[-2 + math.sqrt(6), 2, 0],
[-2, 2 - math.sqrt(2), 0],
color=YELLOW
)

triangle2 = Polygon(
[2, 2, 0],
[-2 + math.sqrt(6), 2, 0],
[2, 2 - math.sqrt(6), 0],
color=YELLOW
)

triangle3 = Polygon(
[2, 2 - math.sqrt(6), 0],
[2, -2, 0],
[2 - math.sqrt(6), -2, 0],
color=YELLOW
)

triangle4 = Polygon(
[-2, 2 - math.sqrt(2), 0],
[-2, -2, 0],
[2 - math.sqrt(6), -2, 0],
color=YELLOW
)

triangles = [triangle1, triangle2, triangle3, triangle4]
for triangle in triangles:
triangle.set_fill(YELLOW, 0.6)

self.play(Write(title), ShowCreation(pre_square), ShowCreation(triangle1), ShowCreation(triangle2), ShowCreation(triangle3), ShowCreation(triangle4))

self.wait()

group = VGroup(pre_square, triangle1, triangle2, triangle3, triangle4)

self.play(ApplyMethod(group.to_edge, LEFT, {"buff": 1.6}))
self.wait()

square3 = pre_square.copy()

self.play(ApplyMethod(square3.shift, RIGHT * 7))

triangle2.generate_target()
triangle2.target.shift(RIGHT * (7- math.sqrt(6)))

triangle1.generate_target()
triangle1.target = triangle2.target.copy().rotate(PI)

triangle3.generate_target()
triangle3.target.shift(RIGHT * 7)

triangle4.generate_target()
triangle4.target = triangle3.target.copy().rotate(PI)

self.play(MoveToTarget(triangle1.copy()), MoveToTarget(triangle2.copy()), MoveToTarget(triangle3.copy()), MoveToTarget(triangle4.copy()))

self.wait()
```
2) run manim on this scene with -ps.

Unexpected behaviour
See https://stackoverflow.com/questions/57467134/when-rotating-shapes-vertices-are-just-slightly-off

Environment
OS: Windows 10
Python: 3.7.3
manim: 9 August 2019

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。