Skip to content

XYZ (3D) Vectors

FloatVector3

FloatVector3(x: float, y: float, z: float)

Bases: BaseVector3

3D Float Vector Array.

Create a new 3D, float-based vector array.

PARAMETER DESCRIPTION
x

Coordinate on the X-axis.

TYPE: float

y

Coordinate on the Y-axis.

TYPE: float

z

Coordinate on the Z-axis.

TYPE: float

x property writable

x: float

Coordinate on the X-axis.

y property writable

y: float

Coordinate on the Y-axis.

z property writable

z: float

Coordinate on the Z-axis.

copy

copy() -> FloatVector3

Copy this vector into another instance of the same vector.

RETURNS DESCRIPTION
FloatVector3

This vector as another instance.

cross

cross(other: FloatVector3) -> FloatVector3

Calculate the cross product of this vector with another.

PARAMETER DESCRIPTION
other

The other vector cross with.

TYPE: FloatVector3

RETURNS DESCRIPTION
FloatVector3

The resulting cross product vector.

dot

dot(other: FloatVector3) -> float

Calculate the dot product of this vector with another.

PARAMETER DESCRIPTION
other

The other vector to calculate the dot product with.

TYPE: FloatVector3

RETURNS DESCRIPTION
float

The dot product of these two vectors.

from_iterable classmethod

Create a new 3D, float-based vector array from an iterable with 3 float or int values.

PARAMETER DESCRIPTION
iterable

The iterable with 3 float or int values.

TYPE: FloatVector3 | IntVector3 | numpy.ndarray[numpy.int32] | tuple[int | float, int | float, int | float] | list[int | float]

RETURNS DESCRIPTION
FloatVector3

The new 3D, float-based vector array.

RAISES DESCRIPTION
ValueError

If the provided iterable contains more or less than 3 values

normalize

normalize() -> FloatVector3

Normalize this vector.

RETURNS DESCRIPTION
FloatVector3

The normalized vector.

RAISES DESCRIPTION
ZeroDivisionError

If the magnitude of this vector is 0

to_numpy

to_numpy(copy: bool = True) -> NDArray[np.float32]

Return this vector as an instance of a NumPy array.

PARAMETER DESCRIPTION
copy

If this method should return a copy of the internal NumPy array or the array itself

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
numpy.ndarray[numpy.float32]

This vector as an instance of a NumPy array.

Warning

If you return the array itself, any changes to that array will change this vector object.

to_tuple

to_tuple() -> tuple[float, float, float]

Return this vector as a tuple.

RETURNS DESCRIPTION
tuple[float, float, float]

This vector as a tuple.

magnitude

magnitude() -> float

Calculate the magnitude of this vector.

RETURNS DESCRIPTION
float

The magnitude of this vector.

IntVector3

IntVector3(x: int, y: int, z: int)

Bases: BaseVector3

3D Integer Vector Array.

Create a new 3D, int-based vector array.

PARAMETER DESCRIPTION
x

Coordinate on the X-axis.

TYPE: int

y

Coordinate on the Y-axis.

TYPE: int

z

Coordinate on the Z-axis.

TYPE: int

x property writable

x: int

Coordinate on the X-axis.

y property writable

y: int

Coordinate on the Y-axis.

z property writable

z: int

Coordinate on the Z-axis.

copy

copy() -> IntVector3

Copy this vector into another instance of the same vector.

RETURNS DESCRIPTION
IntVector3

This vector as another instance.

cross

cross(other: IntVector3) -> IntVector3

Calculate the cross product of this vector with another.

PARAMETER DESCRIPTION
other

The other vector cross with.

TYPE: IntVector3

RETURNS DESCRIPTION
IntVector3

The resulting cross product vector.

dot

dot(other: IntVector3) -> float

Calculate the dot product of this vector with another.

PARAMETER DESCRIPTION
other

The other vector to calculate the dot product with.

TYPE: IntVector3

RETURNS DESCRIPTION
float

The dot product of these two vectors.

from_iterable classmethod

from_iterable(
    iterable: Union[
        IntVector3,
        np.ndarray[np.int32],
        tuple[int, int, int],
        list[int],
    ],
) -> IntVector3

Create a new 3D, int-based vector array from an iterable with 3 int values.

PARAMETER DESCRIPTION
iterable

The iterable with 3 int values.

TYPE: IntVector3 | numpy.ndarray[numpy.int32] | tuple[int, int, int] | list[int]

RETURNS DESCRIPTION
IntVector3

The new 3D, int-based vector array.

RAISES DESCRIPTION
ValueError

If the provided iterable contains more or less than 3 values

normalize

normalize() -> FloatVector3

Normalize this vector.

RETURNS DESCRIPTION
FloatVector3

The normalized vector.

RAISES DESCRIPTION
ZeroDivisionError

If the magnitude of this vector is 0

to_numpy

to_numpy(copy: bool = True) -> NDArray[np.int32]

Return this vector as an instance of a NumPy array.

PARAMETER DESCRIPTION
copy

If this method should return a copy of the internal NumPy array or the array itself

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
numpy.ndarray[numpy.int32]

This vector as an instance of a NumPy array.

Warning

If you return the array itself, any changes to that array will change this vector object.

to_tuple

to_tuple() -> tuple[int, int, int]

Return this vector as a tuple.

RETURNS DESCRIPTION
tuple[int, int, int]

This vector as a tuple.

magnitude

magnitude() -> float

Calculate the magnitude of this vector.

RETURNS DESCRIPTION
float

The magnitude of this vector.