addDirectedFillet method
void
addDirectedFillet(
- Coordinate p,
- double startAngle,
- double endAngle,
- int direction,
- double radius,
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
Implementation
void addDirectedFillet(Coordinate p, double startAngle, double endAngle,
int direction, double radius) {
int directionFactor = direction == Orientation.CLOCKWISE ? -1 : 1;
double totalAngle = (startAngle - endAngle).abs();
int nSegs = (totalAngle / filletAngleQuantum + 0.5).toInt();
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.empty2D();
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;
}
}