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