Attention

You are viewing PyUnity docs under the develop branch. As such, they are only applicable if you installed from source. Go to https://docs.pyunity.x10.bz/en/latest/ for the most recent release.

pyunity.values.vector module


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

Clamp a value between a minimum and a maximum

pyunity.values.vector.conv(num)[source]

Convert float to string and removing decimal place as necessary.

class pyunity.values.vector.Vector[source]

Bases: LockedLiteral

abs()[source]
length()[source]
property intTuple

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

replace(num, value)[source]
class pyunity.values.vector.Vector2[source]

Bases: Vector

replace(num, value)[source]
copy()[source]

Makes a copy of the Vector2

getLengthSqrd()[source]

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

Returns:

The length of the vector squared

Return type:

float

property length

Gets 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

Return type:

Vector2

getDistance(other)[source]

The distance between this vector and the other vector

Returns:

The distance

Return type:

float

getDistSqrd(other)[source]

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

Returns:

The squared distance

Return type:

float

clamp(min, max)[source]

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

Parameters:
Returns:

A vector inside or on the surface of the bounding box specified by min and max.

Return type:

Vector3

dot(other)[source]

Dot product of two vectors.

Parameters:

other (Vector2) – Other vector

Returns:

Dot product of the two vectors

Return type:

float

cross(other)[source]

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

Parameters:

other (Vector2) – Other vector

Returns:

Cross product of the two vectors

Return type:

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[source]

Bases: Vector

replace(num, value)[source]
copy()[source]

Makes a copy of the Vector3

Returns:

A shallow copy of the vector

Return type:

Vector3

getLengthSqrd()[source]

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

Returns:

The length of the vector squared

Return type:

float

property length

Gets 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

Return type:

Vector3

getDistance(other)[source]

The distance between this vector and the other vector

Returns:

The distance

Return type:

float

getDistSqrd(other)[source]

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

Returns:

The squared distance

Return type:

float

clamp(min, max)[source]

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

Parameters:
Returns:

A vector inside or on the surface of the bounding box specified by min and max.

Return type:

Vector3

dot(other)[source]

Dot product of two vectors.

Parameters:

other (Vector3) – Other vector

Returns:

Dot product of the two vectors

Return type:

float

cross(other)[source]

Cross product of two vectors

Parameters:

other (Vector3) – Other vector

Returns:

Cross product of the two vectors

Return type:

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