ortho.js
function mergeSegment(row, x0, x1) {
    //Take left and right curves out of horizon
    var left = takeCurve(function(c) {
      return c[c.length-1][0] === x0
    })
    var right = takeCurve(function(c) {
      return c[0][0] === x1
    })

    //Create new vertices
    var p0 = [x0,row,vertices.length]
    var p1 = [x1,row,vertices.length+1]
    vertices.push([x0, row], [x1,row])

    //Merge chains
    var ncurve = []
    if(left) {
      var l1 = reflexLeft(left, p0, 0, left.length-1)
      for(var i=0; i<=l1; ++i) {
        ncurve.push(left[i])
      }
    }
    ncurve.push(p0, p1)
    if(right) {
      var r0 = reflexRight(right, p1, 0, right.length-1)
      for(var i=r0; i<right.length; ++i) {
        ncurve.push(right[i])
      }
    }

    //Append new chain to horizon
    horizon.push(ncurve)
  }
function mergeSegment(row, x0, x1) {
    //Take left and right curves out of horizon
    var left = takeCurve(function(c) {
      return c[c.length-1][0] === x0
    })
    var right = takeCurve(function(c) {
      return c[0][0] === x1
    })

    //Create new vertices
    var p0 = [x0,row,vertices.length]
    var p1 = [x1,row,vertices.length+1]
    vertices.push([x0, row], [x1,row])

    //Merge chains
    var ncurve = []
    if(left) {
      var l1 = reflexLeft(left, p0, 0, left.length-1)
      for(var i=0; i<=l1; ++i) {
        ncurve.push(left[i])
      }
    }
    ncurve.push(p0, p1)
    if(right) {
      var r0 = reflexRight(right, p1, 0, right.length-1)
      for(var i=r0; i<right.length; ++i) {
        ncurve.push(right[i])
      }
    }

    //Append new chain to horizon
    horizon.push(ncurve)
  }
function mergeSegment ( row , x0 , x1 ) { //Take left and right curves out of horizon var left = takeCurve ( function ( c ) { return c [ c . length - 1 ] [ 0 ] === x0 } ) var right = takeCurve ( function ( c ) { return c [ 0 ] [ 0 ] === x1 } ) //Create new vertices var p0 = [ x0 , row , vertices . length ] var p1 = [ x1 , row , vertices . length + 1 ] vertices . push ( [ x0 , row ] , [ x1 , row ] ) //Merge chains var ncurve = [ ] if ( left ) { var l1 = reflexLeft ( left , p0 , 0 , left . length - 1 ) for ( var i = 0 ; i <= l1 ; ++ i ) { ncurve . push ( left [ i ] ) } } ncurve . push ( p0 , p1 ) if ( right ) { var r0 = reflexRight ( right , p1 , 0 , right . length - 1 ) for ( var i = r0 ; i < right . length ; ++ i ) { ncurve . push ( right [ i ] ) } } //Append new chain to horizon horizon . push ( ncurve ) }
Insert new segment into horizon
Insert new segment into horizon