Sideway
output.to from Sideway
Draft for Information Only

Content

Manim Vector Field
 Codes in Vector_field.py
  Import
  Constant
  Function Front
  Class VectorField(VGroup)
   Configuration
   Functions
  Class StreamLines(VGroup)
   Configuration
   Functions
  Class ShowPassingFlashWithThinningStrokeWidth(AnimationGroup)
   Configuration
   Functions
  Class AnimatedStreamLines(VGroup)
   Configuration
   Functions
 Source and Reference

Manim Vector Field

The vector field VMobject object in Manim is defined in vector_field.py.

Codes in Vector_field.py

Available codes defined in manimlib.mobject.vector_field.py

image

Four classes, VectorField(VGroup), StreamLines(VGroup), ShowPassingFlashWithThinningStrokeWidth(AnimationGroup) and AnimatedStreamLines(VGroup) are defined.

Import

import numpy as np
import os
import itertools as it
from PIL import Image
import random

from manimlib.constants import *

from manimlib.animation.composition import AnimationGroup
from manimlib.animation.indication import ShowPassingFlash
from manimlib.mobject.geometry import Vector
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.mobject.types.vectorized_mobject import VMobject
from manimlib.utils.bezier import inverse_interpolate
from manimlib.utils.bezier import interpolate
from manimlib.utils.color import color_to_rgb
from manimlib.utils.color import rgb_to_color
from manimlib.utils.config_ops import digest_config
from manimlib.utils.rate_functions import linear
from manimlib.utils.simple_functions import sigmoid
from manimlib.utils.space_ops import get_norm
# from manimlib.utils.space_ops import normalize

Constant

DEFAULT_SCALAR_FIELD_COLORS = [BLUE_E, GREEN, YELLOW, RED]

Function Front

  • def get_colored_background_image(scalar_field_func, number_to_rgb_func, pixel_height=DEFAULT_PIXEL_HEIGHT, pixel_width=DEFAULT_PIXEL_WIDTH)
  • def get_rgb_gradient_function(min_value=0, max_value=1, colors=[BLUE, RED], flip_alphas=True, # Why? )
    • def func(values)
  • def get_color_field_image_file(scalar_func, min_value=0, max_value=2, colors=DEFAULT_SCALAR_FIELD_COLORS )
  • def move_along_vector_field(mobject, func)
  • def move_submobjects_along_vector_field(mobject, func)
    • def apply_nudge(mob, dt)
  • def move_points_along_vector_field(mobject, func)
    • def apply_nudge(self, dt)

Class VectorField(VGroup)

class manimlib.mobject.vector_field.VectorField(VGroup)version 19Dec2019

Configuration

CONFIG = {
        "delta_x": 0.5,
        "delta_y": 0.5,
        "x_min": int(np.floor(-FRAME_WIDTH / 2)),
        "x_max": int(np.ceil(FRAME_WIDTH / 2)),
        "y_min": int(np.floor(-FRAME_HEIGHT / 2)),
        "y_max": int(np.ceil(FRAME_HEIGHT / 2)),
        "min_magnitude": 0,
        "max_magnitude": 2,
        "colors": DEFAULT_SCALAR_FIELD_COLORS,
        # Takes in actual norm, spits out displayed norm
        "length_func": lambda norm: 0.45 * sigmoid(norm),
        "opacity": 1.0,
        "vector_config": {},
    }

Functions

  • def __init__(self, func, **kwargs)
  • def get_vector(self, point, **kwargs)

Class StreamLines(VGroup)

class manimlib.mobject.vector_field.StreamLines(VGroup)version 19Dec2019

Configuration

    CONFIG = {
        # TODO, this is an awkward way to inherit
        # defaults to a method.
        "start_points_generator_config": {},
        # Config for choosing start points
        "x_min": -8,
        "x_max": 8,
        "y_min": -5,
        "y_max": 5,
        "delta_x": 0.5,
        "delta_y": 0.5,
        "n_repeats": 1,
        "noise_factor": None,
        # Config for drawing lines
        "dt": 0.05,
        "virtual_time": 3,
        "n_anchors_per_line": 100,
        "stroke_width": 1,
        "stroke_color": WHITE,
        "color_by_arc_length": True,
        # Min and max arc lengths meant to define
        # the color range, should color_by_arc_length be True
        "min_arc_length": 0,
        "max_arc_length": 12,
        "color_by_magnitude": False,
        # Min and max magnitudes meant to define
        # the color range, should color_by_magnitude be True
        "min_magnitude": 0.5,
        "max_magnitude": 1.5,
        "colors": DEFAULT_SCALAR_FIELD_COLORS,
        "cutoff_norm": 15,
    }

Functions

  • def __init__(self, func, **kwargs)
  • def get_start_points(self)

Class ShowPassingFlashWithThinningStrokeWidth(AnimationGroup)

class manimlib.mobject.vector_field.ShowPassingFlashWithThinningStrokeWidth(AnimationGroup)version 19Dec2019

Configuration

    CONFIG = {
        "n_segments": 10,
        "time_width": 0.1,
        "remover": True
    }

Functions

  • def __init__(self, vmobject, **kwargs)

Class AnimatedStreamLines(VGroup)

class manimlib.mobject.vector_field.AnimatedStreamLines(VGroup)version 19Dec2019

Configuration

    CONFIG = {
        "lag_range": 4,
        "line_anim_class": ShowPassingFlash,
        "line_anim_config": {
            "run_time": 4,
            "rate_func": linear,
            "time_width": 0.3,
        },
    }

Functions

  • def __init__(self, stream_lines, **kwargs)
  • def update(self, dt)

Source and Reference

https://github.com/3b1b/manim19Dec2019

©sideway

ID: 210700026 Last Updated: 7/26/2021 Revision: 0

IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 337

Reference 68

Computer

Hardware 154

Software

Application 207

Digitization 25

Latex 35

Manim 203

Numeric 19

Programming

Web 285

Unicode 504

HTML 65

CSS 63

SVG 6

ASP.NET 210

OS 422

DeskTop 7

Python 64

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 25

Coordinate Geometry 1

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2021 Sideway . All rights reserved Disclaimers last modified on 06 September 2019