Int2
A two-dimensional integer vector with x and y components
Category: Utility
Base class: _BlipValue
Properties
maxComponent : int (Read-Only)
The maximum component of the vector.
minComponent : int (Read-Only)
The minimum component of the vector.
x : int
The x component of the vector.
UserName: X
y : int
The y component of the vector.
UserName: Y
Constructors
__init__(self)
__init__(self, other: Int2)
Copy constructor for Int2
__init__(self, v: Vec2)
__init__(self, x_: int, y_: int)
Methods
_initParams(self) -> Any
A serialisable tuple of the Int2 parameters
anyLargerThan(self, v: Int2) -> bool
Checks whether any component of this vector is larger than the corresponding component of another vector.
Parameters:
- v: The other vector to compare with.
Returns True if any component of this vector is larger than the corresponding component of the other vector.
anySmallerThan(self, v: Int2) -> bool
Checks if any component of this vector is smaller than the corresponding component of another vector.
Parameters:
- v: The other vector to compare with.
Returns True if any component of this vector is smaller than the corresponding component of the other vector.
area(self) -> int
The area of the vector if its components are treated as the sides of a rectangle.
Returns The area of the vector, defined as the absolute value of x * y.
aspect(self) -> float
The aspect ratio of the vector, defined as the ratio of the x component to the y component.
Returns The aspect ratio of the vector.
length(self) -> float
The length of the vector in 2D space.
Returns The length of the vector.
restrict(self, a: Int2, b: Int2) -> Int2
Restricts the vector to be within a minimum and maximum range.
Parameters:
- a: A vector of minimum values for each component.
- b: A vector of maximum values for each component.
Returns A new vector with components restricted to the minimum and maximum range.
vmax(self, o: Int2) -> Int2
Component-wise maximum of two vectors.
Parameters:
- o: The other vector to compare with.
Returns A new vector containing the component-wise maximum of this and the other vector.
vmin(self, o: Int2) -> Int2
Component-wise minimum of two vectors.
Parameters:
- o: The other vector to compare with.
Returns A new vector containing the component-wise minimum of this and the other vector.
Special Methods
__add__(self, v: Int2) -> Int2
Adds two vectors.
Parameters:
- v: The vector to add to this one.
Returns The component-wise sum of this and the input vector.
__eq__(self, other: Int2) -> bool
Tests for equality between two vectors.
Parameters:
- other: The vector to compare with.
Returns True if both components of the vectors are equal, false otherwise.
__getitem__(self, key) -> Any
Get an item from the Int2 by index.
Parameters:
- key: The index of the desired item. Must be 0 or 1
Returns The x element if the index is 0, the y element if the index is 1
__len__(self) -> Any
The length of the Int2
Returns Always returns 2
__mul__(self, d) -> Any
Multiplies two vectors component-wise.
Parameters:
- v: The other vector to multiply with.
Returns The component-wise product of the two vectors.
__ne__(self, other: Int2) -> bool
Tests for inequality between two vectors.
Parameters:
- other: The other vector to compare with.
Returns True if either of the components of the vectors are not equal, false otherwise.
__neg__(self) -> Any
The negative of the Int2
Returns The Int2 with its x and y components negated
__repr__(self) -> Any
String representation of the Int2
__rmul__(self, d) -> Any
Multiplies two vectors component-wise.
Parameters:
- v: The other vector to multiply with.
Returns The component-wise product of the two vectors.
__str__(self) -> Any
String representation of the Int2
__sub__(self, v: Int2) -> Int2
Subtracts another vector from this vector.
Parameters:
- v: The vector to subtract from this vector.
Returns The resulting vector after component-wise subtraction.