Struct Vector3i
#[repr(C)]pub struct Vector3i {
pub x: i32,
pub y: i32,
pub z: i32,
}
Expand description
Vector used for 3D math using integer coordinates.
3-element structure that can be used to represent discrete positions or directions in 3D space, as well as any other triple of numeric values.
Vector3i
uses integer coordinates and is therefore preferable to Vector3
when exact precision is
required. Note that the values are limited to 32 bits, and unlike Vector3
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
Vector3i
functions - 3D functions
- Trait impls + operators
§All vector types
You can convert to Vector3
using cast_float()
.
§Godot docs
Fields§
§x: i32
The vector’s X component.
y: i32
The vector’s Y component.
z: i32
The vector’s Z component.
Implementations§
§impl Vector3i
§Constants
impl Vector3i
§Constants
pub const MIN: Vector3i = _
pub const MIN: Vector3i = _
Min vector, a vector with all components equal to i32::MIN
. Can be used as a negative integer equivalent of real::INF
.
pub const MAX: Vector3i = _
pub const MAX: Vector3i = _
Max vector, a vector with all components equal to i32::MAX
. Can be used as an integer equivalent of real::INF
.
pub const LEFT: Vector3i = _
pub const LEFT: Vector3i = _
Unit vector in -X direction. Can be interpreted as left in an untransformed 3D world.
pub const RIGHT: Vector3i = _
pub const RIGHT: Vector3i = _
Unit vector in +X direction. Can be interpreted as right in an untransformed 3D world.
pub const DOWN: Vector3i = _
pub const DOWN: Vector3i = _
Unit vector in -Y direction. Typically interpreted as down in a 3D world.
§impl Vector3i
§Constructors and general vector functions
The following associated functions and methods are available on all vectors (2D, 3D, 4D; float and int).
impl Vector3i
§Constructors and general vector functions
The following associated functions and methods are available on all vectors (2D, 3D, 4D; float and int).
pub const fn from_tuple(tuple: (i32, i32, i32)) -> Vector3i
pub const fn from_tuple(tuple: (i32, i32, i32)) -> Vector3i
Creates a vector from the given tuple.
pub const fn from_array(array: [i32; 3]) -> Vector3i
pub const fn from_array(array: [i32; 3]) -> Vector3i
Creates a vector from the given array.
pub fn abs(self) -> Vector3i
pub fn abs(self) -> Vector3i
Returns a new vector with all components in absolute values (i.e. positive or zero).
pub fn clamp(self, min: Vector3i, max: Vector3i) -> Vector3i
pub fn clamp(self, min: Vector3i, max: Vector3i) -> Vector3i
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 length()
, so prefer it if you need to compare vectors or need the
squared distance for some formula.
pub fn coord_min(self, other: Vector3i) -> Vector3i
pub fn coord_min(self, other: Vector3i) -> Vector3i
Returns a new vector containing the minimum of the two vectors, component-wise.
You may consider using the fully-qualified syntax Vector3i::coord_min(a, b)
for symmetry.
§impl Vector3i
§Specialized Vector3i
functions
impl Vector3i
§Specialized Vector3i
functions
pub const fn from_vector3(v: Vector3) -> Vector3i
Vector3::cast_int()
pub fn snapped(self, step: Vector3i) -> Vector3i
pub fn snapped(self, step: Vector3i) -> Vector3i
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 cast_float(self) -> Vector3
pub const fn cast_float(self) -> Vector3
Converts to a vector with floating-point real
components, using as
casts.
§impl Vector3i
§3D functions
The following methods are only available on 3D vectors (for both float and int).
impl Vector3i
§3D functions
The following methods are only available on 3D vectors (for both float and int).
pub fn max_axis(self) -> Option<Vector3Axis>
pub fn max_axis(self) -> Option<Vector3Axis>
Returns the axis of the vector’s highest value. See Vector3Axis
enum. If all components are equal, this method returns None
.
To mimic Godot’s behavior, unwrap this function’s result with unwrap_or(Vector3Axis::X)
.
pub fn min_axis(self) -> Option<Vector3Axis>
pub fn min_axis(self) -> Option<Vector3Axis>
Returns the axis of the vector’s lowest value. See Vector3Axis
enum. If all components are equal, this method returns None
.
To mimic Godot’s behavior, unwrap this function’s result with unwrap_or(Vector3Axis::Z)
.
Trait Implementations§
§impl AddAssign for Vector3i
impl AddAssign for Vector3i
§fn add_assign(&mut self, rhs: Vector3i)
fn add_assign(&mut self, rhs: Vector3i)
+=
operation. Read more§impl DivAssign<i32> for Vector3i
impl DivAssign<i32> for Vector3i
§fn div_assign(&mut self, rhs: i32)
fn div_assign(&mut self, rhs: i32)
/=
operation. Read more§impl DivAssign for Vector3i
impl DivAssign for Vector3i
§fn div_assign(&mut self, rhs: Vector3i)
fn div_assign(&mut self, rhs: Vector3i)
/=
operation. Read more§impl Export for Vector3i
impl Export for Vector3i
§fn export_hint() -> PropertyHintInfo
fn export_hint() -> PropertyHintInfo
§impl FromGodot for Vector3i
impl FromGodot for Vector3i
§fn try_from_godot(
via: <Vector3i as GodotConvert>::Via,
) -> Result<Vector3i, ConvertError>
fn try_from_godot( via: <Vector3i as GodotConvert>::Via, ) -> Result<Vector3i, 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 Vector3i
impl GodotConvert for Vector3i
§impl Index<Vector3Axis> for Vector3i
impl Index<Vector3Axis> for Vector3i
§impl IndexMut<Vector3Axis> for Vector3i
impl IndexMut<Vector3Axis> for Vector3i
§fn index_mut(&mut self, axis: Vector3Axis) -> &mut i32
fn index_mut(&mut self, axis: Vector3Axis) -> &mut i32
container[index]
) operation. Read more§impl MulAssign<i32> for Vector3i
impl MulAssign<i32> for Vector3i
§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
*=
operation. Read more§impl MulAssign for Vector3i
impl MulAssign for Vector3i
§fn mul_assign(&mut self, rhs: Vector3i)
fn mul_assign(&mut self, rhs: Vector3i)
*=
operation. Read more§impl Ord for Vector3i
impl Ord for Vector3i
§impl ParamType for Vector3i
impl ParamType for Vector3i
§fn owned_to_arg<'v>(self) -> <Vector3i as ParamType>::Arg<'v>
fn owned_to_arg<'v>(self) -> <Vector3i as ParamType>::Arg<'v>
impl AsArg<T>
. Read more§impl PartialOrd for Vector3i
impl PartialOrd for Vector3i
§impl SubAssign for Vector3i
impl SubAssign for Vector3i
§fn sub_assign(&mut self, rhs: Vector3i)
fn sub_assign(&mut self, rhs: Vector3i)
-=
operation. Read more§impl ToGodot for Vector3i
impl ToGodot for Vector3i
§impl Var for Vector3i
impl Var for Vector3i
fn get_property(&self) -> <Vector3i as GodotConvert>::Via
fn set_property(&mut self, value: <Vector3i as GodotConvert>::Via)
§fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info
, e.g. for enums/newtypes.