VectorFloatingPoint

public protocol VectorFloatingPoint : VectorComparable, VectorDivisible, VectorSigned where Self.Scalar : FloatingPoint

Protocol for vector types where the components are floating-point numbers

  • length Default implementation

    Returns the Euclidean norm (square root of the squared length), or magnitude, of this VectorFloatingPoint.

    Default Implementation

    Returns the Euclidean norm (square root of the squared length), or magnitude, of this VectorFloatingPoint.

    Declaration

    Swift

    var length: Scalar { get }
  • normalize() Default implementation

    Normalizes this Vector.

    Returns Vector.zero, if the vector has length == 0.

    Default Implementation

    Normalizes this Vector.

    Returns Vector.zero, if the vector has length == 0.

    Declaration

    Swift

    mutating func normalize()
  • normalized() Default implementation

    Returns a normalized version of this Vector.

    Returns Vector.zero if the vector has length == 0.

    Default Implementation

    Returns a normalized version of this vector.

    Returns Vector2.zero if the vector has length == 0.

    Declaration

    Swift

    func normalized() -> Self
  • distance(to:) Default implementation

    Returns the distance between this VectorFloatingPoint and another VectorFloatingPoint.

    Default Implementation

    Returns the distance between this VectorFloatingPoint and another VectorFloatingPoint.

    Declaration

    Swift

    func distance(to vec: Self) -> Scalar
  • 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

    func addingProduct(_ a: Self, _ b: Self) -> Self

    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

    func addingProduct(_ a: Scalar, _ b: Self) -> Self

    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

    func addingProduct(_ a: Self, _ b: Scalar) -> Self

    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 VectorType using a given FloatingPointRoundingRule.

    Declaration

    Swift

    func rounded(_ rule: FloatingPointRoundingRule) -> Self
  • rounded() Default implementation

    Rounds the components of this VectorType using a given FloatingPointRoundingRule.toNearestOrAwayFromZero.

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

    Default Implementation

    Rounds the components of this VectorFloatingPoint using a given FloatingPointRoundingRule.toNearestOrAwayFromZero.

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

    Declaration

    Swift

    func rounded() -> Self
  • ceil() Default implementation

    Rounds the components of this VectorType using a given FloatingPointRoundingRule.up.

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

    Default Implementation

    Rounds the components of this VectorFloatingPoint using a given FloatingPointRoundingRule.up.

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

    Declaration

    Swift

    func ceil() -> Self
  • floor() Default implementation

    Rounds the components of this VectorType using a given FloatingPointRoundingRule.down.

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

    Default Implementation

    Rounds the components of this VectorFloatingPoint using a given FloatingPointRoundingRule.down.

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

    Declaration

    Swift

    func floor() -> Self
  • Undocumented

    Declaration

    Swift

    static func % (lhs: Self, rhs: Self) -> Self
  • Undocumented

    Declaration

    Swift

    static func % (lhs: Self, rhs: Scalar) -> Self