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

../_images/ExampleLine3D-1.png
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)

方法

get_end

返回Line3D的终点。

get_start

返回Line3D的起点。

parallel_to

返回一条与另一条线平行并通过给定点的线。

perpendicular_to

返回一条通过给定点且垂直于另一条线的线。

pointify

获取表示Mobjects中心的点。

set_start_and_end_attrs

设置线条的起点和终点。

属性

animate

用于动画化self的任何方法的应用。

animation_overrides

color

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, **kwargs)

初始化自身。有关准确的签名,请参阅 help(type(self))。

Parameters:
  • 开始 (np.ndarray)

  • end (np.ndarray)

  • 厚度 (浮点数)

  • 颜色 (ParsableManimColor | )

get_end()[source]

返回Line3D的终点。

Returns:

endLine3D的结束点。

Return type:

numpy.array

get_start()[来源]

返回Line3D的起点。

Returns:

startLine3D的起点。

Return type:

numpy.array

classmethod parallel_to(line, point=array([0., 0., 0.]), length=5, **kwargs)[来源]

返回一条与另一条线平行并通过给定点的线。

Parameters:
  • line (Line3D) – 要与之平行的线。

  • (Vector3D) – 要通过的点。

  • length (float) – 平行线的长度。

  • kwargs – 传递给类的额外参数。

Returns:

line平行的线。

Return type:

Line3D

示例

示例:ParallelLineExample

../_images/ParallelLineExample-1.png
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:
  • line (Line3D) – 需要与之垂直的线。

  • (Vector3D) – 要通过的点。

  • length (float) – 垂直线的长度。

  • kwargs – 传递给类的额外参数。

Returns:

垂直于line的线。

Return type:

Line3D

示例

示例:PerpLineExample

../_images/PerpLineExample-1.png
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)

pointify(mob_or_point, direction=None)[来源]

获取表示Mobjects中心的点。

Parameters:
Returns:

Mobjects 的中心或点,如果给定了方向,则为边缘。

Return type:

numpy.array

set_start_and_end_attrs(start, end, **kwargs)[来源]

设置线条的起点和终点。

如果 startendMobjects,这将给出它们的中心。

Parameters:
  • 开始 (ndarray) – 起点或 Mobject

  • 结束 (ndarray) – 结束点或 Mobject

Return type: