manim.utils.space_ops

Utility functions for two- and three-dimensional vectors.

Functions

R3_to_complex(point)[source]
angle_axis_from_quaternion(quaternion)[source]
angle_between(v1, v2)[source]
angle_between_vectors(v1, v2)[source]

Returns the angle between two 3D vectors. This angle will always be btw 0 and pi

angle_of_vector(vector)[source]

Returns polar coordinate theta when vector is project on xy plane

center_of_mass(points)[source]
compass_directions(n=4, start_vect=array([1.0, 0.0, 0.0]))[source]
complex_func_to_R3_func(complex_func)[source]
complex_to_R3(complex_num)[source]
cross(v1, v2)[source]
cross2d(a, b)[source]
earclip_triangulation(verts, ring_ends)[source]

Returns a list of indices giving a triangulation of a polygon, potentially with holes

  • verts is a numpy array of points

  • ring_ends is a list of indices indicating where

the ends of new paths are

find_intersection(p0, v0, p1, v1, threshold=1e-05)[source]

Return the intersection of a line passing through p0 in direction v0 with one passing through p1 in direction v1. (Or array of intersections from arrays of such points/directions). For 3d values, it returns the point on the ray p0 + v0 * t closest to the ray p1 + v1 * t

get_norm(vect)[source]
get_unit_normal(v1, v2, tol=1e-06)[source]
get_winding_number(points)[source]
line_intersection(line1, line2)[source]

Returns intersection point of two lines, each defined with a pair of vectors determining the end points

midpoint(point1, point2)[source]
norm_squared(v)[source]
normalize(vect, fall_back=None)[source]
normalize_along_axis(array, axis, fall_back=None)[source]
project_along_vector(point, vector)[source]
quaternion_conjugate(quaternion)[source]
quaternion_from_angle_axis(angle, axis, axis_normalized=False)[source]
quaternion_mult(*quats)[source]
rotate_vector(vector, angle, axis=array([0.0, 0.0, 1.0]))[source]
rotation_about_z(angle)[source]
rotation_matrix(angle, axis)[source]

Rotation in R^3 about a specified axis of rotation.

rotation_matrix_from_quaternion(quat)[source]
rotation_matrix_transpose(angle, axis)[source]
rotation_matrix_transpose_from_quaternion(quat)[source]
shoelace(x_y)[source]

2D implementation of the shoelace formula.

Returns

Returns signed area.

Return type

float

shoelace_direction(x_y)[source]

Uses the area determined by the shoelace method to determine whether the input set of points is directed clockwise or counterclockwise.

Returns

Either "CW" or "CCW".

Return type

str

thick_diagonal(dim, thickness=2)[source]
z_to_vector(vector)[source]

Returns some matrix in SO(3) which takes the z-axis to the (normalized) vector provided as an argument