Package gameobjects :: Module vector3 :: Class Vector3
[hide private]
[frames] | no frames]

Class Vector3

source code


Instance Methods [hide private]
 
__init__(self, *args)
Creates a Vector3 from 3 numeric values or a list-like object containing at least 3 values.
source code
 
copy(self)
Returns a copy of this vector.
source code
 
__copy__(self)
Returns a copy of this vector.
source code
 
_get_x(self) source code
 
_set_x(self, x) source code
 
_get_y(self) source code
 
_set_y(self, y) source code
 
_get_z(self) source code
 
_set_z(self, z) source code
 
_get_length(self) source code
 
_set_length(self, length) source code
 
unit(self)
Returns a unit vector.
source code
 
set(self, x, y, z)
Sets the components of this vector.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
__len__(self) source code
 
__iter__(self)
Iterates the components in x, y, z order.
source code
 
__getitem__(self, index)
Retrieves a component, given its index.
source code
 
__setitem__(self, index, value)
Sets a component, given its index.
source code
 
__eq__(self, rhs)
Test for equality
source code
 
__ne__(self, rhs)
Test of inequality
source code
 
__hash__(self)
hash(x)
source code
 
__add__(self, rhs)
Returns the result of adding a vector (or collection of 3 numbers) from this vector.
source code
 
__iadd__(self, rhs)
Adds another vector (or a collection of 3 numbers) to this vector.
source code
 
__radd__(self, lhs)
Adds vector to this vector (right version)
source code
 
__sub__(self, rhs)
Returns the result of subtracting a vector (or collection of 3 numbers) from this vector.
source code
 
_isub__(self, rhs)
Subtracts another vector (or a collection of 3 numbers) from this vector.
source code
 
__rsub__(self, lhs)
Subtracts a vector (right version)
source code
 
scalar_mul(self, scalar) source code
 
vector_mul(self, vector) source code
 
get_scalar_mul(self, scalar) source code
 
get_vector_mul(self, vector) source code
 
__mul__(self, rhs)
Return the result of multiplying this vector by another vector, or a scalar (single number).
source code
 
__imul__(self, rhs)
Multiply this vector by another vector, or a scalar (single number).
source code
 
__rmul__(self, lhs) source code
 
__div__(self, rhs)
Return the result of dividing this vector by another vector, or a scalar (single number).
source code
 
__idiv__(self, rhs)
Divide this vector by another vector, or a scalar (single number).
source code
 
__rdiv__(self, lhs) source code
 
scalar_div(self, scalar) source code
 
vector_div(self, vector) source code
 
get_scalar_div(self, scalar) source code
 
get_vector_div(self, vector) source code
 
__neg__(self)
Returns the negation of this vector (a vector pointing in the opposite direction.
source code
 
__pos__(self) source code
 
__nonzero__(self) source code
 
__call__(self, keys)
Returns a tuple of the values in a vector
source code
 
as_tuple(self)
Returns a tuple of the x, y, z components.
source code
 
scale(self, scale)
Scales the vector by onther vector or a scalar.
source code
 
get_length(self)
Calculates the length of the vector.
source code
 
get_magnitude(self)
Calculates the length of the vector.
source code
 
set_length(self, new_length)
Sets the length of the vector.
source code
 
get_distance_to(self, p)
Returns the distance of this vector to a point.
source code
 
get_distance_to_squared(self, p)
Returns the squared distance of this vector to a point.
source code
 
normalise(self)
Scales the vector to be length 1.
source code
 
normalize(self)
Scales the vector to be length 1.
source code
 
get_normalised(self) source code
 
get_normalized(self) source code
 
in_sphere(self, sphere)
Returns true if this vector (treated as a position) is contained in the given sphere.
source code
 
dot(self, other)
Returns the dot product of this vector with another.
source code
 
cross(self, other)
Returns the cross product of this vector with another.
source code
 
cross_tuple(self, other)
Returns the cross product of this vector with another, as a tuple.
source code

Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Methods [hide private]
 
from_points(cls, p1, p2) source code
 
from_floats(cls, x, y, z)
Creates a Vector3 from individual float values.
source code
 
from_iter(cls, iterable)
Creates a Vector3 from an iterable containing at least 3 values.
source code
 
_from_float_sequence(cls, sequence) source code
Class Variables [hide private]
  _gameobjects_vector = 3
Properties [hide private]
  x
x component.
  y
y component.
  z
z component.
  length
Length of the vector
  _v

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args)
(Constructor)

source code 
Creates a Vector3 from 3 numeric values or a list-like object containing at least 3 values. No arguments result in a null vector.
Overrides: object.__init__

from_floats(cls, x, y, z)
Class Method

source code 
Creates a Vector3 from individual float values. Warning: There is no checking (for efficiency) here: x, y, z _must_ be floats.

set(self, x, y, z)

source code 
Sets the components of this vector. x -- x component y -- y component z -- z component

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

__getitem__(self, index)
(Indexing operator)

source code 

Retrieves a component, given its index.

index -- 0, 1 or 2 for x, y or z

__setitem__(self, index, value)
(Index assignment operator)

source code 

Sets a component, given its index.

index -- 0, 1 or 2 for x, y or z value -- New (float) value of component

__eq__(self, rhs)
(Equality operator)

source code 

Test for equality

rhs -- Vector or sequence of 3 values

__ne__(self, rhs)

source code 

Test of inequality

rhs -- Vector or sequenece of 3 values

__hash__(self)
(Hashing function)

source code 
hash(x)
Overrides: object.__hash__
(inherited documentation)

__add__(self, rhs)
(Addition operator)

source code 

Returns the result of adding a vector (or collection of 3 numbers) from this vector.

rhs -- Vector or sequence of 2 values

__iadd__(self, rhs)

source code 

Adds another vector (or a collection of 3 numbers) to this vector.

rhs -- Vector or sequence of 2 values

__radd__(self, lhs)
(Right-side addition operator)

source code 

Adds vector to this vector (right version)

lhs -- Left hand side vector or sequence

__sub__(self, rhs)
(Subtraction operator)

source code 

Returns the result of subtracting a vector (or collection of 3 numbers) from this vector.

rhs -- 3 values

_isub__(self, rhs)

source code 

Subtracts another vector (or a collection of 3 numbers) from this vector.

rhs -- Vector or sequence of 3 values

__rsub__(self, lhs)

source code 

Subtracts a vector (right version)

lhs -- Left hand side vector or sequence

__mul__(self, rhs)

source code 

Return the result of multiplying this vector by another vector, or a scalar (single number).

rhs -- Vector, sequence or single value.

__imul__(self, rhs)

source code 

Multiply this vector by another vector, or a scalar (single number).

rhs -- Vector, sequence or single value.

__neg__(self)

source code 
Returns the negation of this vector (a vector pointing in the opposite direction. eg v1 = Vector(1,2,3) print -v1 >>> (-1,-2,-3)

__call__(self, keys)
(Call operator)

source code 

Returns a tuple of the values in a vector

keys -- An iterable containing the keys (x, y or z) eg v = Vector3(1.0, 2.0, 3.0) v('zyx') -> (3.0, 2.0, 1.0)

as_tuple(self)

source code 
Returns a tuple of the x, y, z components. A little quicker than tuple(vector).

scale(self, scale)

source code 

Scales the vector by onther vector or a scalar. Same as the *= operator.

scale -- Value to scale the vector by

set_length(self, new_length)

source code 

Sets the length of the vector. (Normalises it then scales it)

new_length -- The new length of the vector.

get_distance_to(self, p)

source code 

Returns the distance of this vector to a point.

p -- A position as a vector, or collection of 3 values.

get_distance_to_squared(self, p)

source code 

Returns the squared distance of this vector to a point.

p -- A position as a vector, or collection of 3 values.

dot(self, other)

source code 

Returns the dot product of this vector with another.

other -- A vector or tuple

cross(self, other)

source code 

Returns the cross product of this vector with another.

other -- A vector or tuple

cross_tuple(self, other)

source code 

Returns the cross product of this vector with another, as a tuple. This avoids the Vector3 construction if you don't need it.

other -- A vector or tuple

Property Details [hide private]

x

x component.
Get Method:
gameobjects.vector3.Vector3._get_x(self)
Set Method:
gameobjects.vector3.Vector3._set_x(self, x)

y

y component.
Get Method:
gameobjects.vector3.Vector3._get_y(self)
Set Method:
gameobjects.vector3.Vector3._set_y(self, y)

z

z component.
Get Method:
gameobjects.vector3.Vector3._get_z(self)
Set Method:
gameobjects.vector3.Vector3._set_z(self, z)

length

Length of the vector
Get Method:
gameobjects.vector3.Vector3._get_length(self)
Set Method:
gameobjects.vector3.Vector3._set_length(self, length)