본문 바로가기

Programming/Manim Lectures

[04-1]Coordinate System

반응형

Manim expresses a specific position on the screen with the combination of (x,y,z), with the screen as the x-axis and the vertical as the y-axis and z is zero.

The x-axis has a left end value of -7.1, the right end is 7.1, and the y axis has -4.0 at the bottom and 4.0 at the top.

 

The total frame height value is defined as 'FRAME_HEIGHT' and frame width is defined as 'FRAME_WIDTH' in the manimlib/constants.py file.

 

FRAME_HEIGHT = 8.0
FRAME_WIDTH = FRAME_HEIGHT * DEFAULT_PIXEL_WIDTH / DEFAULT_PIXEL_HEIGHT
FRAME_Y_RADIUS = FRAME_HEIGHT / 2
FRAME_X_RADIUS = FRAME_WIDTH / 2

DEFAULT_PIXEL_HEIGHT = PRODUCTION_QUALITY_CAMERA_CONFIG["pixel_height"]
DEFAULT_PIXEL_WIDTH = PRODUCTION_QUALITY_CAMERA_CONFIG["pixel_width"]

PRODUCTION_QUALITY_CAMERA_CONFIG = {
    "pixel_height": 1440,
    "pixel_width": 2560,
    "frame_rate": 60,
}
FRAME_HEIGHT is fixed as 8.0 but FRAME_WIDTH will be calculated with the above equation, so the FRAME_WIDTH value depends on the pixel_height and pixel_width.
The calculated vaue of the FRAME_WIDHT is 14.22222

 

The coorThe coordinates of the screen are as follows.

 

 

An array of numpy is used to represent (x,y) coordinates. By the way, numpy's array has 3 values of x,y,z, so Manim uses only the previous x,y value and treats z as 0. (When expressing a 3D graph, z value is also used)

 

numpy is a popular library for mathematical operations such as matrices, vectors, etc. in Python, which is automatically installed when you install the packages required by Manim. However, if numpy is not installed or erased, you can easily install it via 'pip install numpy' command in the Command Prompt window.

 

For example, if you want to move an object named 'mob' to the location of (-2.0, 3.0) on the screen, you can do something like 'mob_move(np_array([-2.0, 3.0, 0]))'

 

In this way, you can move the object by specifying the absolute position of the coordinate system, or you can move it by specifying a relative position like the right side of some other object.

 

From the next page, we will explain how to move an object to the absolute position and move to the relative position.

 


Next: [04-2] Move to absolute position(move_to)

 

[04-2] Move to absolute position(move_to)

As we saw in the previous page, Manim can acess the screen position with (x,y,0) coordinates. x has a value between [-7.1, 7.1] and y has a value between [-4.0, 4.0] (x,y) coordinates can't be expre..

infograph.tistory.com

Go To: [99] Table of Contents

반응형