To find the arc segment that forms the fillet between two line segments you first have to find the centre of the arc by intersecting the offset of the two lines:
The start and end point of the arc are found by creating lines through the new found centre, perpendicular to the two lines:
Now we have enough data to construct the fillet arc:
a centre;
a radius;
a start point (implicating a start angle);
and a endpoint (implicating an and angle).
if you write this algorithm in pseudo (C#) code, you end up with:
public%20static%20ArcSegment%20FilletArc%28LineSegment%20Line1%2C%20LineSegment%20Line2%2C%20double%20Radius%29%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20Point%20center%20%3D%20%28Point%29%20Line1.Offset%28Radius%29.Intersect%28Line2.Offset%28Radius%29%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20new%20ArcSegment%28%29%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Center%20%3D%20center%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//%20P2%20is%20the%20intersection%20point%20of%20the%20returned%20linesegment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20StartPoint%20%3D%20Line1.PerpendicularLine%28center%29.P2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20EndPoint%20%3D%20Line2.PerpendicularLine%28center%29.P2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%20%20%7D[copy code to clipboard]
1: public static ArcSegment FilletArc(LineSegment Line1, LineSegment Line2, double Radius)
2: {
3: Point center = (Point) Line1.Offset(Radius).Intersect(Line2.Offset(Radius));
4: return new ArcSegment()
5: {
6: Center = center,
7: // P2 is the intersection point of the returned linesegment
8: StartPoint = Line1.PerpendicularLine(center).P2,
9: EndPoint = Line2.PerpendicularLine(center).P2,
10: };
11: }
That looks neat! A few hurdles to take, though. the function LineSegment.Offset(double radius) does not take into account that there are two possible sides to offset to, resulting in 4 possible fillets. I’ll have to ponder on that a little more. The rest is trivial and coded …. Material for a next post.