Vector3Base

public struct Vector3Base<VectorType> where VectorType : Addable

A 3-dimensional vector.

  • The number of components in a Vector3Base instance.

    Declaration

    Swift

    public static var numberOfComponents: Int { get }
  • The values of this vector.

    Declaration

    Swift

    public private(set) var components: [VectorType]
  • x

    The x coordinate of the vector (the first component).

    Declaration

    Swift

    public var x: VectorType { get set }
  • y

    The y coordinate of the vector (the second component).

    Declaration

    Swift

    public var y: VectorType { get set }
  • z

    The z coordinate of the vector (the third component).

    Declaration

    Swift

    public var z: VectorType { get set }
  • Initializes the zero vector.

    Declaration

    Swift

    public init()
  • Initializes a VectorBase with the given values.

    Declaration

    Swift

    public init(x: VectorType, y: VectorType, z: VectorType)

    Parameters

    x

    The first component of the vector.

    y

    The second component of the vector.

    z

    The third component of the vector.

  • Provides access to the underlying components of this instance.

    Declaration

    Swift

    public subscript(index: Int) -> VectorType { get set }

    Parameters

    index

    The index of the component to access.

    Return Value

    The component at the given index.

  • The color white.

    Declaration

    Swift

    public static var white: Vector3Base<Double> { get }
  • The color black.

    Declaration

    Swift

    public static var black: Vector3Base<Double> { get }
  • red

    The color red.

    Declaration

    Swift

    public static var red: Vector3Base<Double> { get }
  • The color green.

    Declaration

    Swift

    public static var green: Vector3Base<Double> { get }
  • The color blue.

    Declaration

    Swift

    public static var blue: Vector3Base<Double> { get }
  • The color yellow.

    Declaration

    Swift

    public static var yellow: Vector3Base<Double> { get }
  • The color magenta.

    Declaration

    Swift

    public static var magenta: Vector3Base<Double> { get }
  • The color cyan.

    Declaration

    Swift

    public static var cyan: Vector3Base<Double> { get }
  • The color purple.

    Declaration

    Swift

    public static var purple: Vector3Base<Double> { get }
  • The color brown.

    Declaration

    Swift

    public static var brown: Vector3Base<Double> { get }
  • The color orange.

    Declaration

    Swift

    public static var orange: Vector3Base<Double> { get }
  • The color gray.

    Declaration

    Swift

    public static var gray: Vector3Base<Double> { get }
  • The color light gray.

    Declaration

    Swift

    public static var lightGray: Vector3Base<Double> { get }
  • The color dark gray.

    Declaration

    Swift

    public static var darkGray: Vector3Base<Double> { get }
  • The color dark red.

    Declaration

    Swift

    public static var darkRed: Vector3Base<Double> { get }
  • The color dark green.

    Declaration

    Swift

    public static var darkGreen: Vector3Base<Double> { get }
  • The color dark blue.

    Declaration

    Swift

    public static var darkBlue: Vector3Base<Double> { get }
  • r

    The red component of the vector (equivalent to x).

    Declaration

    Swift

    public var r: VectorType { get set }
  • g

    The green component of the vector (equivalent to y).

    Declaration

    Swift

    public var g: VectorType { get set }
  • b

    The blue component of the vector (equivalent to z).

    Declaration

    Swift

    public var b: VectorType { get set }
  • red

    The red component of the vector (equivalent to r).

    Declaration

    Swift

    public var red: VectorType { get set }
  • The green component of the vector (equivalent to g).

    Declaration

    Swift

    public var green: VectorType { get set }
  • The blue component of the vector (equivalent to b).

    Declaration

    Swift

    public var blue: VectorType { get set }
  • The unit vector in the x direction.

    Declaration

    Swift

    public static var unitX: Vector3Base<VectorType> { get }
  • The unit vector in the y direction.

    Declaration

    Swift

    public static var unitY: Vector3Base<VectorType> { get }
  • The unit vector in the z direction.

    Declaration

    Swift

    public static var unitZ: Vector3Base<VectorType> { get }
  • Calculates the cross product of this vector and another vector.

    Declaration

    Swift

    public func cross(vector: Vector3Base) -> Vector3Base

    Parameters

    vector

    The vector with which to perform the cross product.

    Return Value

    The cross product. This is a vector perpendicular to self and vector with length ||self| * |vector| * sin(angle between self and vector)|.