向量

限定名称: manim.mobject.geometry.line.Vector

class Vector(direction=array([1., 0., 0.]), buff=0, **kwargs)[source]

基类: Arrow

专门用于图中的向量。

注意

请勿与Vector2DVector3DVectorND类型别名混淆,它们不是Mobject!

参数:
  • direction (Point2DLike | Point3DLike) – 箭头的方向。

  • buff (float) – 向量与其端点的距离。

  • kwargs (Any) – 将传递给Arrow的额外参数。

示例

示例:VectorExample

../_images/VectorExample-1.png
from manim import *

class VectorExample(Scene):
    def construct(self):
        plane = NumberPlane()
        vector_1 = Vector([1,2])
        vector_2 = Vector([-5,-2])
        self.add(plane, vector_1, vector_2)
class VectorExample(Scene):
    def construct(self):
        plane = NumberPlane()
        vector_1 = Vector([1,2])
        vector_2 = Vector([-5,-2])
        self.add(plane, vector_1, vector_2)

方法

coordinate_label

根据向量的坐标创建一个标签。

属性

animate (动画)

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

animation_overrides (动画覆盖)

颜色

depth (深度)

mobject 的深度。

fill_color (填充颜色)

如果存在多种颜色(用于渐变),则返回第一种颜色

height (高度)

mobject 的高度。

n_points_per_curve (每条曲线的点数)

sheen_factor (光泽因子)

stroke_color (描边颜色)

width (宽度)

mobject 的宽度。

_original__init__(direction=array([1., 0., 0.]), buff=0, **kwargs)

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

参数:
返回类型:

coordinate_label(integer_labels=True, n_dim=2, color=None, **kwargs)[source]

根据向量的坐标创建一个标签。

参数:
  • integer_labels (bool) – 是否将坐标四舍五入为整数。

  • n_dim (int) – 向量的维数。

  • color (ParsableManimColor | None) – 设置标签的颜色,可选。

  • kwargs (Any) – 将传递给Matrix的额外参数。

返回:

该标签。

返回类型:

矩阵

示例

示例:VectorCoordinateLabel

../_images/VectorCoordinateLabel-1.png
from manim import *

class VectorCoordinateLabel(Scene):
    def construct(self):
        plane = NumberPlane()

        vec_1 = Vector([1, 2])
        vec_2 = Vector([-3, -2])
        label_1 = vec_1.coordinate_label()
        label_2 = vec_2.coordinate_label(color=YELLOW)

        self.add(plane, vec_1, vec_2, label_1, label_2)
class VectorCoordinateLabel(Scene):
    def construct(self):
        plane = NumberPlane()

        vec_1 = Vector([1, 2])
        vec_2 = Vector([-3, -2])
        label_1 = vec_1.coordinate_label()
        label_2 = vec_2.coordinate_label(color=YELLOW)

        self.add(plane, vec_1, vec_2, label_1, label_2)