Vector4

public struct Vector4<Scalar> : Vector4Type
extension Vector4: Equatable where Scalar: Equatable
extension Vector4: Hashable where Scalar: Hashable
extension Vector4: Encodable where Scalar: Encodable
extension Vector4: Decodable where Scalar: Decodable
extension Vector4: VectorComparable where Scalar: Comparable
extension Vector4: AdditiveArithmetic where Scalar: AdditiveArithmetic
extension Vector4: VectorAdditive where Scalar: AdditiveArithmetic
extension Vector4: VectorMultiplicative where Scalar: Numeric
extension Vector4: Vector4Additive where Scalar: AdditiveArithmetic
extension Vector4: VectorSigned where Scalar: SignedNumeric & Comparable
extension Vector4: VectorDivisible where Scalar: DivisibleArithmetic
extension Vector4: VectorFloatingPoint where Scalar: DivisibleArithmetic & FloatingPoint
extension Vector4: SignedDistanceMeasurableType where Scalar: DivisibleArithmetic & FloatingPoint
extension Vector4: Vector4FloatingPoint where Scalar: DivisibleArithmetic & FloatingPoint
extension Vector4: VectorReal where Scalar: DivisibleArithmetic & Real

A four-component vector type

  • x

    X coordinate of this vector

    Declaration

    Swift

    public var x: Scalar
  • y

    Y coordinate of this vector

    Declaration

    Swift

    public var y: Scalar
  • z

    Z coordinate of this vector

    Declaration

    Swift

    public var z: Scalar
  • w

    w coordinate of this vector

    Declaration

    Swift

    public var w: Scalar
  • Textual representation of this Vector4

    Declaration

    Swift

    public var description: String { get }
  • Declaration

    Swift

    public init(x: Scalar, y: Scalar, z: Scalar, w: Scalar)
  • Declaration

    Swift

    public init(repeating scalar: Scalar)
  • Initializes this Vector4 with the values from a given tuple.

    Declaration

    Swift

    public init(_ tuple: (Scalar, Scalar, Scalar, Scalar))

Available where Scalar: Comparable

  • Returns the pointwise minimal Vector where each component is the minimal scalar value at each index for both vectors.

    Declaration

    Swift

    public static func pointwiseMin(_ lhs: `Self`, _ rhs: `Self`) -> Vector4<Scalar>
  • Returns the pointwise maximal Vector where each component is the maximal scalar value at each index for both vectors.

    Declaration

    Swift

    public static func pointwiseMax(_ lhs: `Self`, _ rhs: `Self`) -> Vector4<Scalar>
  • Compares two vectors and returns true if all components of lhs are greater than rhs.

    Performs lhs.x > rhs.x && lhs.y > rhs.y && lhs.z > rhs.z && lhs.w > rhs.w

    Declaration

    Swift

    public static func > (lhs: `Self`, rhs: `Self`) -> Bool
  • Compares two vectors and returns true if all components of lhs are greater than or equal to rhs.

    Performs lhs.x >= rhs.x && lhs.y >= rhs.y && lhs.z >= rhs.z && lhs.w >= rhs.w

    Declaration

    Swift

    public static func >= (lhs: `Self`, rhs: `Self`) -> Bool
  • Compares two vectors and returns true if all components of lhs are less than rhs.

    Performs lhs.x < rhs.x && lhs.y < rhs.y && lhs.z < rhs.z && lhs.w < rhs.w

    Declaration

    Swift

    public static func < (lhs: `Self`, rhs: `Self`) -> Bool
  • Compares two vectors and returns true if all components of lhs are less than or equal to rhs.

    Performs lhs.x <= rhs.x && lhs.y <= rhs.y && lhs.z <= rhs.z && lhs.w <= rhs.w

    Declaration

    Swift

    public static func <= (lhs: `Self`, rhs: `Self`) -> Bool

Available where Scalar: AdditiveArithmetic

  • A zero-value Vector4 value where each component corresponds to its representation of 0.

    Declaration

    Swift

    public static var zero: `Self` { get }
  • Declaration

    Swift

    @inlinable
    public var nonZeroScalarCount: Int { get }
  • Declaration

    Swift

    public static func + (lhs: `Self`, rhs: `Self`) -> Vector4<Scalar>
  • Declaration

    Swift

    public static func - (lhs: `Self`, rhs: `Self`) -> Vector4<Scalar>
  • Declaration

    Swift

    public static func + (lhs: `Self`, rhs: Scalar) -> Vector4<Scalar>
  • Declaration

    Swift

    public static func - (lhs: `Self`, rhs: Scalar) -> Vector4<Scalar>

Available where Scalar: Numeric

  • one

    A unit-value Vector4Type value where each component corresponds to its representation of 4.

    Declaration

    Swift

    public static var one: `Self` { get }
  • Calculates the dot product between this and another provided Vector4Type

    Declaration

    Swift

    public func dot(_ other: `Self`) -> Scalar
  • Declaration

    Swift

    public static func * (lhs: `Self`, rhs: `Self`) -> Vector4<Scalar>
  • Declaration

    Swift

    public static func * (lhs: `Self`, rhs: Scalar) -> Vector4<Scalar>
  • Declaration

    Swift

    public static func * (lhs: Scalar, rhs: `Self`) -> Vector4<Scalar>

Available where Scalar: SignedNumeric & Comparable

  • Returns a Vector4 where each component is the absolute value of the components of this Vector4.

    Declaration

    Swift

    public var absolute: `Self` { get }
  • Declaration

    Swift

    public var sign: `Self` { get }
  • Negates this Vector

    Declaration

    Swift

    public prefix static func - (lhs: `Self`) -> Vector4<Scalar>

Available where Scalar: DivisibleArithmetic

  • Declaration

    Swift

    public static func / (lhs: `Self`, rhs: `Self`) -> Vector4<Scalar>
  • Declaration

    Swift

    public static func / (lhs: `Self`, rhs: Scalar) -> Vector4<Scalar>
  • Declaration

    Swift

    public static func / (lhs: Scalar, rhs: `Self`) -> Vector4<Scalar>

Available where Scalar: DivisibleArithmetic & FloatingPoint

  • Returns the result of adding the product of the two given vectors to this vector, computed without intermediate rounding.

    This method is equivalent to calling C fma function on each component.

    Declaration

    Swift

    public func addingProduct(_ a: `Self`, _ b: `Self`) -> Vector4<Scalar>

    Parameters

    lhs

    One of the vectors to multiply before adding to this vector.

    rhs

    The other vector to multiply.

    Return Value

    The product of lhs and rhs, added to this vector.

  • Returns the result of adding the product of the given scalar and vector to this vector, computed without intermediate rounding.

    This method is equivalent to calling C fma function on each component.

    Declaration

    Swift

    public func addingProduct(_ a: Scalar, _ b: `Self`) -> Vector4<Scalar>

    Parameters

    lhs

    A scalar to multiply before adding to this vector.

    rhs

    A vector to multiply.

    Return Value

    The product of lhs and rhs, added to this vector.

  • Returns the result of adding the product of the given vector and scalar to this vector, computed without intermediate rounding.

    This method is equivalent to calling C fma function on each component.

    Declaration

    Swift

    public func addingProduct(_ a: `Self`, _ b: Scalar) -> Vector4<Scalar>

    Parameters

    lhs

    A vector to multiply before adding to this vector.

    rhs

    A scalar to multiply.

    Return Value

    The product of lhs and rhs, added to this vector.

  • Rounds the components of this Vector3Type using a given FloatingPointRoundingRule.

    Declaration

    Swift

    public func rounded(_ rule: FloatingPointRoundingRule) -> Vector4<Scalar>
  • Rounds the components of this Vector3Type using a given FloatingPointRoundingRule.toNearestOrAwayFromZero.

    Equivalent to calling C’s round() function on each component.

    Declaration

    Swift

    public func rounded() -> Vector4<Scalar>
  • Rounds the components of this Vector3Type using a given FloatingPointRoundingRule.up.

    Equivalent to calling C’s ceil() function on each component.

    Declaration

    Swift

    public func ceil() -> Vector4<Scalar>
  • Rounds the components of this Vector3Type using a given FloatingPointRoundingRule.down.

    Equivalent to calling C’s floor() function on each component.

    Declaration

    Swift

    public func floor() -> Vector4<Scalar>
  • Declaration

    Swift

    public static func % (lhs: `Self`, rhs: `Self`) -> Vector4<Scalar>
  • Declaration

    Swift

    public static func % (lhs: `Self`, rhs: Scalar) -> Vector4<Scalar>
  • Declaration

    Swift

    public func signedDistance(to other: `Self`) -> Scalar
  • Declaration

    Swift

    public init<V>(_ vec: V) where V : Vector4Type, V.Scalar : BinaryInteger

Available where Scalar: DivisibleArithmetic & Real

  • Declaration

    Swift

    public static func pow(_ vec: `Self`, _ exponent: Int) -> Vector4<Scalar>
  • Declaration

    Swift

    public static func pow(_ vec: `Self`, _ exponent: `Self`) -> Vector4<Scalar>