Package mglutil :: Package math :: Module VectorModule :: Class Vector
[hide private]
[frames] | no frames]

Class Vector

source code

Vector in 3D space

Constructor:

- Vector(|x|, |y|, |z|)   (from three coordinates)
- Vector(|coordinates|)   (from any sequence containing three coordinates)

Vectors support the usual arithmetic operations
('v1', 'v2': vectors, 's': scalar): 

-  'v1+v2'           (addition)
-  'v1-v2'           (subtraction)
-  'v1*v2'           (scalar product)
-  's*v1', 'v1*s'    (multiplication with a scalar)
-  'v1/s'            (division by a scalar)

The three coordinates can be extracted by indexing.

Vectors are *immutable*, i.e. their elements cannot be changed.

Vector elements can be any objects on which the standard
arithmetic operations plus the functions sqrt and arccos are defined.



Instance Methods [hide private]
  __init__(self, x=None, y=None, z=None)
  __getstate__(self)
  __setstate__(self, state)
  __copy__(self, memo=None)
  __deepcopy__(self, memo=None)
  __repr__(self)
  __str__(self)
  __add__(self, other)
  __radd__(self, other)
  __neg__(self)
  __sub__(self, other)
  __rsub__(self, other)
  __mul__(self, other)
  __rmul__(self, other)
  __div__(self, other)
  __rdiv__(self, other)
  __cmp__(self, other)
  __len__(self)
  __getitem__(self, index)
  x(self)
Returns the x coordinate.
  y(self)
Returns the y coordinate.
  z(self)
Returns the z coordinate.
  length(self)
Returns the length (norm).
  normal(self)
Returns a normalized copy.
  cross(self, other)
Returns the cross product with vector |other|.
  asTensor(self)
Returns an equivalent tensor object of rank 1.
  dyadicProduct(self, other)
Returns the dyadic product with vector or tensor |other|.
  angle(self, other)
Returns the angle to vector |other|.

Class Variables [hide private]
  is_vector = 1

Method Details [hide private]

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

source code 
None

__getstate__(self)

source code 
None

__setstate__(self, state)

source code 
None

__copy__(self, memo=None)

source code 
None

__deepcopy__(self, memo=None)

source code 
None

__repr__(self)
(Representation operator)

source code 
None

__str__(self)
(Informal representation operator)

source code 
None

__add__(self, other)
(Addition operator)

source code 
None

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

source code 
None

__neg__(self)

source code 
None

__sub__(self, other)
(Subtraction operator)

source code 
None

__rsub__(self, other)

source code 
None

__mul__(self, other)

source code 
None

__rmul__(self, other)

source code 
None

__div__(self, other)

source code 
None

__rdiv__(self, other)

source code 
None

__cmp__(self, other)
(Comparison operator)

source code 
None

__len__(self)
(Length operator)

source code 
None

__getitem__(self, index)
(Indexing operator)

source code 
None

x(self)

source code 
Returns the x coordinate.

y(self)

source code 
Returns the y coordinate.

z(self)

source code 
Returns the z coordinate.

length(self)

source code 
Returns the length (norm).

normal(self)

source code 
Returns a normalized copy.

cross(self, other)

source code 
Returns the cross product with vector |other|.

asTensor(self)

source code 
Returns an equivalent tensor object of rank 1.

dyadicProduct(self, other)

source code 
Returns the dyadic product with vector or tensor |other|.

angle(self, other)

source code 
Returns the angle to vector |other|.

Class Variable Details [hide private]

is_vector

None
Value:
1