protected List<PointFeature> clip(PointFeature v1,PointFeature v2,Vector2 n,double offset){
  List<PointFeature> points=new ArrayList<PointFeature>(2);
  Vector2 p1=v1.getPoint();
  Vector2 p2=v2.getPoint();
  double d1=n.dot(p1) - offset;
  double d2=n.dot(p2) - offset;
  if (d1 <= 0.0)   points.add(v1);
  if (d2 <= 0.0)   points.add(v2);
  if (d1 * d2 < 0.0) {
    Vector2 e=p1.to(p2);
    double u=d1 / (d1 - d2);
    e.multiply(u);
    e.add(p1);
    if (d1 > 0.0) {
      points.add(new PointFeature(e,v1.getIndex()));
    }
 else {
      points.add(new PointFeature(e,v2.getIndex()));
    }
  }
  return points;
}

protected List < PointFeature > clip ( PointFeature v1 , PointFeature v2 , Vector2 n , double offset ) { List < PointFeature > points = new ArrayList < PointFeature > ( 2 ) ; Vector2 p1 = v1 . getPoint ( ) ; Vector2 p2 = v2 . getPoint ( ) ; double d1 = n . dot ( p1 ) - offset ; double d2 = n . dot ( p2 ) - offset ; if ( d1 <= 0.0 ) points . add ( v1 ) ; if ( d2 <= 0.0 ) points . add ( v2 ) ; if ( d1 * d2 < 0.0 ) { Vector2 e = p1 . to ( p2 ) ; double u = d1 / ( d1 - d2 ) ; e . multiply ( u ) ; e . add ( p1 ) ; if ( d1 > 0.0 ) { points . add ( new PointFeature ( e , v1 . getIndex ( ) ) ) ; } else { points . add ( new PointFeature ( e , v2 . getIndex ( ) ) ) ; } } return points ; }
clips the segment given by s1 and s2 by n .
