       @_findT(target, guess - error / 2);
 
   # adapted from: https://github.com/DmitryBaranovskiy/raphael/blob/c47c077368c1113e1ed653376415961749de5466/dev/raphael.core.js
-  ###
-  Computes the length at position t of the curve.
-  @param {number} t The portion of the curve to consider. The curve starts at t=0 and ends at t=1.
-  @returns {number} the length value.
-  ###
   lengthAt: (t = 1) ->
+    ###
+    Computes the length at position t of the curve.
+
+    * t: Number. The portion of the curve to consider. The curve starts at t=0 and ends at t=1.
+    * Returns number, the length value.
+    ###
     t = if t > 1 then 1 else if t < 0 then 0 else t
     t2 = t / 2
 

###
@brief Bezier curve and spline plugin for D3.

Credits:
Function to create control points of a Bezier Spline: https://www.particleincell.com
Function to compute the length of a Bezier Curve: https://github.com/DmitryBaranovskiy/raphael

@author Zach Young <zach.young@gmail.com>
@license http://en.wikipedia.org/wiki/MIT_License MIT License
###

###
Utility function for array zip.
###
zip = () ->
  lengthArray = (arr.length for arr in arguments)
  length = Math.min(lengthArray...)
  for i in [0...length]
    arr[i] for arr in arguments

###
Produces a list of pairs of adjacent items in an array.
###
pairs = (xs) -> ([x, xs[i+1]] for x, i in xs[...-1])

###
Utility function for defining object property getter.
###
Function::getter = (prop, get) ->
  Object.defineProperty @prototype, prop, {get, configurable: yes}

###
Utility function for defining object property setter.
###
Function::setter = (prop, set) ->
  Object.defineProperty @prototype, prop, {set, configurable: yes}

###
A Point object represents a location in space or a vector.
###
class Point
  ###
  @param {number} x The x coordinate
  @param {number} y The y coordinate
  ###
  constructor: (@x, @y) ->

###
A BezierCurve represents one segment of a spline.
###
class BezierCurve
  @_base3 = (t, p1, p2, p3, p4) ->
    t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4
    t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3
    return t * t2 - 3 * p1 + 3 * p2;

  ###
  @param {point} p0 start point
  @param {point} p1 control point 1
  @param {point} p2 control point 2
  @param {point} p3 end point
  @property {number} length The full length of the curve
  ###
  constructor: (@p0, @p1, @p2, @p3) ->

  _findT: (target, guess) ->
    target = Math.min(target, @length)


      c

  constructor: (knots, closed) ->
    ###

    * knots: Point[]. Array of points that the spline passes through. A curve is generated connecting each knot point to the next.
    * closed: Boolean. Default false. Indicates that the spline should connect its end point back to its start point, making a loop.
    ###
    @closed = closed;
    @curves = BezierSpline.computeBezierSpline(knots.map((p) -> p.x), knots.map((p) -> p.y), closed);
    @startLengths = (c.startLength for c in @curves)
