Point

public struct Point: Equatable, CustomStringConvertible

A structure that contains a point in a two-dimensional coordinate system.

  • x

    The x value of the coordinate.

    Declaration

    Swift

    public var x: Double = 0
  • y

    The y value of the coordinate.

    Declaration

    Swift

    public var y: Double = 0
  • Initializes a new point with the coordinates {0,0}

    let p = Point()
    

    Declaration

    Swift

    public init()
  • Initializes a new point with the specified coordinates {x,y}

    let p = Point(10.5,10.5)
    

    Declaration

    Swift

    public init(_ x: Double, _ y: Double)

    Parameters

    x

    a Double value

    y

    a Double value

  • Initializes a new point with the specified coordinates {x,y}, converting integer values to doubles

    let p = Point(10,10)
    

    Declaration

    Swift

    public init(_ x: Int, _ y: Int)
  • Initializes a Point initialized with a CGPoint.

    Declaration

    Swift

    public init(_ point: CGPoint)

    Parameters

    point

    a previously initialized CGPoint

  • Returns true if the point’s coordinates are {0,0}, otherwise returns false

    Declaration

    Swift

    public func isZero() -> Bool
  • Transforms the point.

    var p = Point(10,10)
    let v = Vector(x: 0, y: 0, z: 1)
    let t = Transform.makeRotation(M_PI, axis: v)
    p.transform(t) // -> {-10.0, -10.0}
    

    Declaration

    Swift

    public mutating func transform(t: Transform)

    Parameters

    t

    A Transform to apply to the point

  • A string representation of the point.

    let p = Point()
    println(p)
    

    Declaration

    Swift

    public var description: String

    Return Value

    A string formatted to look like {x,y}