Vector2Multiplicative

public protocol Vector2Multiplicative : Vector2Additive, VectorMultiplicative where Self.SubVector3 : Vector3Multiplicative

Protocol for 2D vector types with multiplicable scalars.

  • unitX Default implementation

    Gets the (x: 1, y: 0) vector of this type.

    Default Implementation

    Gets the (x: 1, y: 0) vector of this type.

    Declaration

    Swift

    static var unitX: Self { get }
  • unitY Default implementation

    Gets the (x: 0, y: 1) vector of this type.

    Default Implementation

    Gets the (x: 0, y: 1) vector of this type.

    Declaration

    Swift

    static var unitY: Self { get }
  • cross(_:) Default implementation

    Calculates the cross product between this and another provided Vector. The resulting scalar would match the ‘z’ axis of the cross product between 3d vectors matching the x and y coordinates of the operands, with the ‘z’ coordinate being 0.

    Also called perp-dot product, as it equates to taking the dot product of self • other.perpendicular. Provided in Vector2Multiplicative as a convenience, as the protocol constraints are more lax than Vector2Signed.

    Default Implementation

    Declaration

    Swift

    func cross(_ other: Self) -> Scalar
  • tripleProduct(_:_:) Default implementation

    Performs a 2D vector triple product between self, b, and c: a x (b x c).

    Can be used to derive a vector perpendicular to ab, such that it points in the direction of ac.

    Default Implementation

    Declaration

    Swift

    func tripleProduct(_ b: Self, _ c: Self) -> Self