maxon.Vec4

Description

General maxon.Data class.
An object of this class can store every type of data as long as that type has been registered (see maxon.DataType).

Inheritance diagram

Inheritance

Parent Class:

Children Classes:

Attributes

maxon.Vec4.STRIDE

maxon.Vec4.w

(float) the w component

maxon.Vec4.x

(float) the x component

maxon.Vec4.y

(float) the y component

maxon.Vec4.z

(float) the z component

Methods Signature

Clamp01()

Returns a vector that is clamped to the range [0.0 .

GetAverage()

Calculates the average value of ‘x’, ‘y’, ‘z’ and ‘w’.

GetLength()

Retrieves the length of the vector.

GetMax()

Returns the maximum of ‘x’, ‘y’, ‘z’ and ‘w’.

GetMin()

Return the minimum of ‘x’, ‘y’, ‘z’ and ‘w’.

GetSquaredLength()

Retrieves the squared length of the vector.

IsEqual(other[, epsilon])

Tests component-wise if the difference is no bigger than ‘epsilon’.

IsZero()

Checks if each component is zero.

LessThanOrEqual(v)

Checks if each component are less or equal to v

MaxonConvert([expected])

Converts the data to the expected type (built-in).

SetZero()

Sets all components to zero.

__add__(scalar)

Adds another vector to the current vector.

__div__(scalar)

Divides each vector component by a scalar.

__eq__(other)

Checks if two vectors are equal.

__getitem__(index)

Retrieves the value of the x, y, z or w component of the vector.

__hash__()

Returns the hash code of a vector.

__iadd__(other)

Adds another vector to the current vector.

__idiv__(scalar)

Divides each vector component by a scalar.

__imul__(scalar)

Multiplies each vector components by the scalar and returns the vector result.

__init__([x, y, z, w])

Initializes a new four component vector.

__isub__(other)

Subtracts another vector to the current vector.

__iter__()

Iterates vector values in the next order: x, y, z, w.

__len__()

__maxon_convert__([expected])

__mul__(scalar)

Multiplies each vector components by the scalar and returns the vector result.

__ne__(other)

Checks if two vectors are not equal.

__repr__()

Returns the string representation of a Vector.

__setitem__(index, value)

Assigns a value to the x, y or z w component of the vector.

__str__()

Returns the string representation of a data.

__sub__(scalar)

Subtracts another vector to the current vector.

Methods Definition

Vec4.Clamp01()

Returns a vector that is clamped to the range [0.0 .. 1.0].

Returns

The vector clamped.

Return type

maxon.Vec4

Vec4.GetAverage()

Calculates the average value of ‘x’, ‘y’, ‘z’ and ‘w’.

Returns

the average value.

Return type

float

Vec4.GetLength()

Retrieves the length of the vector.

Returns

Vector length.

Return type

float

Vec4.GetMax()

Returns the maximum of ‘x’, ‘y’, ‘z’ and ‘w’.

Returns

The maximum value.

Returns

float

Vec4.GetMin()

Return the minimum of ‘x’, ‘y’, ‘z’ and ‘w’.

Returns

The minimum value.

Returns

float

Vec4.GetSquaredLength()

Retrieves the squared length of the vector.

Returns

Vector squared length.

Return type

float

Vec4.IsEqual(other, epsilon=0.01)

Tests component-wise if the difference is no bigger than ‘epsilon’.

Parameters
  • other (maxon.Vec3) – The other color to compare with.

  • epsilon (float) – The tolerance value.

Returns

True if both color are identical.

Return type

bool

Vec4.IsZero()

Checks if each component is zero.

Returns

True if all component is zero.

Return type

bool

Vec4.LessThanOrEqual(v)

Checks if each component are less or equal to v

Parameters

v – The maximum value to checks for.

Returns

True if all components are less or equals to the passed value.

Return type

bool

Vec4.MaxonConvert(expected=None)

Converts the data to the expected type (built-in).

Parameters

expected (Any) – The expected type after the conversion.

Returns

The data converted.

Return type

Same as expected

Vec4.SetZero()

Sets all components to zero.

Vec4.__add__(scalar)

Adds another vector to the current vector.

Parameters

scalar (maxon.Vec4) – The other vector.

Vec4.__div__(scalar)

Divides each vector component by a scalar.

Parameters

scalar (Union[int, float]) – The other operand.

Return type

maxon.Vec4

Returns

The resulting vector.

Vec4.__eq__(other)

Checks if two vectors are equal.

Parameters

other (maxon.Vec4) – The other vector.

Return type

bool

Returns

True if both vectors are equal.

Vec4.__getitem__(index)
Retrieves the value of the x, y, z or w component of the vector.

The component is identified by an index in the interval [0, 3].
Parameters

index (int) – The component index.

Raises

IndexError – When key does not satisfy 0 <= key < 3.

Return type

float

Returns

The vector component.

Vec4.__hash__()

Returns the hash code of a vector.

Vec4.__iadd__(other)

Adds another vector to the current vector.

Parameters

other (maxon.Vec4) – The other vector.

Vec4.__idiv__(scalar)

Divides each vector component by a scalar.

Parameters

scalar (Union[int, float]) – The other operand.

Return type

maxon.Vec4

Returns

The resulting vector.

Vec4.__imul__(scalar)

Multiplies each vector components by the scalar and returns the vector result.

Parameters

scalar (float) – The other vector.

Return type

maxon.Vec4

Returns

The resulting vector.

Vec4.__init__(x=None, y=None, z=None, w=None)
Initializes a new four component vector.

It is possible to instantiate a new vector without any arguments, causing the x, y, z, w
components to default to the value 0. The type can otherwise be instantiated with one or
four arguments, either setting all components to the same value or copying another
maxon.Vec4 instance, or setting all three components individually.
..note:

This type should not be instantiated directly, use instead the type maxon.Vector4d.

Parameters
  • x (Optional[maxon.Vec4, float]) – If x is the only passed argument. If this is a float set this value to X/Y/Z/W components. If this is a vector, this vector is copied.

  • y (float) – The z component. Can only be passed if z and w are also defined.

  • z (float) – The z component. Can only be passed if w is also defined.

  • w (float) – The w component.

Vec4.__isub__(other)

Subtracts another vector to the current vector.

Parameters

other (maxon.Vec4) – The other vector.

Return type

maxon.Vec4

Returns

The resulting vector.

Vec4.__iter__()

Iterates vector values in the next order: x, y, z, w.

Vec4.__len__()
Vec4.__maxon_convert__(expected=None)
Vec4.__mul__(scalar)

Multiplies each vector components by the scalar and returns the vector result.

Parameters

scalar (float) – The other vector.

Return type

maxon.Vec4

Returns

The resulting vector.

Vec4.__ne__(other)

Checks if two vectors are not equal.

Parameters

other (maxon.Vec4) – The other vector.

Return type

bool

Returns

True if both vectors are not equal.

Vec4.__repr__()

Returns the string representation of a Vector.

Return type

str

Vec4.__setitem__(index, value)
Assigns a value to the x, y or z w component of the vector.

The component is identified by an index in the interval [0, 3].
Parameters
  • index (int) – The index to which the value should be assigned.

  • value (float) – The value to assign for the given index.

Vec4.__str__()

Returns the string representation of a data.

Return type

str

Vec4.__sub__(scalar)

Subtracts another vector to the current vector.

Parameters

scalar (maxon.Vec4) – The other vector.

Return type

maxon.Vec4

Returns

The resulting vector.