Vector#

class Vector(x, y, z)[source]#

Bases: object

Represents a 3D vector with x, y, and z components.

This class defines a data type ‘Vector’ that represents a 3D vector with x, y, and z components, assuming the vector originates at the origin (0,0,0). Expands the numpy.array object.

Attributes:
xfloat

The x-component of the vector.

yfloat

The y-component of the vector.

zfloat

The z-component of the vector.

Methods

calculate_cross_product(b)

Calculate the cross product of two vectors.

calculate_projection(b)

Calculate the projection of this vector onto vector b.

magnitude()

Calculate the magnitude (length) of the vector.

scale(a)

Scale the vector by a scalar a.

Methods Summary

calculate_cross_product(b)

Calculate the cross product of two vectors.

calculate_projection(b)

Calculate the projection of this vector onto vector b.

magnitude()

Calculate the magnitude (length) of the vector.

scale(a)

Scale the vector by a scalar a.

Methods Documentation

calculate_cross_product(b)[source]#

Calculate the cross product of two vectors.

Calculates the cross product of two vectors, which is the unit vector that is perpendicular to both vectors.

Parameters:
bVector

The second vector to calculate the cross product with.

Returns:
Vector

The resulting vector from the cross product.

calculate_projection(b)[source]#

Calculate the projection of this vector onto vector b.

Parameters:
bVector

The vector to project onto.

Returns:
Vector

The resulting vector from the projection.

magnitude()[source]#

Calculate the magnitude (length) of the vector.

Returns:
float

The magnitude (length) of the vector.

scale(a)[source]#

Scale the vector by a scalar a.

Parameters:
afloat

The scalar to scale the vector by.

Returns:
Vector

The scaled vector.

__init__(x, y, z)[source]#

Initialize a Vector instance.

Parameters:
xfloat

The x-component of the vector.

yfloat

The y-component of the vector.

zfloat

The z-component of the vector.

calculate_cross_product(b)[source]#

Calculate the cross product of two vectors.

Calculates the cross product of two vectors, which is the unit vector that is perpendicular to both vectors.

Parameters:
bVector

The second vector to calculate the cross product with.

Returns:
Vector

The resulting vector from the cross product.

magnitude()[source]#

Calculate the magnitude (length) of the vector.

Returns:
float

The magnitude (length) of the vector.

calculate_projection(b)[source]#

Calculate the projection of this vector onto vector b.

Parameters:
bVector

The vector to project onto.

Returns:
Vector

The resulting vector from the projection.

scale(a)[source]#

Scale the vector by a scalar a.

Parameters:
afloat

The scalar to scale the vector by.

Returns:
Vector

The scaled vector.