pyunity.values.vector module¶

class
pyunity.values.vector.
Vector2
(x_or_list=None, y=None)[source]¶ Bases:
pyunity.values.vector.Vector

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 Return type: 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 Return type: Vector2

normalize_return_length
()[source]¶ Normalize the vector and return its length before the normalization
Returns: The length before the normalization Return type: float

get_distance
(other)[source]¶ The distance between this vector and the other vector
Returns: The distance Return type: 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 Return type: 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:

dot
(other)[source]¶ Dot product of two vectors.
Parameters: other (Vector2) – Other vector Returns: Dot product of the two vectors Return type: float


class
pyunity.values.vector.
Vector3
(x_or_list=None, y=None, z=None)[source]¶ Bases:
pyunity.values.vector.Vector

copy
()[source]¶ Makes a copy of the Vector3
Returns: A shallow copy of the vector Return type: 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 Return type: 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 Return type: Vector3

normalize_return_length
()[source]¶ Normalize the vector and return its length before the normalization
Returns: The length before the normalization Return type: float

get_distance
(other)[source]¶ The distance between this vector and the other vector
Returns: The distance Return type: 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 Return type: 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:

dot
(other)[source]¶ Dot product of two vectors.
Parameters: other (Vector3) – Other vector Returns: Dot product of the two vectors Return type: float
