Vec
A three-dimensional vector with x, y and z components.
Category: Utility
Base class: _BlipValue
Properties
maxComponent : float (Read-Only)
The maximum component of the vector.
minComponent : float (Read-Only)
The minimum component of the vector.
x : float
The x component of the vector.
UserName: X
y : float
The y component of the vector.
UserName: Y
z : float
The z component of the vector.
UserName: Z
Constructors
__init__(self)
__init__(self, _x: float, _y: float)
__init__(self, _x: float, _y: float, _z: float)
__init__(self, v: Vec2)
__init__(self, other: Vec)
Copy constructor for Vec
Methods
_initParams(self) -> Any
A serialisable tuple of the Vec parameters
angles(self) -> Vec
The Euler angles that rotate (0,0,-1) to be parallel with this vector.
Returns The Euler angles as a Vec of (heading, elevation, 0), in normalised coordinates.
cross(self, v: Vec) -> Vec
The cross product of two vectors.
Parameters:
- v: The other vector.
Returns The cross product of this vector and the other vector.
dot(self, v: Vec) -> float
The dot product of two vectors.
Parameters:
- v: The other vector to calculate the dot product with.
Returns The dot product of this vector and the other vector.
length(self) -> float
The length of the vector in 3D space.
Returns The length of the vector.
modulo(self, v: Vec) -> Vec
Modulo of two vectors.
Parameters:
- v: The other vector.
Returns A new vector with the component-wise modulo of this vector and the other vector.
normalise(self) -> Vec
Normalises the vector to have a length of 1.
Returns The normalised vector.
restrict(self, min: Vec, max: Vec) -> Vec
Restricts the vector to be within a minimum and maximum range.
Parameters:
- min: A vector of minimum values for each component.
- max: A vector of maximum values for each component.
Returns A new vector with components restricted to the minimum and maximum range.
round(self, v: Vec) -> Vec
Rounds the components of this vector.
Parameters:
- v: A vector of multiples each component is rounded to. e.g. (1, 1, 1) to round to the nearest integer.
Returns A new vector with rounded components.
vmax(self, v: Vec) -> Vec
Component-wise maximum of two vectors.
Parameters:
- v: The other vector to compare with.
Returns A new vector containing the component-wise maximum of this and the other vector.
vmin(self, v: Vec) -> Vec
Component-wise minimum of two vectors.
Parameters:
- v: 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: Vec) -> Vec
Adds two vectors.
Parameters:
- v: The Vec object to add to this one.
Returns The component-wise sum of this and the input vector.
__div__(self, s) -> Any
Divides the vector by a scalar value.
Parameters:
- s: The scalar value to divide the vector by.
Returns A new vector that is the result of dividing the components of this vector by the given scalar value.
__eq__(self, v: Vec) -> bool
Tests for equality between two vectors.
Parameters:
- v: The vector to compare with.
Returns True if all components of the vectors are equal, false otherwise.
__getitem__(self, key) -> Any
Get an item from the Vec by index.
Parameters:
- key: The index of the desired item. Must be 0, 1 or 2
Returns The x element if the index is 0, the y element if the index is 1, the z element if the index is 2
__len__(self) -> Any
The length of the Vec
Returns Always returns 3
__mul__(self, s) -> Any
Multiplies the vector by a scalar value.
Parameters:
- s: The scalar value to multiply with.
Returns A new vector that is the result of multiplying the components of this vector by the given scalar value.
__ne__(self, v: Vec) -> bool
Tests for inequality between two vectors.
Parameters:
- v: The other vector to compare with.
Returns True if any of the components of the vectors are not equal, false otherwise.
__neg__(self) -> Any
The negative of the Vec
Returns The Vec with its x, y and z components negated
__rdiv__(self, other) -> Any
Divide another vector by this vector
Parameters:
- other: The vector which is divided by this
Returns The element-wise division other/self
__repr__(self) -> Any
String representation of the Vec
__rmul__(self, s) -> Any
Multiplies the vector by a scalar value.
Parameters:
- s: The scalar value to multiply with.
Returns A new vector that is the result of multiplying the components of this vector by the given scalar value.
__str__(self) -> Any
String representation of the Vec
__sub__(self, v: Vec) -> Vec
Subtracts another vector from this vector.
Parameters:
- v: The vector to subtract from this vector.
Returns The resulting vector after component-wise subtraction.