#[repr(C)]pub struct Vector4i {
pub x: i32,
pub y: i32,
pub z: i32,
pub w: i32,
}
Expand description
Vector used for 4D math using integer coordinates.
4-element structure that can be used to represent 4D grid coordinates or sets of integers.
Vector4i
uses integer coordinates and is therefore preferable to Vector4
when exact precision is
required. Note that the values are limited to 32 bits, and unlike Vector4
this cannot be
configured with an engine build option. Use i64
or PackedInt64Array
if 64-bit values are needed.
Conversions are provided via various from_*
and to_*
functions, not via the From
trait. This encourages new()
as the main way to construct vectors, is explicit about the conversion taking place, needs no type inference, and works in const
contexts.
§Navigation to impl
blocks within this page
- Constants
- Constructors and general vector functions
- Specialized
Vector4i
functions - 4D functions
- Trait impls + operators
§All vector types
§Godot docs
Fields§
§x: i32
The vector’s X component.
y: i32
The vector’s Y component.
z: i32
The vector’s Z component.
w: i32
The vector’s W component.
Implementations§
Source§impl Vector4i
§Constants
impl Vector4i
§Constants
Source§impl Vector4i
§Constructors and general vector functions
The following associated functions and methods are available on all vectors (2D, 3D, 4D; float and int).
impl Vector4i
§Constructors and general vector functions
The following associated functions and methods are available on all vectors (2D, 3D, 4D; float and int).
Sourcepub const fn new(x: i32, y: i32, z: i32, w: i32) -> Vector4i
pub const fn new(x: i32, y: i32, z: i32, w: i32) -> Vector4i
Creates a vector with the given components.
Sourcepub const fn from_tuple(tuple: (i32, i32, i32, i32)) -> Vector4i
pub const fn from_tuple(tuple: (i32, i32, i32, i32)) -> Vector4i
Creates a vector from the given tuple.
Sourcepub const fn from_array(array: [i32; 4]) -> Vector4i
pub const fn from_array(array: [i32; 4]) -> Vector4i
Creates a vector from the given array.
Sourcepub const fn to_tuple(&self) -> (i32, i32, i32, i32)
pub const fn to_tuple(&self) -> (i32, i32, i32, i32)
Returns a tuple with the components of the vector.
Sourcepub fn abs(self) -> Vector4i
pub fn abs(self) -> Vector4i
Returns a new vector with all components in absolute values (i.e. positive or zero).
Sourcepub fn clamp(self, min: Vector4i, max: Vector4i) -> Vector4i
pub fn clamp(self, min: Vector4i, max: Vector4i) -> Vector4i
Returns a new vector with all components clamped between the components of min
and max
.
§Panics
If min
> max
, min
is NaN, or max
is NaN.
Sourcepub fn length_squared(self) -> i32
pub fn length_squared(self) -> i32
Squared length (squared magnitude) of this vector.
Runs faster than length()
, so prefer it if you need to compare vectors or need the
squared distance for some formula.
Sourcepub fn coord_min(self, other: Vector4i) -> Vector4i
pub fn coord_min(self, other: Vector4i) -> Vector4i
Returns a new vector containing the minimum of the two vectors, component-wise.
You may consider using the fully-qualified syntax Vector4i::coord_min(a, b)
for symmetry.
Source§impl Vector4i
§Specialized Vector4i
functions
impl Vector4i
§Specialized Vector4i
functions
Sourcepub fn snapped(self, step: Vector4i) -> Vector4i
pub fn snapped(self, step: Vector4i) -> Vector4i
A new vector with each component snapped to the closest multiple of the corresponding
component in step
.
§Panics
On under- or overflow:
Sourcepub const fn cast_float(self) -> Vector4
pub const fn cast_float(self) -> Vector4
Converts to a vector with floating-point real
components, using as
casts.
Source§impl Vector4i
§4D functions
The following methods are only available on 4D vectors (for both float and int).
impl Vector4i
§4D functions
The following methods are only available on 4D vectors (for both float and int).
Sourcepub fn max_axis(self) -> Option<Vector4Axis>
pub fn max_axis(self) -> Option<Vector4Axis>
Returns the axis of the vector’s highest value. See Vector4Axis
enum. If all components are equal, this method returns None
.
To mimic Godot’s behavior, unwrap this function’s result with unwrap_or(Vector4Axis::X)
.
Sourcepub fn min_axis(self) -> Option<Vector4Axis>
pub fn min_axis(self) -> Option<Vector4Axis>
Returns the axis of the vector’s lowest value. See Vector4Axis
enum. If all components are equal, this method returns None
.
To mimic Godot’s behavior, unwrap this function’s result with unwrap_or(Vector4Axis::W)
.
Trait Implementations§
Source§impl AddAssign for Vector4i
impl AddAssign for Vector4i
Source§fn add_assign(&mut self, rhs: Vector4i)
fn add_assign(&mut self, rhs: Vector4i)
+=
operation. Read moreSource§impl DivAssign<i32> for Vector4i
impl DivAssign<i32> for Vector4i
Source§fn div_assign(&mut self, rhs: i32)
fn div_assign(&mut self, rhs: i32)
/=
operation. Read moreSource§impl DivAssign for Vector4i
impl DivAssign for Vector4i
Source§fn div_assign(&mut self, rhs: Vector4i)
fn div_assign(&mut self, rhs: Vector4i)
/=
operation. Read moreSource§impl DynamicSend for Vector4i
impl DynamicSend for Vector4i
Source§impl Export for Vector4i
impl Export for Vector4i
Source§fn export_hint() -> PropertyHintInfo
fn export_hint() -> PropertyHintInfo
Source§impl FromGodot for Vector4i
impl FromGodot for Vector4i
Source§fn try_from_godot(
via: <Vector4i as GodotConvert>::Via,
) -> Result<Vector4i, ConvertError>
fn try_from_godot( via: <Vector4i as GodotConvert>::Via, ) -> Result<Vector4i, ConvertError>
Err
on failure.Source§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
Source§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant
, returning Err
on failure.Source§impl GodotConvert for Vector4i
impl GodotConvert for Vector4i
Source§impl Index<Vector4Axis> for Vector4i
impl Index<Vector4Axis> for Vector4i
Source§impl IndexMut<Vector4Axis> for Vector4i
impl IndexMut<Vector4Axis> for Vector4i
Source§impl IntoDynamicSend for Vector4i
impl IntoDynamicSend for Vector4i
type Target = Vector4i
fn into_dynamic_send(self) -> <Vector4i as IntoDynamicSend>::Target
Source§impl MulAssign<i32> for Vector4i
impl MulAssign<i32> for Vector4i
Source§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
*=
operation. Read moreSource§impl MulAssign for Vector4i
impl MulAssign for Vector4i
Source§fn mul_assign(&mut self, rhs: Vector4i)
fn mul_assign(&mut self, rhs: Vector4i)
*=
operation. Read moreSource§impl Ord for Vector4i
impl Ord for Vector4i
Source§impl ParamType for Vector4i
impl ParamType for Vector4i
type ArgPassing = ByValue
Source§fn owned_to_arg(self) -> impl AsArg<Self>
fn owned_to_arg(self) -> impl AsArg<Self>
Source§impl PartialOrd for Vector4i
impl PartialOrd for Vector4i
Source§impl SubAssign for Vector4i
impl SubAssign for Vector4i
Source§fn sub_assign(&mut self, rhs: Vector4i)
fn sub_assign(&mut self, rhs: Vector4i)
-=
operation. Read moreSource§impl ToGodot for Vector4i
impl ToGodot for Vector4i
Source§impl Var for Vector4i
impl Var for Vector4i
fn get_property(&self) -> <Vector4i as GodotConvert>::Via
fn set_property(&mut self, value: <Vector4i as GodotConvert>::Via)
Source§fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info
, e.g. for enums/newtypes.