球体

限定名称: manim.mobject.three\_d.three\_dimensions.Sphere

class Sphere(center=array([0., 0., 0.]), radius=1, resolution=None, u_range=(0, 6.283185307179586), v_range=(0, 3.141592653589793), **kwargs)[source]

基类: Surface

一个三维球体。

参数:
  • center (Point3DLike) – Sphere 的中心。

  • radius (float) – Sphere 的半径。

  • resolution (Sequence[int] | None) – 对 Sphere 进行采样的数量。可以使用元组来分别定义 uv 的不同分辨率。

  • u_range (Sequence[float]) – u 变量的范围:(u_min, u_max)

  • v_range (Sequence[float]) – v 变量的范围:(v_min, v_max)

示例

示例: ExampleSphere

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

class ExampleSphere(ThreeDScene):
    def construct(self):
        self.set_camera_orientation(phi=PI / 6, theta=PI / 6)
        sphere1 = Sphere(
            center=(3, 0, 0),
            radius=1,
            resolution=(20, 20),
            u_range=[0.001, PI - 0.001],
            v_range=[0, TAU]
        )
        sphere1.set_color(RED)
        self.add(sphere1)
        sphere2 = Sphere(center=(-1, -3, 0), radius=2, resolution=(18, 18))
        sphere2.set_color(GREEN)
        self.add(sphere2)
        sphere3 = Sphere(center=(-1, 2, 0), radius=2, resolution=(16, 16))
        sphere3.set_color(BLUE)
        self.add(sphere3)
class ExampleSphere(ThreeDScene):
    def construct(self):
        self.set_camera_orientation(phi=PI / 6, theta=PI / 6)
        sphere1 = Sphere(
            center=(3, 0, 0),
            radius=1,
            resolution=(20, 20),
            u_range=[0.001, PI - 0.001],
            v_range=[0, TAU]
        )
        sphere1.set_color(RED)
        self.add(sphere1)
        sphere2 = Sphere(center=(-1, -3, 0), radius=2, resolution=(18, 18))
        sphere2.set_color(GREEN)
        self.add(sphere2)
        sphere3 = Sphere(center=(-1, 2, 0), radius=2, resolution=(16, 16))
        sphere3.set_color(BLUE)
        self.add(sphere3)

方法

func

定义所绘制的 Sphere 的 z 值。

属性

animate (动画)

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

animation_overrides (动画覆盖)

颜色

depth (深度)

mobject 的深度。

fill_color (填充颜色)

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

height (高度)

mobject 的高度。

n_points_per_curve (每条曲线的点数)

sheen_factor (光泽因子)

stroke_color (描边颜色)

width (宽度)

mobject 的宽度。

_original__init__(center=array([0., 0., 0.]), radius=1, resolution=None, u_range=(0, 6.283185307179586), v_range=(0, 3.141592653589793), **kwargs)

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

参数:
  • center (Point3DLike)

  • radius (float)

  • resolution (Sequence[int] | None)

  • u_range (Sequence[float])

  • v_range (Sequence[float])

返回类型:

func(u, v)[source]

定义所绘制的 Sphere 的 z 值。

返回:

定义 Sphere 的 z 值。

返回类型:

numpy.array

参数:
  • u (float)

  • v (float)