Structure
DoublePoint
public struct DoublePoint : Equatable
A DoublePoint
represents a location in a two-dimensional plane.
Relationships
Conforms To
Equatable
Initializers
init()
public init()
Creates a new DoublePoint
located at (x:0, y:0)
init(x:y:)
public init(x:Double, y:Double)
Creates a new DoublePoint
from the specified coordinates
Parameters
Name | Type | Description |
---|---|---|
x | Double |
The x coordinate |
y | Double |
The y coordinate |
init(x:y:)
public init(x:Int, y:Int)
Creates a new DoublePoint
from the specified coordinates
Parameters
Name | Type | Description |
---|---|---|
x | Int |
The x coordinate |
y | Int |
The y coordinate |
init(_:)
public init(_ point:Point)
Creates a new DoublePoint
from the specified Point
Parameters
Name | Type | Description |
---|---|---|
point | Point |
The source of the x, y coordinates |
Properties
x
public var x : Double
The coordinate along the x-axis
y
public var y : Double
The coordinate along the y-axis
zero
static public let zero
The point (x:0.0, y:0.0)
Methods
distanceSquared(target:)
public func distanceSquared(target:DoublePoint) -> Double
Calculates the square of the distance between this point and another
Parameters
Name | Type | Description |
---|---|---|
target | DoublePoint |
The target point to which to calculate the distance |
Returns
The square of the distance to a target point
distance(target:)
public func distance(target:DoublePoint) -> Double
Calculates the distance between this point and another
Parameters
Name | Type | Description |
---|---|---|
target | DoublePoint |
The target point to which to calculate the distance |
Returns
The distance to a target point
DoublePoints(_:)
static public func DoublePoints(_ points: [Point]) -> [DoublePoint]
Converts an array of Point
s to an array of DoublePoint
s
Operators
==
static public func == (lhs:DoublePoint, rhs:DoublePoint) -> Bool
Equivalence operator for two DoublePoint
s
+
static public func + (left: DoublePoint, right: DoublePoint) -> DoublePoint
Addition operator for two DoublePoint
s
+=
static public func += (left: inout DoublePoint, right: DoublePoint)
Compound addition operator for two DoublePoint
s
-
static public prefix func - (doublePoint: DoublePoint) -> DoublePoint
Negation operator for a DoublePoint
-
static public func - (left: DoublePoint, right: DoublePoint) -> DoublePoint
Subtraction operator for two DoublePoint
s
-=
static public func -= (left: inout DoublePoint, right: DoublePoint)
Compound subtration operator for two DoublePoint
s