2

The operation mentioned in the title is common in many Computer Aided Design (CAD) softwares such as AutoCAD, where it is called fillet. However, I found it is really difficult to implement this function in my own program.

The method I thought of is to use the condition that the distances of the arc center to the tangent lines of the curves are equal to the specified radius. Considering that actual curves are defined with piece-wise nonlinear functions, and the contact points could be anywhere on the curves, it is not easy to get the solution. Anyone good ideas?

Mohammad Yusuf
  • 16,554
  • 10
  • 50
  • 78
user1446072
  • 83
  • 1
  • 8
  • You are right, it's not easy, but is it really a programming problem? – n. m. could be an AI Nov 26 '16 at 12:45
  • Sorry, I am not sure how to classify this problem, but I really want to realize this function by programing. – user1446072 Nov 26 '16 at 12:58
  • You need to come up with a formula/equation first, then solving it is a programming problem. But deriving the equation is pure math. – n. m. could be an AI Nov 26 '16 at 13:01
  • That's why I added the "geometry" tag. The method I thought of will lead to solving a group of nonlinear equations, and I am not sure if this is the only method. – user1446072 Nov 26 '16 at 13:15
  • Is this 2D or 3D? – Nico Schertler Nov 26 '16 at 13:26
  • It is a 2D problem. – user1446072 Nov 26 '16 at 13:43
  • @n.m. "You need to come up with a formula/equation first" If everything would be possible with formulae, one wouldn't need a computer; a calculator would suffice. You know, heaps of cases in which the solutions are solvable only numerical using an algo instead of a closed form solution to an equation. Go no further than non-linear univariate equations with the classical Newton-Raphson method as a classic example. – Adrian Colomitchi Nov 26 '16 at 14:09
  • @AdrianColomitchi some equations are only solvable numerically, but in order to solve them you need to *have* them first. – n. m. could be an AI Nov 26 '16 at 15:29

2 Answers2

1

Given that you don't describe in enough details the characteristics of the curves, it's hard to come with a specific/specified algo, but let's try a descriptive approach:

take a circle of the given radius and roll it on one curve until the circle touches the other one.

I assume you can parametrize you curves.

To "roll the circle" along the curve you need the tangent (or better said the normal, which of course is normal to the tangent) in the point "rolling track curve"-to-circle tangent point. You have this normal, you know the radius, you can compute your circle. You have the circle, you can see if/where it intersects the other curve.

The idea of "rolling" is to bracket your solution (parameter of the tangent-point on one curve) between a point when the circle does not intersect the other curve and another point where it intersects (possible in more than 1 point). Once you have the bracket, go with a bisection method (binary search) between the two positions until your circle becomes "tangent enough" to the other curve (i.e the intersection points with the other curve are so close that they fall below your acceptable epsilon).

You will now have two points (one on each curves) and the circle that realizes the solution: just keep the arc on this circle corresponding what make sense (based on the convergence or divergence of the two tangents).

Adrian Colomitchi
  • 3,974
  • 1
  • 14
  • 23
  • Firstly, thanks for your detailed reply, and sorry for not providing specific data, because this is really a general problem. Actual curves encountered are usually splines such as cubic splines or NURBS. It seems that the approach you proposed will also lead to solving nonlinear equations. Maybe this is unavoidable because of the generality of this problem. – user1446072 Nov 26 '16 at 15:10
  • @user1446072 yes, the equations are non-linear in all but the simplest cases and must be solved numerically, – n. m. could be an AI Nov 26 '16 at 16:13
  • You can write down the coordinates (x1,y1) of the centre of the circle tangent to one of the curves as a function of the curve parameter. You then can write down the coordinates (x2,y2) of the centre of the circle tangent to the other curve as a function of the curve parameter. Now equate the two points. You have two equations (x1(t1)=x2(t2),y1(t1)=y2(t2)) of two variables t1, t2. You can solve it by whatever numerical method. – n. m. could be an AI Nov 26 '16 at 16:23
1

To find the arc center you need two robust and strategic algorithms:

  1. Curve offset
  2. Curve intersection

What AutoCAD does to find the arc center is to offset the two curves of the arc radius distance and intersect them. Depending on the curve offset direction you can easily switch between all possible solutions to the problem.

At this point, trimming the curves at tangent points will be trivial.

abenci
  • 8,422
  • 19
  • 69
  • 134