 
 # ----
 
-# The function `lift` computes the projection or 'lift' of a given
+# The function `lift` computes the projection or _lift_ of a given
 # point in the plane onto the standard parabola z = x * x + y * y.
 lift = (p) -> new Point3d p.x, p.y, p.x * p.x + p.y * p.y
 

# Computing Delaunay triangulations and stuff.
#
# Copyright (c) 2011 Olaf Delgado-Friedrichs

# ----



# ----

# The function `Triangulation` creates an _oriented_ abstract
# triangulation, i.e. one in which the vertices of each triangle are
# assigned one out of two possible circular orders. Whenever two
# triangles share an edge, we moreover require the orientations of
# these to 'match' in such a way that the induced orders on the pair
# of vertices defining the edge are exactly opposite.
#
# The triangulation is abstract in the sense that we do not impose any
# restrictions on the objects representing vertices.
#
# Most of the implementation details are hidden within a closure via
# the `do ->` construct.

triangulation = do ->
  # The helper function `seq` creates a sequence from its argument
  # list.
  seq = (args...) -> new Sequence args

  # We use a hidden class to encapsulate the implementation details.
  class Triangulation

    # The constructor takes a set of triangles and a map specifying
    # the associated third triangle vertex for any oriented edge that
    # is part of an oriented triangle.
    constructor: (@triangles = new HashSet(), @third = new HashMap()) ->

    # The method `plus` returns a triangulation with the given
    # triangle added unless it is already present or creates an
    # orientation mismatch. In the first case, the original
    # triangulation is returned without changes; in the second, an
    # exception is raised.
    plus: (a, b, c) ->


    # For a given oriented triangle specified by its three vertices,
    # the method `find` returns a canonical vertex order if the
    # triangle is included in this triangulation or else `null`.
    find: (a, b, c) ->
      seq(seq(a, b, c), seq(b, c, a), seq(c, a, b)).find @triangles.contains

  # Here we define our access point. The function `triangulation`
  # takes a list of triangles, each given as an array of three
  # abstract vertices.
  (args...) -> Sequence.reduce args, new Triangulation(), (t, x) -> t.plus x...


# ----

# We export the classes `Point2d` and `Point3d` and the functions
# `circumCircleCenter` and `inclusionInCircumCircle` for testing.

