# maxon.Vec3¶

## Description¶

A vector consisting of three components X, Y and Z.

## Inheritance diagram¶

Inheritance

Parent Class:

Children Classes:

## Attributes¶

 `maxon.Vec3.STRIDE` `maxon.Vec3.x` (float) the x component `maxon.Vec3.y` (float) the y component `maxon.Vec3.z` (float) the z component

## Methods Signature¶

 Returns a vector that is clamped to the range [0.0 . Calculates the average value of ‘x’, ‘y’, ‘z’. Retrieves the length of the vector. Returns the maximum of ‘x’, ‘y’, ‘z’. Return the minimum of ‘x’, ‘y’, ‘z’. Retrieves the squared length of the vector. `IsEqual`(other[, epsilon]) Tests component-wise if the difference is no bigger than ‘epsilon’. Checks if each component is zero. Checks if each component are less or equal to v `MaxonConvert`([expected]) Converts the data to the expected type (built-in). 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 or z component of the vector. 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]) Initializes a new three component vector. `__isub__`(other) Subtracts another vector to the current vector. Iterates vector values in the next order: x, y, z. `__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. Returns the string representation of a Vector. `__setitem__`(index, value) Assigns a value to the x, y or z component of the vector. Returns the string representation of a data. `__sub__`(scalar) Subtracts another vector to the current vector.

## Methods Definition¶

`Vec3.``Clamp01`()

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

Returns

The vector clamped.

Return type

`maxon.Vec3`

`Vec3.``GetAverage`()

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

Returns

the average value.

Return type

float

`Vec3.``GetLength`()

Retrieves the length of the vector.

Returns

Vector length.

Return type

float

`Vec3.``GetMax`()

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

Returns

The maximum value.

Returns

float

`Vec3.``GetMin`()

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

Returns

The minimum value.

Returns

float

`Vec3.``GetSquaredLength`()

Retrieves the squared length of the vector.

Returns

Vector squared length.

Return type

float

`Vec3.``IsEqual`(other, epsilon=0.01)

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

Parameters
Returns

True if both color are identical.

Return type

bool

`Vec3.``IsZero`()

Checks if each component is zero.

Returns

True if all component is zero.

Return type

bool

`Vec3.``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

`Vec3.``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

`Vec3.``SetZero`()

Sets all components to zero.

`Vec3.``__add__`(scalar)

Adds another vector to the current vector.

Parameters

scalar (`maxon.Vec3`) – The other vector.

Return type

`maxon.Vec3`

Returns

The resulting vector.

`Vec3.``__div__`(scalar)

Divides each vector component by a scalar.

Parameters

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

Return type

`maxon.Vec3`

Returns

The resulting vector.

`Vec3.``__eq__`(other)

Checks if two vectors are equal.

Parameters

other (`maxon.Vec3`) – The other vector.

Return type

bool

Returns

True if vector are equal.

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

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

index (int) – The component index.

Raises

IndexError – When index does not satisfy 0 <= index < 2.

Return type

float

Returns

The vector component.

`Vec3.``__hash__`()

Returns the hash code of a vector.

`Vec3.``__iadd__`(other)

Adds another vector to the current vector.

Parameters

other (`maxon.Vec3`) – The other vector.

Return type

`maxon.Vec3`

Returns

The resulting vector.

`Vec3.``__idiv__`(scalar)

Divides each vector component by a scalar.

Parameters

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

Return type

`maxon.Vec3`

Returns

The resulting vector.

`Vec3.``__imul__`(scalar)

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

Parameters

scalar (float) – The other vector.

Return type

`maxon.Vec3`

Returns

The resulting vector.

`Vec3.``__init__`(x=None, y=None, z=None)
Initializes a new three component vector.

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

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

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 components. If this is a vector, this vector is copied.

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

• z (float) – The z component

`Vec3.``__isub__`(other)

Subtracts another vector to the current vector.

Parameters

other (`maxon.Vec3`) – The other vector.

Return type

`maxon.Vec3`

Returns

The resulting vector.

`Vec3.``__iter__`()

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

`Vec3.``__len__`()
`Vec3.``__maxon_convert__`(expected=None)
`Vec3.``__mul__`(scalar)

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

Parameters

scalar (float) – The other vector.

Return type

`maxon.Vec3`

Returns

The resulting vector.

`Vec3.``__ne__`(other)

Checks if two vectors are not equal.

Parameters

other (`maxon.Vec3`) – The other vector.

Return type

bool

Returns

True if both vector are not equal.

`Vec3.``__repr__`()

Returns the string representation of a Vector.

Return type

str

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

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

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

`Vec3.``__str__`()

Returns the string representation of a data.

Return type

str

`Vec3.``__sub__`(scalar)

Subtracts another vector to the current vector.

Parameters

scalar (`maxon.Vec3`) – The other vector.

Return type

`maxon.Vec3`

Returns

The resulting vector.