Enumerationmigueldeicaza.swiftgodot 0.45.0SwiftGodot
Axis
Vector4.swift:24enum Axis
Cases
case x
Enumerated value for the X axis. Returned by
maxAxisIndex
andminAxisIndex
.case y
Enumerated value for the Y axis. Returned by
maxAxisIndex
andminAxisIndex
.case z
Enumerated value for the Z axis. Returned by
maxAxisIndex
andminAxisIndex
.case w
Enumerated value for the W axis. Returned by
maxAxisIndex
andminAxisIndex
.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (63) members.
Type members
init(
) Constructs a default-initialized
Vector4
with all components set to0
.init(from: Vector4
) init(from: Vector4i
) Constructs a new
Vector4
from the givenVector4i
.init(x: Float, y: Float, z: Float, w: Float
) Returns a
Vector4
with the given components.static let axisW: Int
Enumerated value for the W axis. Returned by
maxAxisIndex
andminAxisIndex
.static let axisX: Int
Enumerated value for the X axis. Returned by
maxAxisIndex
andminAxisIndex
.static let axisY: Int
Enumerated value for the Y axis. Returned by
maxAxisIndex
andminAxisIndex
.static let axisZ: Int
Enumerated value for the Z axis. Returned by
maxAxisIndex
andminAxisIndex
.static var godotType: Variant.GType
static let inf: Vector4
Infinity vector, a vector with all components set to
@GDScript.INF
.static let one: Vector4
One vector, a vector with all components set to
1
.static let zero: Vector4
Zero vector, a vector with all components set to
0
.static func != (lhs: Vector4, rhs: Vector4
) -> Bool Returns
true
if the vectors are not equal.static func * (lhs: Vector4, rhs: Projection
) -> Vector4 Multiplies each component of the
Vector4
by the given integer.static func * (lhs: Vector4, rhs: Vector4
) -> Vector4 Multiplies each component of the
Vector4
by the given integer.static func * (lhs: Vector4, rhs: Double
) -> Vector4 Multiplies each component of the
Vector4
by the given integer.static func * (lhs: Vector4, rhs: Int64
) -> Vector4 Multiplies each component of the
Vector4
by the given integer.static func *= (left: inout `Self`, right: `Self`
) static func + (lhs: Vector4, rhs: Vector4
) -> Vector4 Adds each component of the
Vector4
by the components of the givenVector4
.static func += (left: inout `Self`, right: `Self`
) static func - (v: `Self`
) -> Vector4 Returns the negative value of the Vector4. This is the same as writing Vector4(-v.x, -v.y, -v.z, -v.w). This operation flips the direction of the vector while keeping the same magnitude. With floats, the number zero can be either positive or negative.
static func - (lhs: Vector4, rhs: Vector4
) -> Vector4 Subtracts each component of the
Vector4
by the components of the givenVector4
.static func -= (left: inout `Self`, right: `Self`
) static func / (lhs: Vector4, rhs: Vector4
) -> Vector4 Divides each component of the
Vector4
by the given integer.static func / (lhs: Vector4, rhs: Double
) -> Vector4 Divides each component of the
Vector4
by the given integer.static func / (lhs: Vector4, rhs: Int64
) -> Vector4 Divides each component of the
Vector4
by the given integer.static func /= (left: inout `Self`, right: `Self`
) static func < (lhs: Vector4, rhs: Vector4
) -> Bool Compares two
Vector4
vectors by first checking if the X value of the left vector is less than the X value of theright
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: Vector4, rhs: Vector4
) -> Bool Compares two
Vector4
vectors by first checking if the X value of the left vector is less than or equal to the X value of theright
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: Vector4, rhs: Vector4
) -> Bool Returns
true
if the vectors are exactly equal.static func > (lhs: Vector4, rhs: Vector4
) -> Bool Compares two
Vector4
vectors by first checking if the X value of the left vector is greater than the X value of theright
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: Vector4, rhs: Vector4
) -> Bool Compares two
Vector4
vectors by first checking if the X value of the left vector is greater than or equal to the X value of theright
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.
Instance members
var w: Float
The vector’s W component. Also accessible by using the index position
[3]
.var x: Float
The vector’s X component. Also accessible by using the index position
[0]
.var y: Float
The vector’s Y component. Also accessible by using the index position
[1]
.var z: Float
The vector’s Z component. Also accessible by using the index position
[2]
.subscript(Int64
) -> Double func abs(
) -> Vector4 Returns a new vector with all components in absolute values (i.e. positive).
func ceil(
) -> Vector4 Returns a new vector with all components rounded up (towards positive infinity).
func clamp(min: Vector4, max: Vector4
) -> Vector4 Returns a new vector with all components clamped between the components of
min
andmax
, by running@GlobalScope.clamp
on each component.func cubicInterpolate(b: Vector4, preA: Vector4, postB: Vector4, weight: Double
) -> Vector4 Performs a cubic interpolation between this vector and
b
usingpreA
andpostB
as handles, and returns the result at positionweight
.weight
is on the range of 0.0 to 1.0, representing the amount of interpolation.func cubicInterpolateInTime(b: Vector4, preA: Vector4, postB: Vector4, weight: Double, bT: Double, preAT: Double, postBT: Double
) -> Vector4 Performs a cubic interpolation between this vector and
b
usingpreA
andpostB
as handles, and returns the result at positionweight
.weight
is on the range of 0.0 to 1.0, representing the amount of interpolation.func directionTo(Vector4
) -> Vector4 Returns the normalized vector pointing from this vector to
to
. This is equivalent to using(b - a).normalized()
.func distanceSquaredTo(Vector4
) -> Double Returns the squared distance between this vector and
to
.func distanceTo(Vector4
) -> Double Returns the distance between this vector and
to
.func dot(with: Vector4
) -> Double Returns the dot product of this vector and
with
.func floor(
) -> Vector4 Returns a new vector with all components rounded down (towards negative infinity).
func inverse(
) -> Vector4 Returns the inverse of the vector. This is the same as
Vector4(1.0 / v.x, 1.0 / v.y, 1.0 / v.z, 1.0 / v.w)
.func isEqualApprox(to: Vector4
) -> Bool Returns
true
if this vector andto
are approximately equal, by running@GlobalScope.is_equal_approx
on each component.func isFinite(
) -> Bool Returns
true
if this vector is finite, by calling@GlobalScope.is_finite
on each component.func isNormalized(
) -> Bool Returns
true
if the vector is normalized, i.e. its length is approximately equal to 1.func isZeroApprox(
) -> Bool Returns
true
if this vector’s values are approximately zero, by running@GlobalScope.is_zero_approx
on each component.func length(
) -> Double Returns the length (magnitude) of this vector.
func lengthSquared(
) -> Double Returns the squared length (squared magnitude) of this vector.
func lerp(to: `Self`, weight: any BinaryFloatingPoint
) -> Vector4 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 minAxisIndex(
) -> Int64 Returns the axis of the vector’s lowest value. See
AXIS_*
constants. If all components are equal, this method returns .w.func normalized(
) -> Vector4 Returns the result of scaling the vector to unit length. Equivalent to
v / v.length()
. See alsoisNormalized
.func posmod(mod: Double
) -> Vector4 Returns a vector composed of the
@GlobalScope.fposmod
of this vector’s components andmod
.func posmodv(modv: Vector4
) -> Vector4 Returns a vector composed of the
@GlobalScope.fposmod
of this vector’s components andmodv
’s components.func round(
) -> Vector4 Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
func sign(
) -> Vector4 Returns a new vector with each component set to
1.0
if it’s positive,-1.0
if it’s negative, and0.0
if it’s zero. The result is identical to calling@GlobalScope.sign
on each component.func snapped(step: `Self`
) -> Vector4
Citizens in SwiftGodot
Conformances
protocol CaseIterable
A type that provides a collection of all of its values.
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
Type members
Instance members
var debugDescription: String
A textual representation of this instance, suitable for debugging
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.