Uranium
Application Framework
 All Classes Namespaces Files Functions Variables Pages
UM.Math.Vector2.Vector2 Class Reference

Simple 2D-vector class based on numpy arrays. More...

Inherits object.

Public Member Functions

def __init__
 Creates a new 2D vector. More...
 
def cross
 Computes the generalised cross product of this vector with another. More...
 
def dot
 Computes the dot product of this vector and another. More...
 
def getData
 Gets the numpy array with the data. More...
 
def length
 Gets the Euclidean length of this vector. More...
 
def perpendicular
 Gets a vector that is perpendicular to this vector. More...
 
def setX
 Changes the x-component of this vector. More...
 
def setY
 Changes the y-component of this vector. More...
 
def x
 Gets the x-component of the vector. More...
 
def y
 Gets the y-component of the vector. More...
 
def __add__
 Adds the specified vector to this vector element-wise. More...
 
def __iadd__
 Adds the specified vector in-place to this vector element-wise. More...
 
def __truediv__
 Divides this vector by the specified vector element-wise. More...
 
def __itruediv__
 Divides this vector in-place by the specified vector element-wise. More...
 
def __rtruediv__
 Divides this vector by the specified vector element-wise. More...
 
def __mul__
 Multiplies the specified vector with this vector element-wise. More...
 
def __imul__
 Multiplies the specified vector in-place with this vector element-wise. More...
 
def __rmul__
 Multiplies the specified vector with this vector element-wise. More...
 
def __neg__
 Negates the vector, resulting in a vector with the opposite direction. More...
 
def __sub__
 Subtracts the specified vector from this vector element-wise. More...
 
def __isub__
 Subtracts the specified vector in-place from this vector element-wise. More...
 
def __str__
 Gives a programmer-readable string representation of this vector. More...
 

Static Public Attributes

 Unit_X = None
 
 Unit_Y = None
 

Detailed Description

Simple 2D-vector class based on numpy arrays.

This class represents a 2-dimensional vector.

Constructor & Destructor Documentation

def UM.Math.Vector2.Vector2.__init__ (   self,
  args,
  kwargs 
)

Creates a new 2D vector.

Usage:

  • Vector2(x,y): Creates a vector [x,y].
  • Vector2(data = [x,y]): Creates a vector [x,y].
  • Vector2(): Creates a vector [0,0].
Parameters
dataThe numpy array of data to fill the vector with.

Member Function Documentation

def UM.Math.Vector2.Vector2.__add__ (   self,
  other 
)

Adds the specified vector to this vector element-wise.

Parameters
otherThe vector that must be added to this vector.
Returns
The result of the adding.
def UM.Math.Vector2.Vector2.__iadd__ (   self,
  other 
)

Adds the specified vector in-place to this vector element-wise.

Parameters
otherThe vector that must be added to this vector.
def UM.Math.Vector2.Vector2.__imul__ (   self,
  other 
)

Multiplies the specified vector in-place with this vector element-wise.

Parameters
otherThe vector that must be multiplied with this vector.
def UM.Math.Vector2.Vector2.__isub__ (   self,
  other 
)

Subtracts the specified vector in-place from this vector element-wise.

Parameters
otherThe vector that must be subtracted from this vector.
def UM.Math.Vector2.Vector2.__itruediv__ (   self,
  other 
)

Divides this vector in-place by the specified vector element-wise.

Parameters
otherThe vector by which this vector must be divided.
def UM.Math.Vector2.Vector2.__mul__ (   self,
  other 
)

Multiplies the specified vector with this vector element-wise.

Parameters
otherThe vector that must be multiplied with this vector.
Returns
The result of the multiplication.
def UM.Math.Vector2.Vector2.__neg__ (   self)

Negates the vector, resulting in a vector with the opposite direction.

Returns
The negated vector.
def UM.Math.Vector2.Vector2.__rmul__ (   self,
  other 
)

Multiplies the specified vector with this vector element-wise.

Parameters
otherThe vector that must be multiplied with this vector.
def UM.Math.Vector2.Vector2.__rtruediv__ (   self,
  other 
)

Divides this vector by the specified vector element-wise.

Parameters
otherThe vector by which this vector must be divided.
Returns
The result of the division.
def UM.Math.Vector2.Vector2.__str__ (   self)

Gives a programmer-readable string representation of this vector.

The format is: [x,y]

Returns
A string representation of this vector.
def UM.Math.Vector2.Vector2.__sub__ (   self,
  other 
)

Subtracts the specified vector from this vector element-wise.

Parameters
otherThe vector that must be subtracted from this vector.
Returns
The result of the subtraction.
def UM.Math.Vector2.Vector2.__truediv__ (   self,
  other 
)

Divides this vector by the specified vector element-wise.

Parameters
otherThe vector by which this vector must be divided.
Returns
The result of the division.
def UM.Math.Vector2.Vector2.cross (   self,
  other 
)

Computes the generalised cross product of this vector with another.

Parameters
otherThe vector to compute the cross product with.
Returns
The generalised cross product.
def UM.Math.Vector2.Vector2.dot (   self,
  other 
)

Computes the dot product of this vector and another.

Parameters
otherThe vector to compute the dot product with.
Returns
The dot product of the two vectors.
def UM.Math.Vector2.Vector2.getData (   self)

Gets the numpy array with the data.

Returns
A numpy array with the data of this vector.
def UM.Math.Vector2.Vector2.length (   self)

Gets the Euclidean length of this vector.

Returns
The length of this vector.
def UM.Math.Vector2.Vector2.perpendicular (   self)

Gets a vector that is perpendicular to this vector.

There are exactly two vectors perpendicular. This method gets the perpendicular vector that is left of this vector.

Returns
A perpendicular vector.
def UM.Math.Vector2.Vector2.setX (   self,
  x 
)

Changes the x-component of this vector.

Parameters
xThe new x-component of the vector.
def UM.Math.Vector2.Vector2.setY (   self,
  y 
)

Changes the y-component of this vector.

Parameters
yThe new y-component of the vector.
def UM.Math.Vector2.Vector2.x (   self)

Gets the x-component of the vector.

Returns
The x-component of the vector.
def UM.Math.Vector2.Vector2.y (   self)

Gets the y-component of the vector.

Returns
The y-component of the vector.

The documentation for this class was generated from the following file: