private void addLimitedMitreJoin(LineSegment offset0,LineSegment offset1,double distance,double mitreLimit){
  Coordinate basePt=seg0.p1;
  double ang0=Angle.angle(basePt,seg0.p0);
  double ang1=Angle.angle(basePt,seg1.p1);
  double angDiff=Angle.angleBetweenOriented(seg0.p0,basePt,seg1.p1);
  double angDiffHalf=angDiff / 2;
  double midAng=Angle.normalize(ang0 + angDiffHalf);
  double mitreMidAng=Angle.normalize(midAng + Math.PI);
  double mitreDist=mitreLimit * distance;
  double bevelDelta=mitreDist * Math.abs(Math.sin(angDiffHalf));
  double bevelHalfLen=distance - bevelDelta;
  double bevelMidX=basePt.x + mitreDist * Math.cos(mitreMidAng);
  double bevelMidY=basePt.y + mitreDist * Math.sin(mitreMidAng);
  Coordinate bevelMidPt=new Coordinate(bevelMidX,bevelMidY);
  LineSegment mitreMidLine=new LineSegment(basePt,bevelMidPt);
  Coordinate bevelEndLeft=mitreMidLine.pointAlongOffset(1.0,bevelHalfLen);
  Coordinate bevelEndRight=mitreMidLine.pointAlongOffset(1.0,-bevelHalfLen);
  if (side == Position.LEFT) {
    segList.addPt(bevelEndLeft);
    segList.addPt(bevelEndRight);
  }
 else {
    segList.addPt(bevelEndRight);
    segList.addPt(bevelEndLeft);
  }
}

private void addLimitedMitreJoin ( LineSegment offset0 , LineSegment offset1 , double distance , double mitreLimit ) { Coordinate basePt = seg0 . p1 ; double ang0 = Angle . angle ( basePt , seg0 . p0 ) ; double ang1 = Angle . angle ( basePt , seg1 . p1 ) ; double angDiff = Angle . angleBetweenOriented ( seg0 . p0 , basePt , seg1 . p1 ) ; double angDiffHalf = angDiff / 2 ; double midAng = Angle . normalize ( ang0 + angDiffHalf ) ; double mitreMidAng = Angle . normalize ( midAng + Math . PI ) ; double mitreDist = mitreLimit * distance ; double bevelDelta = mitreDist * Math . abs ( Math . sin ( angDiffHalf ) ) ; double bevelHalfLen = distance - bevelDelta ; double bevelMidX = basePt . x + mitreDist * Math . cos ( mitreMidAng ) ; double bevelMidY = basePt . y + mitreDist * Math . sin ( mitreMidAng ) ; Coordinate bevelMidPt = new Coordinate ( bevelMidX , bevelMidY ) ; LineSegment mitreMidLine = new LineSegment ( basePt , bevelMidPt ) ; Coordinate bevelEndLeft = mitreMidLine . pointAlongOffset ( 1.0 , bevelHalfLen ) ; Coordinate bevelEndRight = mitreMidLine . pointAlongOffset ( 1.0 , - bevelHalfLen ) ; if ( side == Position . LEFT ) { segList . addPt ( bevelEndLeft ) ; segList . addPt ( bevelEndRight ) ; } else { segList . addPt ( bevelEndRight ) ; segList . addPt ( bevelEndLeft ) ; } }
adds a limited mitre join connecting the two reflex offset segments . a limited mitre is a mitre which is beveled at the distance determined by the mitre ratio limit .
