Package svs_simulation :: Package numdata :: Module vectors :: Class Vector2D
[show private | hide private]
[frames | no frames]

Class Vector2D

Point2D --+
          |
         Vector2D


Represents a vector in 2D space.
Method Summary
  __init__(self, x, y)
  __add__(self, rhs)
Overloads '+' operator.
  __cmp__(self, otherVector)
Overloads comparison operator.
  __div__(self, rhs)
Overloads '/' operator.
  __mul__(self, rhs)
Overloads '*' operator when vector is on left hand side of operator.
  __rmul__(self, lhs)
Overloads '*' operator when vector is on right hand side of operator.
  __str__(self)
Returns string representation of self.
  __sub__(self, rhs)
Overloads '-' operator.
  distance(self, otherVector)
Calculates the euclidean distance between two vectors.
  distanceSq(self, otherVector)
Calculates the euclidean distance squared between two vectors.
  dot(self, otherVector)
Calculates the dot product.
  getReverse(self)
Returns the vector that is the reverse of this vector.
  length(self)
Returns the length of a 2D vector.
  lengthSq(self)
Returns the squared length of a 2D vector.
  normalize(self)
Normalizes a 2D Vector.
  perp(self)
Returns a vector perpendicular to this vector.
  reflect(self, norm)
Given a normalized vector this method reflects the vector it is operating upon (like the path of a ball bouncing off a wall).
  sign(self, otherVector)
Returns positive if v2 is clockwise of this vector, minus if anticlockwise (Y axis pointing down, X axis to right).
  truncate(self, maxValue)
` Truncates a vector so that its length does not exceed maxValue.
  zero(self)
Resets vector to zero values.
    Inherited from Point2D
  decode(self, data)
Sets self to encoded values.
  encode(self)
Returns encoded description of self.
  setLocation(self, x, y)
  translate(self, xDelta, yDelta)

Method Details

__add__(self, rhs)
(Addition operator)

Overloads '+' operator.

__cmp__(self, otherVector)
(Comparison operator)

Overloads comparison operator.

__div__(self, rhs)

Overloads '/' operator.

__mul__(self, rhs)

Overloads '*' operator when vector is on left hand side of operator.

__rmul__(self, lhs)

Overloads '*' operator when vector is on right hand side of operator.

__str__(self)
(Informal representation operator)

Returns string representation of self.

__sub__(self, rhs)
(Subtraction operator)

Overloads '-' operator.

distance(self, otherVector)

Calculates the euclidean distance between two vectors.

distanceSq(self, otherVector)

Calculates the euclidean distance squared between two vectors.

dot(self, otherVector)

Calculates the dot product.

getReverse(self)

Returns the vector that is the reverse of this vector.

length(self)

Returns the length of a 2D vector.

lengthSq(self)

Returns the squared length of a 2D vector.

normalize(self)

Normalizes a 2D Vector.

perp(self)

Returns a vector perpendicular to this vector.

reflect(self, norm)

Given a normalized vector this method reflects the vector it is operating upon (like the path of a ball bouncing off a wall).

sign(self, otherVector)

Returns positive if v2 is clockwise of this vector, minus if anticlockwise (Y axis pointing down, X axis to right).

truncate(self, maxValue)

` Truncates a vector so that its length does not exceed maxValue.

zero(self)

Resets vector to zero values.

Generated by Epydoc 2.1 on Thu Oct 20 15:30:31 2005 http://epydoc.sf.net