Skip to content

Points

Points live in a Cartesian coordinate system with Real or Unitful.Length coordinates:

julia> Point(1,1)
2-element Point{Int64}:
 1
 1

julia> Point(1.0,1.0)
2-element Point{Float64}:
 1.0
 1.0

julia> Point(1.0u"μm", 1.0u"μm")
2-element Point{Unitful.Quantity{Float64,Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)},Unitful.FreeUnits{(Unitful.Unit{:Meter,Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)}}(-6, 1//1),),Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)}}}}:
 1.0 μm
 1.0 μm

If a point has Real coordinates, the absence of a unit is interpreted to mean μm whenever the geometry is saved to a GDS format, but until then it is just considered to be a pure number. Therefore you cannot mix and match Real and Length coordinates:

julia> Point(1.0u"μm", 1.0)
ERROR: Cannot use `Point` with this combination of types.

You can add Points together or scale them:

julia> 3*Point(1,1)+Point(1,2)
2-element Point{Int64}:
 4
 5

You can also do affine transformations by composing any number of Translation and Rotations, which will return a callable object representing the transformation. You can type the following Unicode symbols with \degree and \circ tab-completions in the Julia REPL or using the Atom package latex-completions.

julia> aff = Rotation(90°) ∘ Translation(Point(1,2))
AffineMap([0.0 -1.0; 1.0 0.0], (-2.0,1.0))

julia> aff(Point(0,0))
2-element Point{Float64}:
 -2.0
  1.0

API

# Devices.PointTypesConstant.

PointTypes = Union{Real, DimensionlessQuantity, Length, InverseLength}

Allowed type variables for Point{T} types.

source

# Devices.CoordinateConstant.

Coordinate = Union{Real, Length}

Type alias for numeric types suitable for coordinate systems.

source

# Devices.Points.PointType.

struct Point{T} <: StaticArrays.FieldVector{2,T}
    x::T
    y::T
end

2D Cartesian coordinate in the plane.

source

# Devices.Points.getxFunction.

getx(p::Point)

Get the x-coordinate of a point. You can also use p.x or p[1].

source

# Devices.Points.getyFunction.

gety(p::Point)

Get the y-coordinate of a point. You can also use p.y or p[2].

source

# Devices.lowerleftFunction.

lowerleft{T}(A::AbstractArray{Point{T}})

Returns the lower-left Point of the smallest bounding rectangle (with sides parallel to the x- and y-axes) that contains all points in A.

Example:

julia> lowerleft([Point(2,0),Point(1,1),Point(0,2),Point(-1,3)])
2-element Point{Int64}:
 -1
  0

source

lowerleft(r::Rectangle)

Returns the lower-left corner of a rectangle (Point object).

source

lowerleft(x::Polygon)

Return the lower-left-most corner of a rectangle bounding polygon x. Note that this point doesn't have to be in the polygon.

source

# Devices.upperrightFunction.

upperright{T}(A::AbstractArray{Point{T}})

Returns the upper-right Point of the smallest bounding rectangle (with sides parallel to the x- and y-axes) that contains all points in A.

Example:

julia> upperright([Point(2,0),Point(1,1),Point(0,2),Point(-1,3)])
2-element Point{Int64}:
 2
 3

source

upperright(r::Rectangle)

Returns the upper-right corner of a rectangle (Point object).

source

upperright(x::Polygon)

Return the upper-right-most corner of a rectangle bounding polygon x. Note that this point doesn't have to be in the polygon.

source

Implementation details

Points are implemented using the abstract type FieldVector from StaticArrays.jl. This permits a fast, efficient representation of coordinates in the plane. Additionally, unlike Tuple objects, we can add points together, simplifying many function definitions.