-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_scene.py
More file actions
65 lines (50 loc) · 1.57 KB
/
test_scene.py
File metadata and controls
65 lines (50 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""
Simple test scene to verify Manim code generation
"""
from manim import *
class SimpleTestScene(ThreeDScene):
"""Simple 3D scene with data points and arrows"""
def construct(self):
# Set up 3D scene
self.set_camera_orientation(phi=60 * DEGREES, theta=45 * DEGREES)
# Create some simple data points
points = VGroup()
for i in range(10):
x = (i % 3 - 1) * 2
y = (i % 4 - 1.5) * 1.5
z = (i % 2 - 0.5) * 1
point = Sphere(radius=0.1).move_to([x, y, z])
point.set_color(BLUE)
points.add(point)
# Create principal component arrows
pc1 = Arrow3D(
start=ORIGIN,
end=[2, 1.5, 0.5],
color=RED,
thickness=0.05
)
pc2 = Arrow3D(
start=ORIGIN,
end=[-1, 1, 0.2],
color=GREEN,
thickness=0.04
)
# Add title
title = Text("PCA Visualization Demo", font_size=36)
title.to_edge(UP)
# Animate
self.play(FadeIn(title))
self.wait(0.5)
self.play(*[FadeIn(point) for point in points], run_time=2)
self.wait(0.5)
self.play(GrowArrow(pc1))
self.wait(0.5)
self.play(GrowArrow(pc2))
self.wait(1)
# Rotate camera
self.move_camera(phi=70 * DEGREES, theta=60 * DEGREES, run_time=2)
self.wait(1)
if __name__ == "__main__":
# Render with: manim -pql test_scene.py SimpleTestScene
pass