VectorFloatingPoint
public protocol VectorFloatingPoint : VectorComparable, VectorDivisible, VectorSigned where Self.Scalar : FloatingPoint
Protocol for vector types where the components are floating-point numbers
-
lengthDefault implementationReturns 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 implementationNormalizes this
Vector.Returns
Vector.zero, if the vector haslength == 0.Default Implementation
Normalizes this
Vector.Returns
Vector.zero, if the vector haslength == 0.Declaration
Swift
mutating func normalize() -
normalized()Default implementationReturns a normalized version of this
Vector.Returns
Vector.zeroif the vector haslength == 0.Default Implementation
Returns a normalized version of this vector.
Returns
Vector2.zeroif the vector haslength == 0.Declaration
Swift
func normalized() -> Self -
distance(to:Default implementation) Returns the distance between this
VectorFloatingPointand anotherVectorFloatingPoint.Default Implementation
Returns the distance between this
VectorFloatingPointand anotherVectorFloatingPoint.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
fmafunction on each component.Declaration
Swift
func addingProduct(_ a: Self, _ b: Self) -> SelfParameters
lhsOne of the vectors to multiply before adding to this vector.
rhsThe other vector to multiply.
Return Value
The product of
lhsandrhs, 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
fmafunction on each component.Declaration
Swift
func addingProduct(_ a: Scalar, _ b: Self) -> SelfParameters
lhsA scalar to multiply before adding to this vector.
rhsA vector to multiply.
Return Value
The product of
lhsandrhs, 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
fmafunction on each component.Declaration
Swift
func addingProduct(_ a: Self, _ b: Scalar) -> SelfParameters
lhsA vector to multiply before adding to this vector.
rhsA scalar to multiply.
Return Value
The product of
lhsandrhs, added to this vector. -
Rounds the components of this
VectorTypeusing a givenFloatingPointRoundingRule.Declaration
Swift
func rounded(_ rule: FloatingPointRoundingRule) -> Self -
rounded()Default implementationRounds the components of this
VectorTypeusing a givenFloatingPointRoundingRule.toNearestOrAwayFromZero.Equivalent to calling C’s round() function on each component.
Default Implementation
Rounds the components of this
VectorFloatingPointusing a givenFloatingPointRoundingRule.toNearestOrAwayFromZero.Equivalent to calling C’s round() function on each component.
Declaration
Swift
func rounded() -> Self -
ceil()Default implementationRounds the components of this
VectorTypeusing a givenFloatingPointRoundingRule.up.Equivalent to calling C’s ceil() function on each component.
Default Implementation
Rounds the components of this
VectorFloatingPointusing a givenFloatingPointRoundingRule.up.Equivalent to calling C’s ceil() function on each component.
Declaration
Swift
func ceil() -> Self -
floor()Default implementationRounds the components of this
VectorTypeusing a givenFloatingPointRoundingRule.down.Equivalent to calling C’s floor() function on each component.
Default Implementation
Rounds the components of this
VectorFloatingPointusing a givenFloatingPointRoundingRule.down.Equivalent to calling C’s floor() function on each component.
Declaration
Swift
func floor() -> Self -
Declaration
Swift
static func % (lhs: Self, rhs: Self) -> Self -
Declaration
Swift
static func % (lhs: Self, rhs: Scalar) -> Self