Vector4Type

public protocol Vector4Type : VectorTakeable where Self.TakeDimensions == Vector4TakeDimensions

Protocol for types that can represent 4D vectors.

  • Undocumented

    Declaration

    Swift

    associatedtype SubVector4 = Self
  • x

    The X coordinate of this 4D vector.

    Declaration

    Swift

    var x: Scalar { get set }
  • y

    The Y coordinate of this 4D vector.

    Declaration

    Swift

    var y: Scalar { get set }
  • z

    The Z coordinate of this 4D vector.

    Declaration

    Swift

    var z: Scalar { get set }
  • w

    The W coordinate of this 4D vector.

    Declaration

    Swift

    var w: Scalar { get set }
  • Initializes this vector type with the given coordinates.

    Declaration

    Swift

    init(x: Scalar, y: Scalar, z: Scalar, w: Scalar)
  • init(_:z:w:) Default implementation

    Creates a new vector with the coordinates of a given Vector3Type, along with a new value for the z and w axis.

    Default Implementation

    Declaration

    Swift

    init<V>(_ vec: V, z: Scalar, w: Scalar) where V : Vector2Type, Self.Scalar == V.Scalar
  • init(_:w:) Default implementation

    Creates a new vector with the coordinates of a given Vector3Type, along with a new value for the w axis.

    Default Implementation

    Declaration

    Swift

    init<V>(_ vec: V, w: Scalar) where V : Vector3Type, Self.Scalar == V.Scalar
  • init(_:) Default implementation

    Initializes a new instance of this Vector4Type type by copying the coordinates of another Vector4Type of matching scalar type.

    Default Implementation

    Declaration

    Swift

    init<Vector>(_ vector: Vector) where Vector : Vector4Type, Self.Scalar == Vector.Scalar
  • scalarCount Extension method

    The number of scalars in the vector.

    For 4D vectors, this value is always 4.

    Declaration

    Swift

    var scalarCount: Int { get }
  • subscript(_:) Extension method

    Accesses the scalar at the specified position.

    • index 0: x
    • index 1: y
    • index 2: z
    • index 3: w

    Precondition

    index >= 0 && index < 4

    Declaration

    Swift

    @inlinable
    subscript(index: Int) -> Scalar { get set }

Available where Self: VectorComparable

  • maximalComponentIndex Extension method

    Returns the index of the component of this vector that has the greatest value.

    Vector4D(x: -3.0, y: 2.5, z: 0, w: 3).maximalComponentIndex // Returns 3
    

    Declaration

    Swift

    var maximalComponentIndex: Int { get }
  • minimalComponentIndex Extension method

    Returns the index of the component of this vector that has the least value.

    Vector4D(x: -3.0, y: 2.5, z: 0, w: 2).minimalComponentIndex // Returns 0
    

    Declaration

    Swift

    var minimalComponentIndex: Int { get }
  • maximalComponent Extension method

    Returns the greatest scalar component between x, y, z, and w in this vector

    Vector3D(x: -3.0, y: 2.5, z: 0, w: 3).maximalComponent // Returns 3
    

    Declaration

    Swift

    var maximalComponent: Scalar { get }
  • minimalComponent Extension method

    Returns the least scalar component between x, y, z, and w in this vector

    Vector4D(x: -3.0, y: 2.5, z: 0, w: 0).minimalComponent // Returns -3.0
    

    Declaration

    Swift

    var minimalComponent: Scalar { get }