Point

public struct Point
extension Point: Additive
extension Point: Equatable
extension Point: Hashable
extension Point: CustomStringConvertible

Representation of a point.

Instance Properties

  • x

    Horizontal position.

    Declaration

    Swift

    public let x: Double
  • y

    Vertical position.

    Declaration

    Swift

    public let y: Double

Initializers

  • Creates a Point with the given x and y values.

    Declaration

    Swift

    public init(x: Double = 0, y: Double = 0)

Instance Methods

  • Declaration

    Swift

    public func distance(to other: Point) -> Double

    Return Value

    The distance to the given other point.

  • Declaration

    Swift

    public func translatedBy(x ΔX: Double = 0, y ΔY: Double = 0) -> Point

    Return Value

    Point translated by the given x and y values.

  • Declaration

    Swift

    public func translated(by point: Point) -> Point

    Return Value

    Point translated by the given point.

  • Declaration

    Swift

    public func scaled(by amount: Double, from reference: Point = Point()) -> Point

    Return Value

    Point scaled by the given amount from the given reference point.

  • Declaration

    Swift

    public func rotated(by angle: Angle, around reference: Point = Point()) -> Point

    Return Value

    Point rotated by the given angle around the given reference point.

  • Declaration

    Swift

    public func reflected(over line: Line) -> Point

    Return Value

    Point reflected over the given line.

Additive

  • Additive identity.

    Declaration

    Swift

    public static var zero: Point { get }

Point Arithmetic

  • Declaration

    Swift

    public subscript(axis: Axis) -> Double { get }

    Return Value

    The value contained herein for the given axis.

  • Declaration

    Swift

    public static func + (lhs: Point, rhs: Point) -> Point

    Return Value

    Point value containing sums of their respective x- and y-values.

  • Declaration

    Swift

    public static func - (lhs: Point, rhs: Point) -> Point

    Return Value

    Point value containing differences of their respective x- and y-values.

CustomStringConvertible

  • Printed description.

    Declaration

    Swift

    public var description: String { get }
  • Undocumented

    Declaration

    Swift

    public typealias Triple = (Point, Point, Point)