Package gavo :: Package base :: Module coords :: Class Vector3
[frames] | no frames]

Class Vector3

source code

object --+
         |
        Vector3

is a 3d vector that responds to both .x... and [0]...

>>> x, y = Vector3(1,2,3), Vector3(2,3,4)
>>> x+y
Vector3(3.000000,5.000000,7.000000)
>>> 4*x
Vector3(4.000000,8.000000,12.000000)
>>> x*4
Vector3(4.000000,8.000000,12.000000)
>>> x*y
20
>>> "%.6f"%abs(x)
'3.741657'
>>> print(abs((x+y).normalized()))
1.0
Instance Methods
 
__init__(self, x, y=None, z=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code
 
__getitem__(self, index) source code
 
__mul__(self, other)
does either scalar multiplication if other is not a Vector3, or a scalar product.
source code
 
__rmul__(self, other)
does either scalar multiplication if other is not a Vector3, or a scalar product.
source code
 
__div__(self, scalar) source code
 
__add__(self, other) source code
 
__sub__(self, other) source code
 
__abs__(self) source code
 
cross(self, other) source code
 
normalized(self) source code
 
getx(self) source code
 
setx(self, x) source code
 
gety(self) source code
 
sety(self, y) source code
 
getz(self) source code
 
setz(self, z) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties
  x
  y
  z

Inherited from object: __class__

Method Details

__init__(self, x, y=None, z=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Property Details

x

Get Method:
getx(self)
Set Method:
setx(self, x)

y

Get Method:
gety(self)
Set Method:
sety(self, y)

z

Get Method:
getz(self)
Set Method:
setz(self, z)