class documentation

class Vector(vector.Vector):

Constructor: Vector(x, y, z)

View In Hierarchy

A simple 3D vector class.

Parameters
xThe x-coordinate of the vector. Defaults to 0.
yThe y-coordinate of the vector. Defaults to 0.
zThe z-coordinate of the vector. Defaults to 0.
Class Method from_val Ensure the value is a Vector, converting from a tuple if needed.
Method __add__ Add another vector or tuple to this vector.
Method __eq__ Check equality with another vector or tuple.
Method __init__ Initialize the vector coordinates.
Method __mul__ Scale this vector by a scalar value.
Method __setattr__ Route attribute assignment through the underlying setters.
Class Variable __slots__ Undocumented
Instance Variable x The x-coordinate of the vector.
Instance Variable y The y-coordinate of the vector.
Instance Variable z The z-coordinate of the vector.
@classmethod
def from_val(cls, value):

Ensure the value is a Vector, converting from a tuple if needed.

Parameters
value:tuple or VectorThe value to coerce into a Vector.
Returns
VectorThe coerced vector instance.
Raises
TypeErrorIf value is neither a tuple nor a Vector.
def __add__(self, other):

Add another vector or tuple to this vector.

Parameters
other:tuple or VectorThe vector (or tuple) to add.
Returns
VectorA new vector representing the sum.
def __eq__(self, other):

Check equality with another vector or tuple.

Parameters
other:tuple or VectorThe value to compare against.
Returns
boolTrue if all components are equal, False otherwise.
def __init__(self, x=0, y=0, z=0):

Initialize the vector coordinates.

Parameters
x:int or floatThe x-coordinate. Defaults to 0.
y:int or floatThe y-coordinate. Defaults to 0.
z:int or floatThe z-coordinate. Defaults to 0.
def __mul__(self, scalar):

Scale this vector by a scalar value.

Parameters
scalar:int or floatThe scalar to multiply each component by.
Returns
VectorA new scaled vector.
def __setattr__(self, name, value):

Route attribute assignment through the underlying setters.

Parameters
name:strThe attribute name being set ("x", "y", or "z").
value:int or floatThe new value for the attribute.
__slots__: tuple[str, ...] =

Undocumented

x: int or float =

The x-coordinate of the vector.

y: int or float =

The y-coordinate of the vector.

z: int or float =

The z-coordinate of the vector.