VectorMultiplicative
public protocol VectorMultiplicative : VectorAdditive where Self.Scalar : Numeric
Protocol for Vectors that support multiplication
-
one
Default implementationA unit-value
VectorType
value where each component corresponds to its representation of1
.Default Implementation
A unit-value
VectorMultiplicative
value where each component corresponds to its representation of1
.Declaration
Swift
static var one: Self { get }
-
lengthSquared
Default implementationReturns the length squared of this
VectorType
.Performs the computation
x0 * x0 + x1 * x1 + ... + xN * xN
for any N-dimensional vector type, and is equivalent to the squared distance to the origin of the vector space, or thedot(_:)
product of the vector with itself.Default Implementation
Returns the length squared of this
VectorType
Declaration
Swift
var lengthSquared: Scalar { get }
-
distanceSquared(to:
Default implementation) Returns the squared distance between this
VectorType
and anotherVectorType
.Equivalent to
(vec - self).distanceSquared
.Default Implementation
Returns the squared distance between this
VectorType
and anotherVectorType
.Equivalent to
(vec - self).distanceSquared
.Declaration
Swift
func distanceSquared(to vec: Self) -> Scalar
-
Calculates the dot product between this vector and another.
Performs the computation
x1 * y1 + x2 * y2 + ... + xN + yN
for any N-dimensional vector type.let v1 = Vector2D(x: 3.0, y: -2.0) let v2 = Vector2D(x: 2.5, y: 7.0) print(v1.dot(v2)) // Prints "-6.5"
Declaration
Swift
func dot(_ other: Self) -> Scalar
-
lerp(start:
Default implementationend: amount: ) Performs a linear interpolation between two vectors.
Passing
amount
a value of 0 will causestart
to be returned; a value of 1 will causeend
to be returned.Default Implementation
Performs a linear interpolation between two points.
Passing
amount
a value of 0 will causestart
to be returned; a value of 1 will causeend
to be returned.Declaration
Swift
static func lerp(start: Self, end: Self, amount: Scalar) -> Self
Parameters
start
Start point.
end
End point.
amount
Value between 0 and 1 indicating the weight of
end
. -
Declaration
Swift
static func * (lhs: Self, rhs: Self) -> Self
-
Declaration
Swift
static func * (lhs: Self, rhs: Scalar) -> Self
-
Declaration
Swift
static func * (lhs: Scalar, rhs: Self) -> Self
-
*=(_:
Default implementation_: ) Default Implementation
Declaration
Swift
static func *= (lhs: inout Self, rhs: Self)
-
Declaration
Swift
static func *= (lhs: inout Self, rhs: Scalar)