给我用manim写几段几个超立方题的代码
时间: 2023-05-27 15:02:09 浏览: 158
C 代码 计算点网格 在 M 维超立方体的内部.rar
以下是使用Manim编写的几个超立方体题目的代码示例:
1. 输出一个超立方体的三维展示
```python
from manim import *
class HyperCube(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
hcube=Cube(fill_opacity=1, stroke_width=2).set_color(GREEN_SCREEN)
hcube.scale(2)
hcube.starting_scale = 1/hcube.scale_factor
def update_hcube(hcube,alpha):
er = interpolate(hcube.starting_scale, 1.0, alpha)
hcube.scale(er/hcube.scale_factor)
self.set_camera_orientation(phi=75*DEGREES,theta=-45*DEGREES,distance=50)
self.play(Create(axes),Create(hcube),UpdateFromAlphaFunc(hcube,update_hcube),run_time=3)
```
2. 输出超立方体的四维展示
```python
from manim import *
class HyperCube(ThreeDScene):
def construct(self):
axes = FourDAxes()
hcube = Hypercube(fill_opacity=1, stroke_width=2).set_color(BLUE)
hcube.scale(2)
hcube.starting_scale = 1 / hcube.scale_factor
def update_hcube(hcube,alpha):
er = interpolate(hcube.starting_scale, 1.0, alpha)
hcube.scale(er/hcube.scale_factor)
self.play(Create(axes))
self.set_camera_orientation(phi=70*DEGREES,theta=-30*DEGREES)
self.begin_ambient_camera_rotation(rate=0.1)
self.play(Create(hcube),UpdateFromAlphaFunc(hcube, update_hcube),run_time=3)
```
3. 输出一个超立方体的五维展示
```python
from manim import *
class HyperCube(ThreeDScene):
def construct(self):
axes = FiveDAxes()
hcube = Hypercube(fill_opacity=1, stroke_width=2).set_color(YELLOW)
hcube.scale(2)
hcube.starting_scale = 1 / hcube.scale_factor
def update_hcube(hcube,alpha):
er = interpolate(hcube.starting_scale, 1.0, alpha)
hcube.scale(er/hcube.scale_factor)
self.play(Create(axes))
self.set_camera_orientation(phi=70*DEGREES,theta=-30*DEGREES)
self.begin_ambient_camera_rotation(rate=0.1)
self.play(Create(hcube),UpdateFromAlphaFunc(hcube, update_hcube),run_time=3)
```
4. 输出一个超立方体的六维展示
```python
from manim import *
class HyperCube(ThreeDScene):
def construct(self):
axes = SixDAxes()
hcube = Hypercube(fill_opacity=1, stroke_width=2).set_color(RED)
hcube.scale(2)
hcube.starting_scale = 1 / hcube.scale_factor
def update_hcube(hcube,alpha):
er = interpolate(hcube.starting_scale, 1.0, alpha)
hcube.scale(er/hcube.scale_factor)
self.play(Create(axes))
self.set_camera_orientation(phi=70*DEGREES, theta=-30*DEGREES)
self.begin_ambient_camera_rotation(rate=0.1)
self.play(Create(hcube),UpdateFromAlphaFunc(hcube, update_hcube),run_time=3)
```
阅读全文