#[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.
It 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.
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§
§impl Vector4i
impl Vector4i
pub 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
Returns a vector with the given components.
pub fn abs(self) -> Vector4i
pub fn abs(self) -> Vector4i
Returns a new vector with all components in absolute values (i.e. positive or zero).
pub 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.
pub fn length_squared(self) -> i32
pub fn length_squared(self) -> i32
Squared length (squared magnitude) of this vector.
Runs faster than Self::length
, so prefer it if you need to compare vectors or need the
squared distance for some formula.
pub 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.
§impl Vector4i
impl Vector4i
pub 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)
.
pub 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)
.
§impl Vector4i
impl Vector4i
pub 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:
pub const fn from_vector4(v: Vector4) -> Vector4i
pub const fn from_vector4(v: Vector4) -> Vector4i
Constructs a new Vector4i
from a Vector4
. The floating point coordinates will be
truncated.
Trait Implementations§
§impl AddAssign for Vector4i
impl AddAssign for Vector4i
§fn add_assign(&mut self, rhs: Vector4i)
fn add_assign(&mut self, rhs: Vector4i)
+=
operation. Read more§impl DivAssign<i32> for Vector4i
impl DivAssign<i32> for Vector4i
§fn div_assign(&mut self, rhs: i32)
fn div_assign(&mut self, rhs: i32)
/=
operation. Read more§impl DivAssign for Vector4i
impl DivAssign for Vector4i
§fn div_assign(&mut self, rhs: Vector4i)
fn div_assign(&mut self, rhs: Vector4i)
/=
operation. Read more§impl Export for Vector4i
impl Export for Vector4i
§fn default_export_info() -> PropertyHintInfo
fn default_export_info() -> PropertyHintInfo
§impl FromGodot for Vector4i
impl FromGodot for Vector4i
§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.§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant
, returning Err
on failure.§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
§impl GodotConvert for Vector4i
impl GodotConvert for Vector4i
§impl Index<Vector4Axis> for Vector4i
impl Index<Vector4Axis> for Vector4i
§impl IndexMut<Vector4Axis> for Vector4i
impl IndexMut<Vector4Axis> for Vector4i
§fn index_mut(&mut self, axis: Vector4Axis) -> &mut i32
fn index_mut(&mut self, axis: Vector4Axis) -> &mut i32
container[index]
) operation. Read more§impl MulAssign<i32> for Vector4i
impl MulAssign<i32> for Vector4i
§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
*=
operation. Read more§impl MulAssign for Vector4i
impl MulAssign for Vector4i
§fn mul_assign(&mut self, rhs: Vector4i)
fn mul_assign(&mut self, rhs: Vector4i)
*=
operation. Read more§impl Ord for Vector4i
impl Ord for Vector4i
§impl PartialOrd for Vector4i
impl PartialOrd for Vector4i
§fn partial_cmp(&self, other: &Vector4i) -> Option<Ordering>
fn partial_cmp(&self, other: &Vector4i) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more§impl SubAssign for Vector4i
impl SubAssign for Vector4i
§fn sub_assign(&mut self, rhs: Vector4i)
fn sub_assign(&mut self, rhs: Vector4i)
-=
operation. Read more§impl ToGodot for Vector4i
impl ToGodot for Vector4i
§fn to_godot(&self) -> <Vector4i as GodotConvert>::Via
fn to_godot(&self) -> <Vector4i as GodotConvert>::Via
§fn into_godot(self) -> <Vector4i as GodotConvert>::Via
fn into_godot(self) -> <Vector4i as GodotConvert>::Via
§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
§impl TypeStringHint for Vector4i
impl TypeStringHint for Vector4i
§fn type_string() -> String
fn type_string() -> String
§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)
fn property_hint() -> PropertyHintInfo
impl ArrayElement for Vector4i
impl Copy for Vector4i
impl Eq for Vector4i
impl GodotType for Vector4i
impl StructuralPartialEq for Vector4i
Auto Trait Implementations§
impl Freeze for Vector4i
impl RefUnwindSafe for Vector4i
impl Send for Vector4i
impl Sync for Vector4i
impl Unpin for Vector4i
impl UnwindSafe for Vector4i
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)