init()
Constructs a default-initialized Vector4i
with all components set to 0
.
init(from: Vector4i)
Constructs a Vector4i
as a copy of the given Vector4i
.
init(from: Vector4)
Constructs a new Vector4i
from the given Vector4
by truncating components’ fractional parts (rounding towards zero). For a different behavior consider passing the result of ceil
, floor
or round
to this constructor instead.
init(x: Int32, y: Int32, z: Int32, w: Int32)
Returns a Vector4i
with the given components.
static let axisW: Int
Enumerated value for the W axis. Returned by maxAxisIndex
and minAxisIndex
.
static let axisX: Int
Enumerated value for the X axis. Returned by maxAxisIndex
and minAxisIndex
.
static let axisY: Int
Enumerated value for the Y axis. Returned by maxAxisIndex
and minAxisIndex
.
static let axisZ: Int
Enumerated value for the Z axis. Returned by maxAxisIndex
and minAxisIndex
.
static var godotType: Variant.GType
static let max: Vector4i
Max vector, a vector with all components equal to INT32_MAX
. Can be used as an integer equivalent of Vector4.INF
.
static let min: Vector4i
Min vector, a vector with all components equal to INT32_MIN
. Can be used as a negative integer equivalent of Vector4.INF
.
static let one: Vector4i
One vector, a vector with all components set to 1
.
static let zero: Vector4i
Zero vector, a vector with all components set to 0
.
static func != (lhs: Vector4i, rhs: Vector4i) -> Bool
Returns true
if the vectors are not equal.
static func % (lhs: Vector4i, rhs: Vector4i) -> Vector4i
Gets the remainder of each component of the Vector4i
with the components of the given Vector4i
. This operation uses truncated division, which is often not desired as it does not work well with negative numbers. Consider using @GlobalScope.posmod
instead if you want to handle negative numbers.
static func % (lhs: Vector4i, rhs: Int64) -> Vector4i
Gets the remainder of each component of the Vector4i
with the the given integer. This operation uses truncated division, which is often not desired as it does not work well with negative numbers. Consider using @GlobalScope.posmod
instead if you want to handle negative numbers.
static func %= (left: inout `Self`, right: `Self`)
static func * (lhs: Vector4i, rhs: Vector4i) -> Vector4i
Multiplies each component of the Vector4i
by the components of the given Vector4i
.
static func * (lhs: Vector4i, rhs: Int64) -> Vector4i
Multiplies each component of the Vector4i
by the given integer.
static func * (lhs: Vector4i, rhs: Double) -> Vector4
Multiplies each component of the Vector4i
by the given float.
static func *= (left: inout `Self`, right: `Self`)
static func + (lhs: Vector4i, rhs: Vector4i) -> Vector4i
Adds each component of the Vector4i
by the components of the given Vector4i
.
static func += (left: inout `Self`, right: `Self`)
static func - (v: `Self`) -> Vector4i
Returns the negative value of the Vector4i. This is the same as writing Vector4i(-v.x, -v.y, -v.z, -v.w). This operation flips the direction of the vector while keeping the same magnitude.
static func - (lhs: Vector4i, rhs: Vector4i) -> Vector4i
Subtracts each component of the Vector4i
by the components of the given Vector4i
.
static func -= (left: inout `Self`, right: `Self`)
static func / (lhs: Vector4i, rhs: Vector4i) -> Vector4i
Divides each component of the Vector4i
by the components of the given Vector4i
.
static func / (lhs: Vector4i, rhs: Int64) -> Vector4i
Divides each component of the Vector4i
by the given integer.
static func / (lhs: Vector4i, rhs: Double) -> Vector4
Divides each component of the Vector4i
by the given float.
static func /= (left: inout `Self`, right: `Self`)
static func < (lhs: Vector4i, rhs: Vector4i) -> Bool
Compares two Vector4i
vectors by first checking if the X value of the left vector is less than the X value of the right
vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
static func <= (lhs: Vector4i, rhs: Vector4i) -> Bool
Compares two Vector4i
vectors by first checking if the X value of the left vector is less than or equal to the X value of the right
vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
static func == (lhs: Vector4i, rhs: Vector4i) -> Bool
Returns true
if the vectors are exactly equal.
static func > (lhs: Vector4i, rhs: Vector4i) -> Bool
Compares two Vector4i
vectors by first checking if the X value of the left vector is greater than the X value of the right
vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
static func >= (lhs: Vector4i, rhs: Vector4i) -> Bool
Compares two Vector4i
vectors by first checking if the X value of the left vector is greater than or equal to the X value of the right
vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
var w: Int32
The vector’s W component. Also accessible by using the index position [3]
.
var x: Int32
The vector’s X component. Also accessible by using the index position [0]
.
var y: Int32
The vector’s Y component. Also accessible by using the index position [1]
.
var z: Int32
The vector’s Z component. Also accessible by using the index position [2]
.
subscript(Int64) -> Int64
func abs() -> Vector4i
Returns a new vector with all components in absolute values (i.e. positive).
func clamp(min: Vector4i, max: Vector4i) -> Vector4i
Returns a new vector with all components clamped between the components of min
and max
, by running @GlobalScope.clamp
on each component.
func clampi(min: Int64, max: Int64) -> Vector4i
Returns a new vector with all components clamped between min
and max
, by running @GlobalScope.clamp
on each component.
func distanceSquaredTo(Vector4i) -> Int64
Returns the squared distance between this vector and to
.
func distanceTo(Vector4i) -> Double
Returns the distance between this vector and to
.
func length() -> Double
Returns the length (magnitude) of this vector.
func lengthSquared() -> Int64
Returns the squared length (squared magnitude) of this vector.
func max(with: Vector4i) -> Vector4i
Returns the component-wise maximum of this and with
, equivalent to Vector4i(maxi(x, with.x), maxi(y, with.y), maxi(z, with.z), maxi(w, with.w))
.
func maxAxisIndex() -> Int64
Returns the axis of the vector’s highest value. See AXIS_*
constants. If all components are equal, this method returns .x.
func maxi(with: Int64) -> Vector4i
Returns the component-wise maximum of this and with
, equivalent to Vector4i(maxi(x, with), maxi(y, with), maxi(z, with), maxi(w, with))
.
func min(with: Vector4i) -> Vector4i
Returns the component-wise minimum of this and with
, equivalent to Vector4i(mini(x, with.x), mini(y, with.y), mini(z, with.z), mini(w, with.w))
.
func minAxisIndex() -> Int64
Returns the axis of the vector’s lowest value. See AXIS_*
constants. If all components are equal, this method returns .w.
func mini(with: Int64) -> Vector4i
Returns the component-wise minimum of this and with
, equivalent to Vector4i(mini(x, with), mini(y, with), mini(z, with), mini(w, with))
.
func sign() -> Vector4i
Returns a new vector with each component set to 1
if it’s positive, -1
if it’s negative, and 0
if it’s zero. The result is identical to calling @GlobalScope.sign
on each component.
func snapped(step: `Self`) -> Vector4i
func snappedi(step: Int64) -> Vector4i
Returns a new vector with each component snapped to the closest multiple of step
.