gdpc.vector_tools¶
Various vector utilities.
This module contains, roughly in order:
Protocols for vector-like classes.
Helpful vector constants.
General vector utilities.
Generators for various geometrical shapes.
- class Vec2iLike¶
Protocol for a vector that contains two integers.
A class is a Vec2iLike if it contains two integers, which can be accessed with both indexing and iteration.
- __init__(*args, **kwargs)¶
- class Vec3iLike¶
Protocol for a vector that contains three integers.
A class is a Vec3iLike if it contains three integers, which can be accessed with both indexing and iteration.
- __init__(*args, **kwargs)¶
- class Vec2bLike¶
Protocol for a vector that contains two bools.
A class is a Vec2iLike if it contains two bools, which can be accessed with both indexing and iteration.
- __init__(*args, **kwargs)¶
- class Vec3bLike¶
Protocol for a vector that contains three bools.
A class is a Vec3iLike if it contains three bools, which can be accessed with both indexing and iteration.
- __init__(*args, **kwargs)¶
-
ZERO_2D =
ivec2( 0, 0 )¶
-
X_2D =
ivec2( 1, 0 )¶
-
Y_2D =
ivec2( 0, 1 )¶
-
XY_2D : ivec2 =
ivec2( 1, 1 )¶
-
EAST_2D : ivec2 =
ivec2( 1, 0 )¶
-
WEST_2D : ivec2 =
ivec2( -1, 0 )¶
-
SOUTH_2D : ivec2 =
ivec2( 0, 1 )¶
-
NORTH_2D : ivec2 =
ivec2( 0, -1 )¶
-
NORTHWEST_2D : ivec2 =
ivec2( -1, -1 )¶
-
NORTHEAST_2D : ivec2 =
ivec2( 1, -1 )¶
-
SOUTHEAST_2D : ivec2 =
ivec2( 1, 1 )¶
-
SOUTHWEST_2D : ivec2 =
ivec2( -1, 1 )¶
-
CARDINALS_2D : FrozenSet[ivec2] =
frozenset({ivec2( 0, -1 ), ivec2( 1, 0 ), ivec2( 0, 1 ), ivec2( -1, 0 )})¶
-
INTERCARDINALS_2D : FrozenSet[ivec2] =
frozenset({ivec2( -1, -1 ), ivec2( 1, -1 ), ivec2( 1, 1 ), ivec2( -1, 1 )})¶
-
CARDINALS_AND_DIAGONALS_2D : FrozenSet[ivec2] =
frozenset({ivec2( -1, 0 ), ivec2( -1, -1 ), ivec2( 1, 0 ), ivec2( 1, -1 ), ivec2( 0, -1 ), ivec2( 1, 1 ), ivec2( 0, 1 ), ivec2( -1, 1 )})¶
-
DIAGONALS_2D =
frozenset({ivec2( -1, -1 ), ivec2( 1, -1 ), ivec2( 1, 1 ), ivec2( -1, 1 )})¶
-
ORDERED_CARDINALS_2D : Tuple[ivec2, ...] =
(ivec2( 1, 0 ), ivec2( 0, 1 ), ivec2( -1, 0 ), ivec2( 0, -1 ))¶
-
ORDERED_INTERCARDINALS_2D : Tuple[ivec2, ...] =
(ivec2( 1, 1 ), ivec2( -1, 1 ), ivec2( -1, -1 ), ivec2( 1, -1 ))¶
-
ORDERED_CARDINALS_AND_DIAGONALS_2D : Tuple[ivec2, ...] =
(ivec2( 1, 0 ), ivec2( 1, 1 ), ivec2( 0, 1 ), ivec2( -1, 1 ), ivec2( -1, 0 ), ivec2( -1, -1 ), ivec2( 0, -1 ), ivec2( 1, -1 ))¶
-
ZERO_3D =
ivec3( 0, 0, 0 )¶
-
X_3D =
ivec3( 1, 0, 0 )¶
-
Y_3D =
ivec3( 0, 1, 0 )¶
-
Z_3D =
ivec3( 0, 0, 1 )¶
-
XY_3D : ivec3 =
ivec3( 1, 1, 0 )¶
-
XZ_3D : ivec3 =
ivec3( 1, 0, 1 )¶
-
YZ_3D : ivec3 =
ivec3( 0, 1, 1 )¶
-
XYZ_3D : ivec3 =
ivec3( 1, 1, 1 )¶
-
UP_3D : ivec3 =
ivec3( 0, 1, 0 )¶
-
DOWN_3D : ivec3 =
ivec3( 0, -1, 0 )¶
-
EAST_3D : ivec3 =
ivec3( 1, 0, 0 )¶
-
WEST_3D : ivec3 =
ivec3( -1, 0, 0 )¶
-
SOUTH_3D : ivec3 =
ivec3( 0, 0, 1 )¶
-
NORTH_3D : ivec3 =
ivec3( 0, 0, -1 )¶
-
NORTHEAST_3D : ivec3 =
ivec3( 1, 0, -1 )¶
-
NORTHWEST_3D : ivec3 =
ivec3( -1, 0, -1 )¶
-
SOUTHWEST_3D : ivec3 =
ivec3( -1, 0, 1 )¶
-
SOUTHEAST_3D : ivec3 =
ivec3( 1, 0, 1 )¶
-
CARDINALS_3D : FrozenSet[ivec3] =
frozenset({ivec3( 0, 0, 1 ), ivec3( 1, 0, 0 ), ivec3( -1, 0, 0 ), ivec3( 0, 0, -1 )})¶
-
INTERCARDINALS_3D : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 1 ), ivec3( 1, 0, 1 ), ivec3( 1, 0, -1 ), ivec3( -1, 0, -1 )})¶
-
CARDINALS_AND_DIAGONALS_3D : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 0 ), ivec3( -1, 0, 1 ), ivec3( 1, 0, 0 ), ivec3( 1, 0, 1 ), ivec3( 0, 0, -1 ), ivec3( 0, 0, 1 ), ivec3( 1, 0, -1 ), ivec3( -1, 0, -1 )})¶
-
ORDERED_CARDINALS_3D : Tuple[ivec3, ...] =
(ivec3( 1, 0, 0 ), ivec3( 0, 0, 1 ), ivec3( -1, 0, 0 ), ivec3( 0, 0, -1 ))¶
-
ORDERED_INTERCARDINALS_3D : Tuple[ivec3, ...] =
(ivec3( 1, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, -1 ), ivec3( 1, 0, -1 ))¶
-
ORDERED_CARDINALS_AND_DIAGONALS_3D : Tuple[ivec3, ...] =
(ivec3( 1, 0, 0 ), ivec3( 1, 0, 1 ), ivec3( 0, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, 0 ), ivec3( -1, 0, -1 ), ivec3( 0, 0, -1 ), ivec3( 1, 0, -1 ))¶
-
DIRECTIONS_3D : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 0 ), ivec3( 1, 0, 0 ), ivec3( 0, 1, 0 ), ivec3( 0, 0, 1 ), ivec3( 0, -1, 0 ), ivec3( 0, 0, -1 )})¶
-
EDGE_DIAGONALS_3D : FrozenSet[ivec3] =
frozenset({ivec3( 0, 1, 1 ), ivec3( -1, 0, 1 ), ivec3( 0, 1, -1 ), ivec3( 1, 0, 1 ), ivec3( 0, -1, -1 ), ivec3( 1, 1, 0 ), ivec3( 0, -1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, -1, 0 ), ivec3( 1, -1, 0 ), ivec3( 1, 0, -1 ), ivec3( -1, 0, -1 )})¶
-
DIRECTIONS_AND_EDGE_DIAGONALS_3D : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 0 ), ivec3( -1, -1, 0 ), ivec3( 0, 1, -1 ), ivec3( 0, 1, 0 ), ivec3( -1, 0, 1 ), ivec3( 0, -1, -1 ), ivec3( 1, 1, 0 ), ivec3( 0, 0, -1 ), ivec3( 0, 0, 1 ), ivec3( 0, -1, 0 ), ivec3( 0, -1, 1 ), ivec3( 1, 0, -1 ), ivec3( 1, 0, 1 ), ivec3( 1, 0, 0 ), ivec3( 1, -1, 0 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, 0, -1 )})¶
-
CORNER_DIAGONALS_3D : FrozenSet[ivec3] =
frozenset({ivec3( -1, -1, 1 ), ivec3( 1, -1, 1 ), ivec3( -1, 1, 1 ), ivec3( 1, 1, -1 ), ivec3( -1, 1, -1 ), ivec3( 1, 1, 1 ), ivec3( 1, -1, -1 ), ivec3( -1, -1, -1 )})¶
-
DIRECTIONS_AND_ALL_DIAGONALS_3D : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 0 ), ivec3( -1, -1, 0 ), ivec3( 0, 1, -1 ), ivec3( 0, 1, 0 ), ivec3( -1, -1, 1 ), ivec3( 1, 1, -1 ), ivec3( -1, 0, 1 ), ivec3( 0, -1, -1 ), ivec3( 1, 1, 0 ), ivec3( 0, 0, -1 ), ivec3( 0, 0, 1 ), ivec3( 0, -1, 0 ), ivec3( 0, -1, 1 ), ivec3( 1, 1, 1 ), ivec3( 1, -1, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 1 ), ivec3( 1, 0, 1 ), ivec3( 1, 0, 0 ), ivec3( 1, -1, 0 ), ivec3( -1, 1, 1 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, 1, -1 ), ivec3( -1, -1, -1 ), ivec3( -1, 0, -1 )})¶
-
DIAGONALS_3D =
frozenset({ivec3( 0, 1, 1 ), ivec3( -1, -1, 0 ), ivec3( 0, 1, -1 ), ivec3( -1, -1, 1 ), ivec3( 1, 1, -1 ), ivec3( -1, 0, 1 ), ivec3( 0, -1, -1 ), ivec3( 1, 1, 0 ), ivec3( 0, -1, 1 ), ivec3( 1, 1, 1 ), ivec3( 1, -1, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 1 ), ivec3( 1, 0, 1 ), ivec3( 1, -1, 0 ), ivec3( -1, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, 1, -1 ), ivec3( -1, -1, -1 ), ivec3( -1, 0, -1 )})¶
-
ORDERED_EDGE_DIAGONALS_3D : Tuple[ivec3, ...] =
(ivec3( 1, 1, 0 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( 0, 1, -1 ), ivec3( 1, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 0 ), ivec3( 0, -1, 1 ), ivec3( -1, -1, 0 ), ivec3( 0, -1, -1 ))¶
-
ORDERED_DIRECTIONS_AND_EDGE_DIAGONALS_3D : Tuple[ivec3, ...] =
(ivec3( 0, 1, 0 ), ivec3( 1, 1, 0 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( 0, 1, -1 ), ivec3( 1, 0, 0 ), ivec3( 1, 0, 1 ), ivec3( 0, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, 0 ), ivec3( -1, 0, -1 ), ivec3( 0, 0, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 0 ), ivec3( 0, -1, 1 ), ivec3( -1, -1, 0 ), ivec3( 0, -1, -1 ), ivec3( 0, -1, 0 ))¶
-
ORDERED_CORNER_DIAGONALS_3D : Tuple[ivec3, ...] =
(ivec3( 1, 1, 1 ), ivec3( -1, 1, 1 ), ivec3( -1, 1, -1 ), ivec3( 1, 1, -1 ), ivec3( 1, -1, 1 ), ivec3( -1, -1, 1 ), ivec3( -1, -1, -1 ), ivec3( 1, -1, -1 ))¶
-
ORDERED_DIRECTIONS_AND_ALL_DIAGONALS_3D : Tuple[ivec3, ...] =
(ivec3( 0, 1, 0 ), ivec3( 1, 1, 0 ), ivec3( 1, 1, 1 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, 1, -1 ), ivec3( 0, 1, -1 ), ivec3( 1, 1, -1 ), ivec3( 1, 0, 0 ), ivec3( 1, 0, 1 ), ivec3( 0, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, 0 ), ivec3( -1, 0, -1 ), ivec3( 0, 0, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 0 ), ivec3( 1, -1, 1 ), ivec3( 0, -1, 1 ), ivec3( -1, -1, 1 ), ivec3( -1, -1, 0 ), ivec3( -1, -1, -1 ), ivec3( 0, -1, -1 ), ivec3( 1, -1, -1 ), ivec3( 0, -1, 0 ))¶
-
ORDERED_DIAGONALS : Tuple[ivec3, ...] =
(ivec3( 1, 1, 0 ), ivec3( 1, 1, 1 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, 1, -1 ), ivec3( 0, 1, -1 ), ivec3( 1, 1, -1 ), ivec3( 1, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 0 ), ivec3( 1, -1, 1 ), ivec3( 0, -1, 1 ), ivec3( -1, -1, 1 ), ivec3( -1, -1, 0 ), ivec3( -1, -1, -1 ), ivec3( 0, -1, -1 ), ivec3( 1, -1, -1 ))¶
-
ZERO : ivec3 =
ivec3( 0, 0, 0 )¶
-
X : ivec3 =
ivec3( 1, 0, 0 )¶
-
Y : ivec3 =
ivec3( 0, 1, 0 )¶
-
Z : ivec3 =
ivec3( 0, 0, 1 )¶
-
XY : ivec3 =
ivec3( 1, 1, 0 )¶
-
XZ : ivec3 =
ivec3( 1, 0, 1 )¶
-
YZ : ivec3 =
ivec3( 0, 1, 1 )¶
-
XYZ : ivec3 =
ivec3( 1, 1, 1 )¶
-
UP : ivec3 =
ivec3( 0, 1, 0 )¶
-
DOWN : ivec3 =
ivec3( 0, -1, 0 )¶
-
EAST : ivec3 =
ivec3( 1, 0, 0 )¶
-
WEST : ivec3 =
ivec3( -1, 0, 0 )¶
-
SOUTH : ivec3 =
ivec3( 0, 0, 1 )¶
-
NORTH : ivec3 =
ivec3( 0, 0, -1 )¶
-
NORTHEAST : ivec3 =
ivec3( 1, 0, -1 )¶
-
NORTHWEST : ivec3 =
ivec3( -1, 0, -1 )¶
-
SOUTHWEST : ivec3 =
ivec3( -1, 0, 1 )¶
-
SOUTHEAST : ivec3 =
ivec3( 1, 0, 1 )¶
-
CARDINALS : FrozenSet[ivec3] =
frozenset({ivec3( 0, 0, 1 ), ivec3( 1, 0, 0 ), ivec3( -1, 0, 0 ), ivec3( 0, 0, -1 )})¶
-
INTERCARDINALS : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 1 ), ivec3( 1, 0, 1 ), ivec3( 1, 0, -1 ), ivec3( -1, 0, -1 )})¶
-
CARDINALS_AND_DIAGONALS : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 0 ), ivec3( -1, 0, 1 ), ivec3( 1, 0, 0 ), ivec3( 1, 0, 1 ), ivec3( 0, 0, -1 ), ivec3( 0, 0, 1 ), ivec3( 1, 0, -1 ), ivec3( -1, 0, -1 )})¶
-
EDGE_DIAGONALS : FrozenSet[ivec3] =
frozenset({ivec3( 0, 1, 1 ), ivec3( -1, 0, 1 ), ivec3( 0, 1, -1 ), ivec3( 1, 0, 1 ), ivec3( 0, -1, -1 ), ivec3( 1, 1, 0 ), ivec3( 0, -1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, -1, 0 ), ivec3( 1, -1, 0 ), ivec3( 1, 0, -1 ), ivec3( -1, 0, -1 )})¶
-
CORNER_DIAGONALS : FrozenSet[ivec3] =
frozenset({ivec3( -1, -1, 1 ), ivec3( 1, -1, 1 ), ivec3( -1, 1, 1 ), ivec3( 1, 1, -1 ), ivec3( -1, 1, -1 ), ivec3( 1, 1, 1 ), ivec3( 1, -1, -1 ), ivec3( -1, -1, -1 )})¶
-
DIRECTIONS : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 0 ), ivec3( 1, 0, 0 ), ivec3( 0, 1, 0 ), ivec3( 0, 0, 1 ), ivec3( 0, -1, 0 ), ivec3( 0, 0, -1 )})¶
-
DIRECTIONS_AND_EDGE_DIAGONALS : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 0 ), ivec3( -1, -1, 0 ), ivec3( 0, 1, -1 ), ivec3( 0, 1, 0 ), ivec3( -1, 0, 1 ), ivec3( 0, -1, -1 ), ivec3( 1, 1, 0 ), ivec3( 0, 0, -1 ), ivec3( 0, 0, 1 ), ivec3( 0, -1, 0 ), ivec3( 0, -1, 1 ), ivec3( 1, 0, -1 ), ivec3( 1, 0, 1 ), ivec3( 1, 0, 0 ), ivec3( 1, -1, 0 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, 0, -1 )})¶
-
DIRECTIONS_AND_ALL_DIAGONALS : FrozenSet[ivec3] =
frozenset({ivec3( -1, 0, 0 ), ivec3( -1, -1, 0 ), ivec3( 0, 1, -1 ), ivec3( 0, 1, 0 ), ivec3( -1, -1, 1 ), ivec3( 1, 1, -1 ), ivec3( -1, 0, 1 ), ivec3( 0, -1, -1 ), ivec3( 1, 1, 0 ), ivec3( 0, 0, -1 ), ivec3( 0, 0, 1 ), ivec3( 0, -1, 0 ), ivec3( 0, -1, 1 ), ivec3( 1, 1, 1 ), ivec3( 1, -1, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 1 ), ivec3( 1, 0, 1 ), ivec3( 1, 0, 0 ), ivec3( 1, -1, 0 ), ivec3( -1, 1, 1 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, 1, -1 ), ivec3( -1, -1, -1 ), ivec3( -1, 0, -1 )})¶
-
ORDERED_CARDINALS : Tuple[ivec3, ...] =
(ivec3( 1, 0, 0 ), ivec3( 0, 0, 1 ), ivec3( -1, 0, 0 ), ivec3( 0, 0, -1 ))¶
-
ORDERED_INTERCARDINALS : Tuple[ivec3, ...] =
(ivec3( 1, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, -1 ), ivec3( 1, 0, -1 ))¶
-
ORDERED_CARDINALS_AND_DIAGONALS : Tuple[ivec3, ...] =
(ivec3( 1, 0, 0 ), ivec3( 1, 0, 1 ), ivec3( 0, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, 0 ), ivec3( -1, 0, -1 ), ivec3( 0, 0, -1 ), ivec3( 1, 0, -1 ))¶
-
ORDERED_EDGE_DIAGONALS : Tuple[ivec3, ...] =
(ivec3( 1, 1, 0 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( 0, 1, -1 ), ivec3( 1, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 0 ), ivec3( 0, -1, 1 ), ivec3( -1, -1, 0 ), ivec3( 0, -1, -1 ))¶
-
ORDERED_CORNER_DIAGONALS : Tuple[ivec3, ...] =
(ivec3( 1, 1, 1 ), ivec3( -1, 1, 1 ), ivec3( -1, 1, -1 ), ivec3( 1, 1, -1 ), ivec3( 1, -1, 1 ), ivec3( -1, -1, 1 ), ivec3( -1, -1, -1 ), ivec3( 1, -1, -1 ))¶
-
ORDERED_DIRECTIONS : Tuple[ivec3, ...] =
(ivec3( 0, 1, 0 ), ivec3( 1, 0, 0 ), ivec3( 0, 0, 1 ), ivec3( -1, 0, 0 ), ivec3( 0, 0, -1 ), ivec3( 0, -1, 0 ))¶
-
ORDERED_DIRECTIONS_AND_EDGE_DIAGONALS : Tuple[ivec3, ...] =
(ivec3( 0, 1, 0 ), ivec3( 1, 1, 0 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( 0, 1, -1 ), ivec3( 1, 0, 0 ), ivec3( 1, 0, 1 ), ivec3( 0, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, 0 ), ivec3( -1, 0, -1 ), ivec3( 0, 0, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 0 ), ivec3( 0, -1, 1 ), ivec3( -1, -1, 0 ), ivec3( 0, -1, -1 ), ivec3( 0, -1, 0 ))¶
-
ORDERED_DIRECTIONS_AND_ALL_DIAGONALS : Tuple[ivec3, ...] =
(ivec3( 0, 1, 0 ), ivec3( 1, 1, 0 ), ivec3( 1, 1, 1 ), ivec3( 0, 1, 1 ), ivec3( -1, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, 1, -1 ), ivec3( 0, 1, -1 ), ivec3( 1, 1, -1 ), ivec3( 1, 0, 0 ), ivec3( 1, 0, 1 ), ivec3( 0, 0, 1 ), ivec3( -1, 0, 1 ), ivec3( -1, 0, 0 ), ivec3( -1, 0, -1 ), ivec3( 0, 0, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 0 ), ivec3( 1, -1, 1 ), ivec3( 0, -1, 1 ), ivec3( -1, -1, 1 ), ivec3( -1, -1, 0 ), ivec3( -1, -1, -1 ), ivec3( 0, -1, -1 ), ivec3( 1, -1, -1 ), ivec3( 0, -1, 0 ))¶
-
DIAGONALS : FrozenSet[ivec3] =
frozenset({ivec3( 0, 1, 1 ), ivec3( -1, -1, 0 ), ivec3( 0, 1, -1 ), ivec3( -1, -1, 1 ), ivec3( 1, 1, -1 ), ivec3( -1, 0, 1 ), ivec3( 0, -1, -1 ), ivec3( 1, 1, 0 ), ivec3( 0, -1, 1 ), ivec3( 1, 1, 1 ), ivec3( 1, -1, -1 ), ivec3( 1, 0, -1 ), ivec3( 1, -1, 1 ), ivec3( 1, 0, 1 ), ivec3( 1, -1, 0 ), ivec3( -1, 1, 1 ), ivec3( -1, 1, 0 ), ivec3( -1, 1, -1 ), ivec3( -1, -1, -1 ), ivec3( -1, 0, -1 )})¶
-
addDimension(vec: Vec2iLike, dimension: int, value: int =
0) ivec3¶ Inserts
valueintovecatdimensionand returns the resulting 3D vector
- trueMod2D(vec: Vec2iLike, modulus: int) ivec2¶
Returns
vmodulomodulus.Some libraries (notably, pyGLM), define vector classes with a % operator that behaves differently than Python-s built-in integer modulo when negative numbers are involved. This function is a workaround for that: it always performs vector modulo in the same way as Python’s built-in modulo.
- trueMod3D(vec: Vec3iLike, modulus: int) ivec3¶
Returns
vmodulomodulus.Some libraries (notably, pyGLM), define vector classes with a % operator that behaves differently than Python-s built-in integer modulo when negative numbers are involved. This function is a workaround for that: it always performs vector modulo in the same way as Python’s built-in modulo.
- perpendicular(vec: Vec2iLike) ivec2¶
Returns the vector perpendicular to
vecthat points to the right ofvecand has the same length.
- rotate2Ddeg(vec: Vec2iLike, degrees: int) ivec2¶
Returns
vec, rotated byrotationdegrees.degreesmust be a multiple of 90.
- rotate3Ddeg(vec: Vec3iLike, degrees: int) ivec3¶
Returns
vec, rotated in the XZ-plane byrotationdegrees.degreesmust be a multiple of 90.
- flipRotation2D(rotation: int, flip: Vec2bLike) int¶
Returns rotation such that applying rotation after
flipis equivalent to applyingflipafterrotation.
- flipRotation3D(rotation: int, flip: Vec3bLike) int¶
Returns rotation such that applying rotation after
flipis equivalent to applyingflipafterrotation
- rotateSize2D(size: Vec2iLike, rotation: int) ivec2¶
Returns the effective size of a rect of size
sizethat has been rotated in the XZ-plane byrotation.
- rotateSize3D(size: Vec3iLike, rotation: int) ivec3¶
Returns the effective size of a box of size
sizethat has been rotated in the XZ-plane byrotation.
- flipToScale2D(flip: Vec2bLike) ivec2¶
Returns a vector with a 1 where
flipisFalse, and -1 whereflipisTrue
- flipToScale3D(flip: Vec3bLike) ivec3¶
Returns a vector with a 1 where
flipisFalse, and -1 whereflipisTrue
- directionToRotation(direction: Vec2iLike) int¶
Returns the rotation that rotates (0,-1) closest to
direction
- distance(vecA: Vec2iLike | Vec3iLike, vecB: Vec2iLike | Vec3iLike) float¶
Returns the distance between
vecAandvecB
- distance2(vecA: Vec2iLike | Vec3iLike, vecB: Vec2iLike | Vec3iLike) int¶
Returns the squared distance between
vecAandvecB
- l1Distance(vecA: Vec2iLike | Vec3iLike, vecB: Vec2iLike | Vec3iLike) int¶
Returns the L1 norm distance between
vecAandvecB.vecAandvecBmust be bothVec2iLikeor bothVec3iLike.
- orderedCorners2D(corner1: Vec2iLike, corner2: Vec2iLike) tuple[ivec2, ivec2]¶
Returns two corners of the rectangle defined by
corner1andcorner2, such that the first corner is smaller than the second corner in each axis
- orderedCorners3D(corner1: Vec3iLike, corner2: Vec3iLike) tuple[ivec3, ivec3]¶
Returns two corners of the box defined by
corner1andcorner2, such that the first corner is smaller than the second corner in each axis
- getDimensionality(corner1: Vec2iLike | Vec3iLike, corner2: Vec2iLike | Vec3iLike) tuple[int, list[int]]¶
Determines the number of dimensions for which
corner1andcorner2are in general position, i.e. the number of dimensions for which the volume they define is not flat.Returns (dimensionality, list of indices of dimensions for which the volume is flat). For example:
(2, [0,2])means that the volume is flat in the x and z axes.
- class Rect¶
A rectangle, defined by an offset and a size
- property offset : ivec2¶
This Rect’s offset
- property size : ivec2¶
This Rect’s size
- property middle : ivec2¶
This Rect’s middle point, rounded down
- translated(translation: Vec2iLike | int) Rect¶
Returns a copy of this Rect, translated by
translation
- centeredSubRectOffset(size: Vec2iLike) ivec2¶
Returns an offset such that
Rect(offset, <size>).middle == self.middle
- centeredSubRect(size: Vec2iLike) Rect¶
Returns a rect of size
sizewith the same middle as this rect
- static between(cornerA: Vec2iLike, cornerB: Vec2iLike) Rect¶
Returns the Rect between
cornerAandcornerB(inclusive), which may be any opposing corners.
-
__match_args__ =
('_offset', '_size')¶
- class Box¶
A box, defined by an offset and a size
- property offset : ivec3¶
This Box’s offset
- property size : ivec3¶
This Box’s size
- property middle : ivec3¶
This Box’s middle point, rounded down
- property center : ivec3¶
Equivalent to
.middle
- centeredSubBoxOffset(size: Vec3iLike) ivec3¶
Returns an offset such that
Box(offset, size).middle == self.middle
- static between(cornerA: Vec3iLike, cornerB: Vec3iLike) Box¶
Returns the Box between
cornerAandcornerB(both inclusive), which may be any opposing corners
-
__match_args__ =
('_offset', '_size')¶
- rectSlice(array: ndarray[tuple[int, ...], dtype[Any]], rect: Rect) ndarray[tuple[int, ...], dtype[Any]]¶
Returns the slice from
arraydefined byrect
- setRectSlice(array: ndarray[tuple[int, ...], dtype[Any]], rect: Rect, value: Any) None¶
Sets the slice from
arraydefined byrecttovalue
- boxSlice(array: ndarray[tuple[int, ...], dtype[Any]], box: Box) ndarray[tuple[int, ...], dtype[Any]]¶
Returns the slice from
arraydefined bybox
- setBoxSlice(array: ndarray[tuple[int, ...], dtype[Any]], box: Box, value: Any) None¶
Sets the slice from
arraydefined byboxtovalue
-
loop2D(begin: Vec2iLike, end: Vec2iLike | None =
None) Generator[ivec2, None, None]¶ Yields all points between
beginandend(end-exclusive).If
endis not given, yields all points between (0,0) andbegin.
-
loop3D(begin: Vec3iLike, end: Vec3iLike | None =
None) Generator[ivec3, None, None]¶ Yields all points between
beginandend(end-exclusive).If
endis not given, yields all points between (0,0,0) andbegin.
- cuboid2D(corner1: Vec2iLike, corner2: Vec2iLike) Generator[ivec2, None, None]¶
Yields all points in the rectangle between
corner1andcorner2(inclusive).
- cuboid3D(corner1: Vec3iLike, corner2: Vec3iLike) Generator[ivec3, None, None]¶
Yields all points in the box between
corner1andcorner2(inclusive).
-
filled2DArray(points: Iterable[Vec2iLike], seedPoint: Vec2iLike, boundingRect: Rect | None =
None, includeInputPoints: bool =True) ndarray[tuple[int, ...], dtype[int64]]¶ Fills the shape defined by
points, starting atseedPointand returns a (n,2) numpy array containing the resulting points.boundingRectshould contain allpoints. If not provided, it is calculated.
-
filled2D(points: Iterable[Vec2iLike], seedPoint: Vec2iLike, boundingRect: Rect | None =
None, includeInputPoints: bool =True) Generator[ivec2, None, None]¶ Fills the shape defined by
points, starting atseedPointand yields the resulting points.boundingRectshould contain allpoints. If not provided, it is calculated.
-
filled3DArray(points: Iterable[Vec3iLike], seedPoint: Vec3iLike, boundingBox: Box | None =
None, includeInputPoints: bool =True) ndarray[tuple[int, ...], dtype[int64]]¶ Fills the shape defined by
points, starting atseedPointand returns a (n,3) numpy array containing the resulting points.boundingBoxshould contain allpoints. If not provided, it is calculated.
-
filled3D(points: Iterable[Vec3iLike], seedPoint: Vec3iLike, boundingBox: Box | None =
None, includeInputPoints: bool =True) Generator[ivec3, None, None]¶ Fills the shape defined by
points, starting atseedPointand yields the resulting points.boundingBoxshould contain allpoints. If not provided, it is calculated.
-
line2DArray(begin: Vec2iLike, end: Vec2iLike, width: int =
1) ndarray[tuple[int, ...], dtype[int64]]¶ Returns (n,2) numpy array of points on the line between
beginandend(inclusive)
-
line2D(begin: Vec2iLike, end: Vec2iLike, width: int =
1) Generator[ivec2, None, None]¶ Yields the points on the line between
beginandend(inclusive)
-
line3Darray(begin: Vec3iLike, end: Vec3iLike, width: int =
1) ndarray[tuple[int, ...], dtype[int64]]¶ Returns (n,3) numpy array of points on the line between
beginandend(inclusive)
-
line3D(begin: Vec3iLike, end: Vec3iLike, width: int =
1) Generator[ivec3, None, None]¶ Yields the points on the line between
beginandend(inclusive)
-
lineSequence2D(points: Iterable[Vec2iLike], closed: bool =
False) Generator[ivec2, None, None]¶ Yields all points on the lines that connect
points
-
lineSequence3D(points: Iterable[Vec3iLike], closed: bool =
False) Generator[ivec3, None, None]¶ Yields all points on the lines that connect
points
-
circle(center: Vec2iLike, diameter: int, filled: bool =
False) Generator[ivec2, None, None]¶ Yields the points of the specified circle.
If
diameteris even,centerwill be the bottom left center point.
-
fittingCircle(corner1: Vec2iLike, corner2: Vec2iLike, filled: bool =
False) Generator[ivec2, None, None]¶ Yields the points of the largest circle that fits between
corner1andcorner2.The circle will be centered in the larger axis.
-
ellipse(center: Vec2iLike, diameters: Vec2iLike, filled: bool =
False) Generator[ivec2, None, None]¶ Yields the points of the specified ellipse.
If
diameter[axis]is even,center[axis]will be the lower center point in that axis.
-
fittingEllipse(corner1: Vec2iLike, corner2: Vec2iLike, filled: bool =
False) Generator[ivec2, None, None]¶ Yields the points of the largest ellipse that fits between
corner1andcorner2.
-
cylinder(baseCenter: Vec3iLike, diameters: Vec2iLike | int, length: int, axis: int =
1, tube: bool =False, hollow: bool =False) Generator[ivec3, None, None]¶ Yields the points from the specified cylinder.
If a
diameteris even,centerwill be the lower center point in that axis.tubehas precedence overhollow.
-
fittingCylinder(corner1: Vec3iLike, corner2: Vec3iLike, axis: int =
1, tube: bool =False, hollow: bool =False) Generator[ivec3, None, None]¶ Yields the points of the largest cylinder that fits between
corner1andcorner2.tubehas precedence overhollow.
-
ellipsoid(center: Vec3iLike, diameters: Vec3iLike, hollow: bool =
False) Generator[ivec3, None, None]¶ Yields the points of an ellipsoid centered on
centerwith diametersdiameters.If
diameter[axis]is even,center[axis]will be the lower center point in that axis.
-
fittingEllipsoid(corner1: Vec3iLike, corner2: Vec3iLike, hollow: bool =
False) Generator[ivec3, None, None]¶ Yields the points of the largest ellipsoid that fits between
corner1andcorner2.
-
sphere(center: Vec3iLike, diameter: int, hollow: bool =
False) Generator[ivec3, None, None]¶ Yields the points of a sphere centered on
centerwith diameterdiameter.If
diameteris even,centerwill be the lower center point in every axis.
-
fittingSphere(corner1: Vec3iLike, corner2: Vec3iLike, hollow: bool =
False) Generator[ivec3, None, None]¶ Yields the points of the largest sphere that fits between
corner1andcorner2.The circle will be centered in the non-minimum axes.