Vector
public struct Vector : Hashable
A structure that contains a two-dimensional vector.
-
The vector whose components are both zero.
Declaration
Swift
public static let zero: Vector -
The x component of the vector.
Declaration
Swift
public var dx: Float -
The y component of the vector.
Declaration
Swift
public var dy: Float -
Creates a vector with components specified as floating-point values.
Declaration
Swift
@inlinable public init(dx: Float, dy: Float)Parameters
dxThe x component of the vector.
dyThe y component of the vector.
-
Creates a vector with components specified as integer values.
Declaration
Swift
@inlinable public init(dx: Int, dy: Int)Parameters
xThe x-coordinate of the point.
yThe y-coordinate of the point.
-
Returns the given vector unchanged.
You can use the unary plus operator (+) to provide symmetry in your code.
Declaration
Swift
@inlinable public prefix static func + (x: Vector) -> VectorParameters
xA vector.
Return Value
The given argument without any changes.
-
Returns the inverse of the specified vector.
Declaration
Swift
@inlinable public prefix static func - (x: Vector) -> VectorParameters
xA vector.
Return Value
The inverse of this vector.
-
Adds two vectors and produces their sum vector.
Declaration
Swift
@inlinable public static func + (lhs: Vector, rhs: Vector) -> VectorParameters
lhsThe first vector to add.
rhsThe second vector to add.
Return Value
The sum vector.
-
Subtracts one value from another and produces their difference vector.
Declaration
Swift
@inlinable public static func - (lhs: Vector, rhs: Vector) -> VectorParameters
lhsA vector.
rhsThe vector to subtract from
lhs.Return Value
The difference vector.
-
Multiplies a vector by a floating-point scalar value.
Declaration
Swift
@inlinable public static func * (lhs: Vector, rhs: Float) -> VectorParameters
lhsA vector.
rhsA floating-point scalar value.
Return Value
The scaled vector.
-
Multiplies a vector by an integer scalar value.
Declaration
Swift
@inlinable public static func * (lhs: Vector, rhs: Int) -> VectorParameters
lhsA vector.
rhsAn integer scalar value.
Return Value
The scaled vector.
-
Multiplies a vector by a floating-point scalar value.
Declaration
Swift
@inlinable public static func * (lhs: Float, rhs: Vector) -> VectorParameters
lhsA floating-point scalar value.
rhsA vector.
Return Value
The scaled vector.
-
Multiplies a vector by an integer scalar value.
Declaration
Swift
@inlinable public static func * (lhs: Int, rhs: Vector) -> VectorParameters
lhsAn integer scalar value.
rhsA vector.
Return Value
The scaled vector.
-
Declaration
Swift
public var debugDescription: String { get }
View on GitHub
Vector Structure Reference