Point

public struct Point : Hashable

Represents a geometrical point. Implements the Hashable protocol.

  • Initializes a new point with zero coordinates.

    Declaration

    Swift

    public init()

    Return Value

    The newly created point.

  • Initializes a new point with the specified coordinates.

    Declaration

    Swift

    public init(x: Double, y: Double)

    Parameters

    x

    The x-coordinate of the new point.

    y

    The y-coordinate of the new point.

    Return Value

    The newly created point.

  • Initializes a new point from the specified point.

    Declaration

    Swift

    public init(p: Point)

    Parameters

    p

    The point whose coordinates are set to the new point.

    Return Value

    The newly created point.

  • Initializes a new point from the specified CGPoint point.

    Declaration

    Swift

    public init(p: CGPoint)

    Parameters

    p

    The CGPoint point whose coordinates are set to the new point.

    Return Value

    The newly created point.

  • Calculates the distance between this point and the specified point.

    Declaration

    Swift

    public func distance(_ p: Point) -> Double

    Parameters

    p

    The point to which the distance is measured.

    Return Value

    The distance.

  • Calculates the squared distance between this point and the specified point.

    Declaration

    Swift

    public func distanceSquared(_ p: Point) -> Double

    Parameters

    p

    The point to which the distance is measured.

    Return Value

    The squared distance.

  • Calculates the point at the middle of the line between this point and the specified point.

    Declaration

    Swift

    public func middle(_ p: Point) -> Point

    Parameters

    p

    The end point of the line at which the middle point is calculated.

    Return Value

    The middle point.

  • Calculates if the coordinates of this point and the specified point equal epsilon.

    Declaration

    Swift

    public func equalEpsilon(_ p: Point) -> Bool

    Parameters

    p

    The other point whose coordinates are taken by the comparison.

    Return Value

    true if the x-coordinates of the both points and the y-coordinates of both points equal epsilon.

  • Parses the x and y coordinates of a point from strings.

    Declaration

    Swift

    public static func fromString(_ s: String) -> Point

    Parameters

    s

    The string to parse.

    Return Value

    A point with coordinates parsed from the string.

  • Specifies an empty point.

    Declaration

    Swift

    public static let empty: Point
  • x

    Specifies the X-coordinate of the Point.

    Declaration

    Swift

    public var x: Double
  • y

    Specifies the Y-coordinate of the Point.

    Declaration

    Swift

    public var y: Double