Simple 2D-vector class based on numpy arrays.
More...
Inherits object.
|
| __init__ (self, *args, **kwargs) |
| Creates a new 2D vector.
|
|
| cross (self, other) |
| Computes the generalised cross product of this vector with another.
|
|
| dot (self, other) |
| Computes the dot product of this vector and another.
|
|
| getData (self) |
| Gets the numpy array with the data.
|
|
| length (self) |
| Gets the Euclidean length of this vector.
|
|
| perpendicular (self) |
| Gets a vector that is perpendicular to this vector.
|
|
| setX (self, x) |
| Changes the x-component of this vector.
|
|
| setY (self, y) |
| Changes the y-component of this vector.
|
|
| x (self) |
| Gets the x-component of the vector.
|
|
| y (self) |
| Gets the y-component of the vector.
|
|
| __add__ (self, other) |
| Adds the specified vector to this vector element-wise.
|
|
| __iadd__ (self, other) |
| Adds the specified vector in-place to this vector element-wise.
|
|
| __truediv__ (self, other) |
| Divides this vector by the specified vector element-wise.
|
|
| __itruediv__ (self, other) |
| Divides this vector in-place by the specified vector element-wise.
|
|
| __rtruediv__ (self, other) |
| Divides this vector by the specified vector element-wise.
|
|
| __mul__ (self, other) |
| Multiplies the specified vector with this vector element-wise.
|
|
| __imul__ (self, other) |
| Multiplies the specified vector in-place with this vector element-wise.
|
|
| __rmul__ (self, other) |
| Multiplies the specified vector with this vector element-wise.
|
|
| __neg__ (self) |
| Negates the vector, resulting in a vector with the opposite direction.
|
|
| __sub__ (self, other) |
| Subtracts the specified vector from this vector element-wise.
|
|
| __isub__ (self, other) |
| Subtracts the specified vector in-place from this vector element-wise.
|
|
| __str__ (self) |
| Gives a programmer-readable string representation of this vector.
|
|
|
| Unit_X = None |
|
| Unit_Y = None |
|
Simple 2D-vector class based on numpy arrays.
This class represents a 2-dimensional vector.
◆ __init__()
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
-
data | The numpy array of data to fill the vector with. |
◆ __add__()
UM.Math.Vector2.Vector2.__add__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Adds the specified vector to this vector element-wise.
- Parameters
-
other | The vector that must be added to this vector. |
- Returns
- The result of the adding.
◆ __iadd__()
UM.Math.Vector2.Vector2.__iadd__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Adds the specified vector in-place to this vector element-wise.
- Parameters
-
other | The vector that must be added to this vector. |
◆ __imul__()
UM.Math.Vector2.Vector2.__imul__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Multiplies the specified vector in-place with this vector element-wise.
- Parameters
-
other | The vector that must be multiplied with this vector. |
◆ __isub__()
UM.Math.Vector2.Vector2.__isub__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Subtracts the specified vector in-place from this vector element-wise.
- Parameters
-
other | The vector that must be subtracted from this vector. |
◆ __itruediv__()
UM.Math.Vector2.Vector2.__itruediv__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Divides this vector in-place by the specified vector element-wise.
- Parameters
-
other | The vector by which this vector must be divided. |
◆ __mul__()
UM.Math.Vector2.Vector2.__mul__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Multiplies the specified vector with this vector element-wise.
- Parameters
-
other | The vector that must be multiplied with this vector. |
- Returns
- The result of the multiplication.
◆ __neg__()
UM.Math.Vector2.Vector2.__neg__ |
( |
|
self | ) |
|
Negates the vector, resulting in a vector with the opposite direction.
- Returns
- The negated vector.
◆ __rmul__()
UM.Math.Vector2.Vector2.__rmul__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Multiplies the specified vector with this vector element-wise.
- Parameters
-
other | The vector that must be multiplied with this vector. |
◆ __rtruediv__()
UM.Math.Vector2.Vector2.__rtruediv__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Divides this vector by the specified vector element-wise.
- Parameters
-
other | The vector by which this vector must be divided. |
- Returns
- The result of the division.
◆ __str__()
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__()
UM.Math.Vector2.Vector2.__sub__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Subtracts the specified vector from this vector element-wise.
- Parameters
-
other | The vector that must be subtracted from this vector. |
- Returns
- The result of the subtraction.
◆ __truediv__()
UM.Math.Vector2.Vector2.__truediv__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Divides this vector by the specified vector element-wise.
- Parameters
-
other | The vector by which this vector must be divided. |
- Returns
- The result of the division.
◆ cross()
UM.Math.Vector2.Vector2.cross |
( |
|
self, |
|
|
|
other |
|
) |
| |
Computes the generalised cross product of this vector with another.
- Parameters
-
other | The vector to compute the cross product with. |
- Returns
- The generalised cross product.
◆ dot()
UM.Math.Vector2.Vector2.dot |
( |
|
self, |
|
|
|
other |
|
) |
| |
Computes the dot product of this vector and another.
- Parameters
-
other | The vector to compute the dot product with. |
- Returns
- The dot product of the two vectors.
◆ getData()
UM.Math.Vector2.Vector2.getData |
( |
|
self | ) |
|
Gets the numpy array with the data.
- Returns
- A numpy array with the data of this vector.
◆ length()
UM.Math.Vector2.Vector2.length |
( |
|
self | ) |
|
Gets the Euclidean length of this vector.
- Returns
- The length of this vector.
◆ perpendicular()
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()
UM.Math.Vector2.Vector2.setX |
( |
|
self, |
|
|
|
x |
|
) |
| |
Changes the x-component of this vector.
- Parameters
-
x | The new x-component of the vector. |
◆ setY()
UM.Math.Vector2.Vector2.setY |
( |
|
self, |
|
|
|
y |
|
) |
| |
Changes the y-component of this vector.
- Parameters
-
y | The new y-component of the vector. |
◆ x()
UM.Math.Vector2.Vector2.x |
( |
|
self | ) |
|
Gets the x-component of the vector.
- Returns
- The x-component of the vector.
◆ y()
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: