pyunity.vector3 module

A class to store x, y and z values, with a lot of utility functions.

class pyunity.vector3.Vector3(x_or_list=None, y=None, z=None)

Bases: object

static back()

Vector3 pointing in the negative z axis

clamp(min, max)

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
copy()

Makes a copy of the Vector3

Returns

A shallow copy of the vector

Return type

Vector3

cross(other)

Cross product of two vectors

Parameters

other (Vector3) – Other vector

Returns

Cross product of the two vectors

Return type

Vector3

dot(other)

Dot product of two vectors.

Parameters

other (Vector3) – Other vector

Returns

Dot product of the two vectors

Return type

float

static down()

Vector3 pointing in the negative y axis

static forward()

Vector3 pointing in the positive z axis

get_dist_sqrd(other)

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

Return type

float

get_distance(other)

The distance between this vector and the other vector

Returns

The distance

Return type

float

get_length_sqrd()

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 int_tuple

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

static left()

Vector3 pointing in the negative x axis

property length

Gets or sets the magnitude of the vector

normalize_return_length()

Normalize the vector and return its length before the normalization

Returns

The length before the normalization

Return type

float

normalized()

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

Returns

A normalized vector

Return type

Vector3

static one()

A vector of ones

static right()

Vector3 pointing in the postive x axis

property rounded

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

static up()

Vector3 pointing in the postive y axis

static zero()

A vector of zero length

pyunity.vector3.clamp()