目录
一、画点和线
下边代码为实验的框架
如果self.add(),是不带动画效果的;如果要想带上动画效果可以使用self.play()
比如使用:
self.play(Create(p), run_time=0.5)
二、画箭头与虚线
三、画圆与椭圆
- 画圆只要提供半径即可,圆心默认在屏幕的中心(0,0,0)。
- 画椭圆的两个参数 width和 height分别控制椭圆最大宽度和最大高度。
四、画圆弧
画圆弧主要有三个参数:
- angle:圆弧的弧度
- start_angle: 开始的角度,默认 0
- radius:圆弧的半径
五、画多边形
六、坐标系
1. 数轴:NumberLine
数轴(NumberLine)是最基本的一维坐标系,它的关键参数是:
- x_range:设置数轴的范围和间隔
- length:设置数轴显示的长度
2. 实数平面:NumberPlane
实数平面(NumberPlane)的关键参数有4个:
- x_range:设置X轴的范围和间隔
- y_range:设置Y轴的范围和间隔
- x_length:设置X轴显示的长度
- y_length:设置Y轴显示的长度
3. 复数平面:ComplexPlane
复数平面(ComplexPlane)是基于实数平面(NumberPlane)的,参数类似,只是多了一些标记复数的信息。
4. 极坐标系:PolarPlane
极坐标系(PolarPlane)通过角度和与原点的距离来定位位置,经常被用于导航类的系统中,与直角坐标相比,在这类系统中能极大的简化计算。
它的关键参数有:
- azimuth_step:分割的角度个数
- size:极坐标在屏幕中显示的大小
- radius_step:极坐标半径的间隔
- radius_max:极坐标最大半径
5. 二维笛卡尔坐标系:Axes
二维的笛卡尔坐标系(Axes)使用的比较多,它在平面坐标系之上,又提供了更多的配置,可以更加灵活的配置数轴,除了上面平面坐标系提到的那4个关键参数之外,还有2个配置坐标轴的参数也很重要:
- x_axis_config:配置X轴如何显示的参数
- y_axis_config:配置Y轴如何显示的参数
比如下面的示例中, 配置了与X轴不一样刻度的Y轴。
6. 三维笛卡尔坐标系:ThreeDAxes
三维的笛卡尔坐标系(ThreeDAxes)与二维坐标系的参数类似,只是多了一个维度(Z轴)的配置,其配置参数与X轴和Y轴类似。
显示三维图形时,有2点需要额外注意:
- 一是场景要继承 ThreeDScene。
- 二是要调整下默认的相机位置,也就是视角的位置,默认视角是从Z轴顶部向下看的。