ninis.js
function findClosestPointOnSpecialAttractor(x,y) {
  var nSpecialAttractor = specialAttractors.length;
  var currentMinDistance = 0;
  var currentSpecialAttractor;
  var ox = 0;
  var oy = 0;
  for(var a=0; a<nSpecialAttractor; a++) {
    var specialAttractor = specialAttractors[a];
    var closestSegmentPoint = distanceToSegment(specialAttractor.x1, specialAttractor.y1, specialAttractor.x2, specialAttractor.y2, x, y);
    if(a == 0 || (closestSegmentPoint.distance) < currentMinDistance) {
      currentMinDistance = closestSegmentPoint.distance;
      currentSpecialAttractor = specialAttractor;
      ox = closestSegmentPoint.originX;
      oy = closestSegmentPoint.originY;
    }
  }
  return {
    distance: currentMinDistance,
    specialAttractor: currentSpecialAttractor,
    originX: ox,
    originY: oy
  }
}
function findClosestPointOnSpecialAttractor(x,y) {
  var nSpecialAttractor = specialAttractors.length;
  var currentMinDistance = 0;
  var currentSpecialAttractor;
  var ox = 0;
  var oy = 0;
  for(var a=0; a<nSpecialAttractor; a++) {
    var specialAttractor = specialAttractors[a];
    var closestSegmentPoint = distanceToSegment(specialAttractor.x1, specialAttractor.y1, specialAttractor.x2, specialAttractor.y2, x, y);
    if(a == 0 || (closestSegmentPoint.distance) < currentMinDistance) {
      currentMinDistance = closestSegmentPoint.distance;
      currentSpecialAttractor = specialAttractor;
      ox = closestSegmentPoint.originX;
      oy = closestSegmentPoint.originY;
    }
  }
  return {
    distance: currentMinDistance,
    specialAttractor: currentSpecialAttractor,
    originX: ox,
    originY: oy
  }
}
function findClosestPointOnSpecialAttractor ( x , y ) { var nSpecialAttractor = specialAttractors . length ; var currentMinDistance = 0 ; var currentSpecialAttractor ; var ox = 0 ; var oy = 0 ; for ( var a = 0 ; a < nSpecialAttractor ; a ++ ) { var specialAttractor = specialAttractors [ a ] ; var closestSegmentPoint = distanceToSegment ( specialAttractor . x1 , specialAttractor . y1 , specialAttractor . x2 , specialAttractor . y2 , x , y ) ; if ( a == 0 || ( closestSegmentPoint . distance ) < currentMinDistance ) { currentMinDistance = closestSegmentPoint . distance ; currentSpecialAttractor = specialAttractor ; ox = closestSegmentPoint . originX ; oy = closestSegmentPoint . originY ; } } return { distance : currentMinDistance , specialAttractor : currentSpecialAttractor , originX : ox , originY : oy } }
Finds the closest point to any special attractor segment
Finds the closest point to any special attractor segment