private void computeOffsetSegment(LineSegment seg,int side,double distance,LineSegment offset){
  int sideSign=side == Position.LEFT ? 1 : -1;
  double dx=seg.p1.x - seg.p0.x;
  double dy=seg.p1.y - seg.p0.y;
  double len=Math.sqrt(dx * dx + dy * dy);
  double ux=sideSign * distance * dx / len;
  double uy=sideSign * distance * dy / len;
  offset.p0.x=seg.p0.x - uy;
  offset.p0.y=seg.p0.y + ux;
  offset.p1.x=seg.p1.x - uy;
  offset.p1.y=seg.p1.y + ux;
}

private void computeOffsetSegment ( LineSegment seg , int side , double distance , LineSegment offset ) { int sideSign = side == Position . LEFT ? 1 : - 1 ; double dx = seg . p1 . x - seg . p0 . x ; double dy = seg . p1 . y - seg . p0 . y ; double len = Math . sqrt ( dx * dx + dy * dy ) ; double ux = sideSign * distance * dx / len ; double uy = sideSign * distance * dy / len ; offset . p0 . x = seg . p0 . x - uy ; offset . p0 . y = seg . p0 . y + ux ; offset . p1 . x = seg . p1 . x - uy ; offset . p1 . y = seg . p1 . y + ux ; }
compute an offset segment for an input segment on a given side and at a given distance . the offset points are computed in full double precision , for accuracy .
