Skip to content

Can someone explain how to create the vector field? #1537

Answered by TonyCrane
Jack071120 asked this question in Q&A
Discussion options

You must be logged in to vote

Just like this? :

class Code1537(Scene):
    def construct(self):
        plane = NumberPlane()
        vector_field = VectorField(
            lambda x, y: np.array([x, y]), plane,
            magnitude_range=(0, 5),
            vector_config={"thickness": 0.025}
        )
        self.add(plane, vector_field)


And you can also learn it from 3b1b's newest video code: https://github.com/3b1b/videos/blob/master/_2021/matrix_exp.py
Such as:

class Code1537(Scene):
    def construct(self):
        matrix = np.array(self.matrix)
        def func(x, y):
            return 0.15 * np.dot(matrix.T, [x, y])

        plane = NumberPlane()
        vector_field = VectorField(
            func, plane,
…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Jack071120
Comment options

@Acpear
Comment options

Answer selected by TonyCrane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants