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, **kwargs)[source]¶
基础类:
Cylinder一个圆柱形线条,用于ThreeDScene。
- Parameters:
start (np.ndarray) – 线的起点。
end (np.ndarray) – 线的终点。
thickness (float) – 线条的厚度。
color (ParsableManimColor | None) – 线条的颜色。
示例
示例: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)方法
属性
animate用于动画化
self的任何方法的应用。animation_overridescolordepthmobject的深度。
fill_color如果有多种颜色(用于渐变),则返回第一个颜色
heightmobject的高度。
n_points_per_curvesheen_factorstroke_colorwidthmobject的宽度。
- _original__init__(start=array([-1., 0., 0.]), end=array([1., 0., 0.]), thickness=0.02, color=None, **kwargs)¶
初始化自身。有关准确的签名,请参阅 help(type(self))。
- Parameters:
开始 (np.ndarray)
end (np.ndarray)
厚度 (浮点数)
颜色 (ParsableManimColor | 无)
- classmethod parallel_to(line, point=array([0., 0., 0.]), length=5, **kwargs)[来源]¶
返回一条与另一条线平行并通过给定点的线。
- Parameters:
- Returns:
与
line平行的线。- Return type:
示例
示例: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)[source]¶
返回一条垂直于另一条线并通过给定点的线。
- Parameters:
- Returns:
垂直于
line的线。- Return type:
示例
示例: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)