Line3D¶
完全限定名: manim.mobject.three\_d.three\_dimensions.Line3D
- class Line3D(start=array([-1., 0., 0.]), end=array([1., 0., 0.]), thickness=0.02, color=None, resolution=24, **kwargs)[源码]¶
继承自:
Cylinder
用于ThreeDScene的圆柱形线。
- 参数:
**start** (*np.ndarray*) – 线的起点。
**end** (*np.ndarray*) – 线的终点。
**thickness** (*float*) – 线的厚度。
**color** (ParsableManimColor | None) – 线的颜色。
**resolution** (*int* | Sequence[int]) – 线的解析度。默认情况下,此值为线将采样的点数。如果你想让线也显示为棋盘格状,请使用元组。例如,对于由24个点组成的线,每个圆柱上有4个棋盘格点,则传入元组 (4, 24)。
示例
示例: ExampleLine3D ¶
from manim import * class ExampleLine3D(ThreeDScene): def construct(self): axes = ThreeDAxes() line = Line3D(start=np.array([0, 0, 0]), end=np.array([2, 2, 2])) self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, line)
class ExampleLine3D(ThreeDScene): def construct(self): axes = ThreeDAxes() line = Line3D(start=np.array([0, 0, 0]), end=np.array([2, 2, 2])) self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, line)
方法
返回
Line3D
的终点。返回
Line3D
的起点。返回一条平行于另一条线并穿过给定点的线。
返回一条垂直于另一条线并穿过给定点的线。
获取一个点,表示
Mobjects
的中心。设置线的起点和终点。
属性
animate (动画)
用于动画化
self
的任何方法的应用。animation_overrides (动画覆盖)
颜色
depth (深度)
mobject 的深度。
fill_color (填充颜色)
如果存在多种颜色(用于渐变),则返回第一种颜色
height (高度)
mobject 的高度。
n_points_per_curve (每条曲线的点数)
sheen_factor (光泽因子)
stroke_color (描边颜色)
width (宽度)
mobject 的宽度。
- _original__init__(start=array([-1., 0., 0.]), end=array([1., 0., 0.]), thickness=0.02, color=None, resolution=24, **kwargs)¶
初始化自身。有关准确签名,请参阅 help(type(self))。
- 参数:
**start** (*np.ndarray*)
**end** (*np.ndarray*)
**thickness** (*float*)
**color** (ParsableManimColor | None)
**resolution** (*int* | Sequence[int])
- classmethod parallel_to(line, point=array([0., 0., 0.]), length=5, **kwargs)[源码]¶
返回一条平行于另一条线并穿过给定点的线。
- 参数:
- 返回:
平行于
line
的线。- 返回类型:
示例
示例: ParallelLineExample ¶
from manim import * class ParallelLineExample(ThreeDScene): def construct(self): self.set_camera_orientation(PI / 3, -PI / 4) ax = ThreeDAxes((-5, 5), (-5, 5), (-5, 5), 10, 10, 10) line1 = Line3D(RIGHT * 2, UP + OUT, color=RED) line2 = Line3D.parallel_to(line1, color=YELLOW) self.add(ax, line1, line2)
class ParallelLineExample(ThreeDScene): def construct(self): self.set_camera_orientation(PI / 3, -PI / 4) ax = ThreeDAxes((-5, 5), (-5, 5), (-5, 5), 10, 10, 10) line1 = Line3D(RIGHT * 2, UP + OUT, color=RED) line2 = Line3D.parallel_to(line1, color=YELLOW) self.add(ax, line1, line2)
- classmethod perpendicular_to(line, point=array([0., 0., 0.]), length=5, **kwargs)[源码]¶
返回一条垂直于另一条线并穿过给定点的线。
- 参数:
- 返回:
垂直于
line
的线。- 返回类型:
示例
示例: PerpLineExample ¶
from manim import * class PerpLineExample(ThreeDScene): def construct(self): self.set_camera_orientation(PI / 3, -PI / 4) ax = ThreeDAxes((-5, 5), (-5, 5), (-5, 5), 10, 10, 10) line1 = Line3D(RIGHT * 2, UP + OUT, color=RED) line2 = Line3D.perpendicular_to(line1, color=BLUE) self.add(ax, line1, line2)
class PerpLineExample(ThreeDScene): def construct(self): self.set_camera_orientation(PI / 3, -PI / 4) ax = ThreeDAxes((-5, 5), (-5, 5), (-5, 5), 10, 10, 10) line1 = Line3D(RIGHT * 2, UP + OUT, color=RED) line2 = Line3D.perpendicular_to(line1, color=BLUE) self.add(ax, line1, line2)