Uranium
Application Framework
UM.Math.Vector2.Vector2 Class Reference

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

Inherits object.

Public Member Functions

def __init__ (self, *args, **kwargs)
 Creates a new 2D vector. More...
 
def cross (self, other)
 Computes the generalised cross product of this vector with another. More...
 
def dot (self, other)
 Computes the dot product of this vector and another. More...
 
def getData (self)
 Gets the numpy array with the data. More...
 
def length (self)
 Gets the Euclidean length of this vector. More...
 
def perpendicular (self)
 Gets a vector that is perpendicular to this vector. More...
 
def setX (self, x)
 Changes the x-component of this vector. More...
 
def setY (self, y)
 Changes the y-component of this vector. More...
 
def x (self)
 Gets the x-component of the vector. More...
 
def y (self)
 Gets the y-component of the vector. More...
 
def __add__ (self, other)
 Adds the specified vector to this vector element-wise. More...
 
def __iadd__ (self, other)
 Adds the specified vector in-place to this vector element-wise. More...
 
def __truediv__ (self, other)
 Divides this vector by the specified vector element-wise. More...
 
def __itruediv__ (self, other)
 Divides this vector in-place by the specified vector element-wise. More...
 
def __rtruediv__ (self, other)
 Divides this vector by the specified vector element-wise. More...
 
def __mul__ (self, other)
 Multiplies the specified vector with this vector element-wise. More...
 
def __imul__ (self, other)
 Multiplies the specified vector in-place with this vector element-wise. More...
 
def __rmul__ (self, other)
 Multiplies the specified vector with this vector element-wise. More...
 
def __neg__ (self)
 Negates the vector, resulting in a vector with the opposite direction. More...
 
def __sub__ (self, other)
 Subtracts the specified vector from this vector element-wise. More...
 
def __isub__ (self, other)
 Subtracts the specified vector in-place from this vector element-wise. More...
 
def __str__ (self)
 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

◆ __init__()

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

◆ __add__()

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.

◆ __iadd__()

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.

◆ __imul__()

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.

◆ __isub__()

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.

◆ __itruediv__()

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.

◆ __mul__()

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.

◆ __neg__()

def UM.Math.Vector2.Vector2.__neg__ (   self)

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

Returns
The negated vector.

◆ __rmul__()

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.

◆ __rtruediv__()

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.

◆ __str__()

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.

◆ __sub__()

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.

◆ __truediv__()

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.

◆ cross()

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.

◆ dot()

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.

◆ getData()

def UM.Math.Vector2.Vector2.getData (   self)

Gets the numpy array with the data.

Returns
A numpy array with the data of this vector.

◆ length()

def UM.Math.Vector2.Vector2.length (   self)

Gets the Euclidean length of this vector.

Returns
The length of this vector.

◆ perpendicular()

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.

◆ setX()

def UM.Math.Vector2.Vector2.setX (   self,
  x 
)

Changes the x-component of this vector.

Parameters
xThe new x-component of the vector.

◆ setY()

def UM.Math.Vector2.Vector2.setY (   self,
  y 
)

Changes the y-component of this vector.

Parameters
yThe new y-component of the vector.

◆ x()

def UM.Math.Vector2.Vector2.x (   self)

Gets the x-component of the vector.

Returns
The x-component of the vector.

◆ y()

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: