# pyunity.values.vector module¶

`pyunity.values.vector.``clamp`(x, _min, _max)[source]
class `pyunity.values.vector.``Vector`[source]

Bases: `object`

`abs`()[source]
`length`()[source]
class `pyunity.values.vector.``Vector2`(x_or_list=None, y=None)[source]
`copy`()[source]

Makes a copy of the Vector2

`get_length_sqrd`()[source]

Gets the length of the vector squared. This is much faster than finding the length.

Returns: The length of the vector squared float
`length`

Gets or sets the magnitude of the vector

`normalized`()[source]

Get a normalized copy of the vector, or Vector2(0, 0) if the length is 0.

Returns: A normalized vector Vector2
`normalize`()[source]

Normalize the vector in place.

`normalize_return_length`()[source]

Normalize the vector and return its length before the normalization

Returns: The length before the normalization float
`get_distance`(other)[source]

The distance between this vector and the other vector

Returns: The distance float
`get_dist_sqrd`(other)[source]

The distance between this vector and the other vector, squared. It is more efficient to call this than to call get_distance and square it.

Returns: The squared distance float
`int_tuple`

Return the x, y and z values of this vector as ints

`rounded`

Return the x, y and z values of this vector rounded to the nearest integer

`clamp`(min, max)[source]

Clamps a vector between two other vectors, resulting in the vector being as close to the edge of a bounding box created as possible.

Parameters: min (Vector2) – Min vector max (Vector2) – Max vector
`dot`(other)[source]

Dot product of two vectors.

Parameters: other (Vector2) – Other vector Dot product of the two vectors float
`cross`(other)[source]

Cross product of two vectors. In 2D this is a scalar.

Parameters: other (Vector2) – Other vector Cross product of the two vectors float
static `min`(a, b)[source]
static `max`(a, b)[source]
static `zero`()[source]

A vector of zero length

static `one`()[source]

A vector of ones

static `left`()[source]

Vector2 pointing in the negative x axis

static `right`()[source]

Vector2 pointing in the postive x axis

static `up`()[source]

Vector2 pointing in the postive y axis

static `down`()[source]

Vector2 pointing in the negative y axis

class `pyunity.values.vector.``Vector3`(x_or_list=None, y=None, z=None)[source]
`copy`()[source]

Makes a copy of the Vector3

Returns: A shallow copy of the vector Vector3
`get_length_sqrd`()[source]

Gets the length of the vector squared. This is much faster than finding the length.

Returns: The length of the vector squared float
`length`

Gets or sets the magnitude of the vector

`normalized`()[source]

Get a normalized copy of the vector, or Vector3(0, 0, 0) if the length is 0.

Returns: A normalized vector Vector3
`normalize`()[source]

Normalize the vector in place.

`normalize_return_length`()[source]

Normalize the vector and return its length before the normalization

Returns: The length before the normalization float
`get_distance`(other)[source]

The distance between this vector and the other vector

Returns: The distance float
`get_dist_sqrd`(other)[source]

The distance between this vector and the other vector, squared. It is more efficient to call this than to call get_distance and square it.

Returns: The squared distance float
`int_tuple`

Return the x, y and z values of this vector as ints

`rounded`

Return the x, y and z values of this vector rounded to the nearest integer

`clamp`(min, max)[source]

Clamps a vector between two other vectors, resulting in the vector being as close to the edge of a bounding box created as possible.

Parameters: min (Vector3) – Min vector max (Vector3) – Max vector
`dot`(other)[source]

Dot product of two vectors.

Parameters: other (Vector3) – Other vector Dot product of the two vectors float
`cross`(other)[source]

Cross product of two vectors

Parameters: other (Vector3) – Other vector Cross product of the two vectors Vector3
static `min`(a, b)[source]
static `max`(a, b)[source]
static `zero`()[source]

A vector of zero length

static `one`()[source]

A vector of ones

static `forward`()[source]

Vector3 pointing in the positive z axis

static `back`()[source]

Vector3 pointing in the negative z axis

static `left`()[source]

Vector3 pointing in the negative x axis

static `right`()[source]

Vector3 pointing in the postive x axis

static `up`()[source]

Vector3 pointing in the postive y axis

static `down`()[source]

Vector3 pointing in the negative y axis