space_ops

该部分代码来自 3b1b/manim,有待重构

janim.utils.space_ops.cross(v1: ndarray, v2: ndarray) list[ndarray]
janim.utils.space_ops.get_norm(vect: Iterable) float
janim.utils.space_ops.det(a: Iterable, b: Iterable) float
janim.utils.space_ops.normalize(vect: ndarray, fall_back: ndarray | None = None) ndarray
janim.utils.space_ops.quaternion_mult(*quats: Sequence[float]) list[float]
janim.utils.space_ops.quaternion_from_angle_axis(angle: float, axis: ndarray) list[float]
janim.utils.space_ops.angle_axis_from_quaternion(quat: Sequence[float]) tuple[float, ndarray]
janim.utils.space_ops.quaternion_conjugate(quaternion: Iterable) list
janim.utils.space_ops.rotate_vector(vector: Iterable, angle: float, axis: ndarray = array([0., 0., 1.])) ndarray | list[float]
janim.utils.space_ops.rotate_vector_2d(vector: Iterable, angle: float)
janim.utils.space_ops.rotation_matrix_transpose_from_quaternion(quat: Iterable) ndarray
janim.utils.space_ops.rotation_matrix_from_quaternion(quat: Iterable) ndarray
janim.utils.space_ops.rotation_matrix(angle: float, axis: ndarray) ndarray

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

janim.utils.space_ops.rotation_matrix_transpose(angle: float, axis: ndarray) ndarray
janim.utils.space_ops.rotation_about_z(angle: float) list[list[float]]
janim.utils.space_ops.rotation_between_vectors(v1, v2) ndarray
janim.utils.space_ops.z_to_vector(vector: ndarray) ndarray
janim.utils.space_ops.angle_of_vector(vector: Sequence[float]) float

Returns polar coordinate theta when vector is project on xy plane

janim.utils.space_ops.angle_between_vectors(v1: ndarray, v2: ndarray) float

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

janim.utils.space_ops.project_along_vector(point: ndarray, vector: ndarray) ndarray
janim.utils.space_ops.normalize_along_axis(array: ndarray, axis: ndarray) ndarray
janim.utils.space_ops.get_unit_normal(v1: ndarray, v2: ndarray, tol: float = 1e-06) ndarray
janim.utils.space_ops.thick_diagonal(dim: int, thickness: int = 2) ndarray
janim.utils.space_ops.compass_directions(n: int = 4, start_vect: ndarray = array([1., 0., 0.])) ndarray
janim.utils.space_ops.complex_to_R3(complex_num: complex) ndarray
janim.utils.space_ops.R3_to_complex(point: Sequence[float]) complex
janim.utils.space_ops.complex_func_to_R3_func(complex_func: Callable[[complex], complex]) Callable[[ndarray], ndarray]
janim.utils.space_ops.center_of_mass(points: Iterable[Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]]) ndarray
janim.utils.space_ops.midpoint(point1: Sequence[float], point2: Sequence[float]) ndarray
janim.utils.space_ops.line_intersection(line1: Sequence[Sequence[float]], line2: Sequence[Sequence[float]]) ndarray

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

janim.utils.space_ops.find_intersection(p0: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], v0: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], p1: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], v1: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], threshold: float = 1e-05) ndarray

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

janim.utils.space_ops.get_closest_point_on_line(a: ndarray, b: ndarray, p: ndarray) ndarray

It returns point x such that x is on line ab and xp is perpendicular to ab. If x lies beyond ab line, then it returns nearest edge(a or b).

janim.utils.space_ops.get_winding_number(points: Iterable[float]) float
janim.utils.space_ops.cross2d(a: ndarray, b: ndarray) ndarray
janim.utils.space_ops.tri_area(a: Sequence[float], b: Sequence[float], c: Sequence[float]) float
janim.utils.space_ops.is_inside_triangle(p: ndarray, a: ndarray, b: ndarray, c: ndarray) bool

Test if point p is inside triangle abc

janim.utils.space_ops.norm_squared(v: Sequence[float]) float