VectorTakeable
public protocol VectorTakeable : VectorType
Protocol that vector types conform to to indicate that different combinations of their dimensions can be extracted into other known N-dimensional vector types.
-
The 2-dimensional vector type for selections of 2-components on this vector.
Declaration
Swift
associatedtype SubVector2 : Vector2Type = Vector2<Self.Scalar> where Self.Scalar == Self.SubVector2.Scalar, Self.SubVector2.Scalar == Self.SubVector3.Scalar
-
The 3-dimensional vector type for selections of 3-components on this vector.
Declaration
Swift
associatedtype SubVector3 : Vector3Type = Vector3<Self.Scalar> where Self.SubVector3.Scalar == Self.SubVector4.Scalar
-
The 4-dimensional vector type for selections of 4-components on this vector.
Declaration
Swift
associatedtype SubVector4 : Vector4Type = Vector4<Self.Scalar>
-
A named indexer into the dimensions of this vector.
Declaration
Swift
associatedtype TakeDimensions : RawRepresentable where Self.TakeDimensions.RawValue == Int
-
subscript(_:
Default implementation_: ) Takes a new 2D vector from a combination of two of the provided dimensions of this vector.
let vector = Vector3D(x: 3.5, y: 2.1, z: 1.0) print(vector[.x, .z]) // Prints "(x: 3.5, y: 1.0)" print(vector[.z, .y]) // Prints "(x: 1.0, y: 2.1)"
Default Implementation
Declaration
Swift
subscript(x: TakeDimensions, y: TakeDimensions) -> SubVector2 { get }
-
subscript(_:
Default implementation_: _: ) Takes a new 3D vector from a combination of two of the provided dimensions of this vector.
let vector = Vector3D(x: 3.5, y: 2.1, z: 1.0) print(vector[.x, .z, .y]) // Prints "(x: 3.5, y: 1.0, z: 2.1)" print(vector[.z, .y, .x]) // Prints "(x: 1.0, y: 2.1, x: 3.5)"
Default Implementation
Declaration
Swift
subscript(x: TakeDimensions, y: TakeDimensions, z: TakeDimensions) -> SubVector3 { get }
-
subscript(_:
Default implementation_: _: _: ) Takes a new 4D vector from a combination of two of the provided dimensions of this vector.
let vector = Vector3D(x: 3.5, y: 2.1, z: 1.0) print(vector[.x, .z, .y, .z]) // Prints "(x: 3.5, y: 1.0, z: 2.1, w: 2.1)" print(vector[.z, .y, .x, .z]) // Prints "(x: 1.0, y: 2.1, x: 3.5, w: 1.0)"
Default Implementation
Declaration
Swift
subscript(x: TakeDimensions, y: TakeDimensions, z: TakeDimensions, w: TakeDimensions) -> SubVector4 { get }