abdullah wrote:The game of the error functions for constraints starts again, with renewed awards for the best ideas. We are missing here:
1. Perpendicular to ellipse constraint (I know there is an equation some 20 posts ago, I still have to take a look to...)
2. Circle tangent to ellipse (without point tricks, I still have to take a look to DevJohans code with the nice figure)
3. Ellipse tangent to ellipse
Here is an approach for those constraints:
1. Perpendicular to ellipse constraint:
a) A point on the ellipse is needed: Pelli
First constraint is: Pelli is a point on the ellipse.
b) Pelli has to be also a point at the line perpendicular to the ellipse.
Second constraint is: Pelli is a point on the line.
c) We can calculate the two vectors between Pelli and the foci F1 and F2 of the ellipse.
V1 = Pelli - F1 and V2 = Pelli - F2
The angle bisecting vector between V1 and V2 is perpendicular to the ellipse curve.
Vperp = V1/|V1| + V2/|V2|
P1 and P2 are the points of the line.
Vline = P1 - P2
We have to test, that Vperp and Vline are parallel. This can be done with the determinat. The error function is:
err_parallel = Vperp.x * Vline.y - Vline.x * Vperp.y
This is the third independent constraint.
So instead of one error function we have three independent error functions, that all have to be fullfilled.
The next two cases are using the same approach. We just have to calculate the vector Vline a little bit different.
Pelli has to be a point of the circle.
The vector Vline is calculated in the case of the circle:
Vline = Circle_center - Pelli
Pelli has to be also a point of the second ellipse.
Vline = Vperp_second_ellipse