/** * Add last offset point */ public void addLastSegment() { segList.addPt(offset1.p1); }
public void addFirstSegment() { segList.addPt(offset1.p0); }
/** * Adds a bevel join connecting the two offset segments * around a reflex corner. * * @param offset0 the first offset segment * @param offset1 the second offset segment */ private void addBevelJoin( LineSegment offset0, LineSegment offset1) { segList.addPt(offset0.p1); segList.addPt(offset1.p0); }
/** * Creates a CW square around a point */ public void createSquare(Coordinate p) { segList.addPt(new Coordinate(p.x + distance, p.y + distance)); segList.addPt(new Coordinate(p.x + distance, p.y - distance)); segList.addPt(new Coordinate(p.x - distance, p.y - distance)); segList.addPt(new Coordinate(p.x - distance, p.y + distance)); segList.closeRing(); } }
/** * Adds points for a circular fillet arc * between two specified angles. * The start and end point for the fillet are not added - * the caller must add them if required. * * @param direction is -1 for a CW angle, 1 for a CCW angle * @param radius the radius of the fillet */ private void addFillet(Coordinate p, double startAngle, double endAngle, int direction, double radius) { int directionFactor = direction == CGAlgorithms.CLOCKWISE ? -1 : 1; double totalAngle = Math.abs(startAngle - endAngle); int nSegs = (int) (totalAngle / filletAngleQuantum + 0.5); if (nSegs < 1) return; // no segments because angle is less than increment - nothing to do! double initAngle, currAngleInc; // choose angle increment so that each segment has equal length initAngle = 0.0; currAngleInc = totalAngle / nSegs; double currAngle = initAngle; Coordinate pt = new Coordinate(); while (currAngle < totalAngle) { double angle = startAngle + directionFactor * currAngle; pt.x = p.x + radius * Math.cos(angle); pt.y = p.y + radius * Math.sin(angle); segList.addPt(pt); currAngle += currAngleInc; } }
/** * Add points for a circular fillet around a reflex corner. * Adds the start and end points * * @param p base point of curve * @param p0 start point of fillet curve * @param p1 endpoint of fillet curve * @param direction the orientation of the fillet * @param radius the radius of the fillet */ private void addFillet(Coordinate p, Coordinate p0, Coordinate p1, int direction, double radius) { double dx0 = p0.x - p.x; double dy0 = p0.y - p.y; double startAngle = Math.atan2(dy0, dx0); double dx1 = p1.x - p.x; double dy1 = p1.y - p.y; double endAngle = Math.atan2(dy1, dx1); if (direction == CGAlgorithms.CLOCKWISE) { if (startAngle <= endAngle) startAngle += 2.0 * Math.PI; } else { // direction == COUNTERCLOCKWISE if (startAngle >= endAngle) startAngle -= 2.0 * Math.PI; } segList.addPt(p0); addFillet(p, startAngle, endAngle, direction, radius); segList.addPt(p1); }
/** * Creates a CW circle around a point */ public void createCircle(Coordinate p) { // add start point Coordinate pt = new Coordinate(p.x + distance, p.y); segList.addPt(pt); addFillet(p, 0.0, 2.0 * Math.PI, -1, distance); segList.closeRing(); }
segList.addPt(li.getIntersection(0)); segList.addPt(offset0.p1); } else { segList.addPt(offset0.p1); Coordinate mid0 = new Coordinate((closingSegLengthFactor * offset0.p1.x + s1.x)/(closingSegLengthFactor + 1), (closingSegLengthFactor*offset0.p1.y + s1.y)/(closingSegLengthFactor + 1)); segList.addPt(mid0); Coordinate mid1 = new Coordinate((closingSegLengthFactor*offset1.p0.x + s1.x)/(closingSegLengthFactor + 1), (closingSegLengthFactor*offset1.p0.y + s1.y)/(closingSegLengthFactor + 1)); segList.addPt(mid1); segList.addPt(s1); segList.addPt(offset1.p0);
case BufferParameters.CAP_ROUND: segList.addPt(offsetL.p1); addFillet(p1, angle + Math.PI / 2, angle - Math.PI / 2, CGAlgorithms.CLOCKWISE, distance); segList.addPt(offsetR.p1); break; case BufferParameters.CAP_FLAT: segList.addPt(offsetL.p1); segList.addPt(offsetR.p1); break; case BufferParameters.CAP_SQUARE: offsetR.p1.x + squareCapSideOffset.x, offsetR.p1.y + squareCapSideOffset.y); segList.addPt(squareCapLOffset); segList.addPt(squareCapROffset); break;
segList.addPt(intPt);
/** * Add last offset point */ public void addLastSegment() { segList.addPt(offset1.p1); }
public void addFirstSegment() { segList.addPt(offset1.p0); }
/** * Adds a bevel join connecting the two offset segments * around a reflex corner. * * @param offset0 the first offset segment * @param offset1 the second offset segment */ private void addBevelJoin( LineSegment offset0, LineSegment offset1) { segList.addPt(offset0.p1); segList.addPt(offset1.p0); }
/** * Creates a CW square around a point */ public void createSquare(Coordinate p) { segList.addPt(new Coordinate(p.x + distance, p.y + distance)); segList.addPt(new Coordinate(p.x + distance, p.y - distance)); segList.addPt(new Coordinate(p.x - distance, p.y - distance)); segList.addPt(new Coordinate(p.x - distance, p.y + distance)); segList.closeRing(); } }
/** * Creates a CW circle around a point */ public void createCircle(Coordinate p) { // add start point Coordinate pt = new Coordinate(p.x + distance, p.y); segList.addPt(pt); addFillet(p, 0.0, 2.0 * Math.PI, -1, distance); segList.closeRing(); }