constraining an empty to the intersection of two coplanar segments For some reason I have two coplanar segments (each represented by a 2 points path), moving relative to each other in a way that guarantees they are always intersecting.

What I would like is to constraint an empty to follow the intersection of these segments.

The movement of the intersection point is far too complicated to be plotted manually or analytically, especially since the idea is to try various configurations that will change the position and rotation of these segments.

I tried using constraints, a combination of "damped track" and "clamp to" (i.e. orienting one axis of the empty parallel to the segment first, and clamping according to this axis next), but to no avail.
I get the empty to follow the first path in the constraint stack, but though it moves somewhat close to the second path, it remains quite far from the intersection.

Maybe the whole idea of using constraints is wrong? I'm interested in any trick that would make this work, including python scripting if there is no other way  (I suppose a scripted driver could easily compute the intersection coordinates, but I would hate to hard-code object references and such).

EDIT:
this cross-question discussion is kinda awkward, but here is a modified version of the proposed answer :



I just moved the end of the rod to reflect the fact that it is not aligned to any global axis. This is a major constraint that had me conclude an analytic solution was too complex to code as a driver formula.
Another constraint is that the slot inside the crank must be a straight line. This piece is supposed to be cut out by hand from a few mm of plywood, and trying to carve out a complex elliptic curve is out of the question (you would never manage to get the precision without laser cutting).

I have no doubt the trigonometry of your model is correct, and the precision is more than enough. Still, it makes the hypothesis that the rod axis of rotation is aligned with global X, and the contact point describes some complex trigonometric curve (I suspect it would be more like some Lissajou curve than a mere part of ellipsis if the axis was not aligned with global X, but not a straight line anyway). 

As soon as its axis deviates from X, you can see the end of the rod going round in cicles as the crank moves. In what I try to simulate, the axis should remain stable and the "top" empty should slide along the crank radius to allow the rod to rotate without shifting position or deforming.

Maybe some formula adjustment can fix this, but I can't see how. At the very least the formula should take the rod rotation axis into account, which would probably require an arcsine of the two axis cross product.
I'm going to post what it is that I believe you are looking for.

If it is wrong, I can always come back and delete the answer.



What I did was add two empties:


The 'Base' located to the center of rotation of the rod which also has the driver on the y rotation. 


AND


The 'Top' which is parented to the z-rotation arm.


THEN

solved the triangle with a simple trig function using the view plane of X/Z.

You just need to know the absolute difference between the 'basex' &amp; 'topx' locations for the 'X-axis' for the horizontal leg of the triangle, then get the absolute distance for the 'basez' &amp; 'topz' locations for the 'Z-axis' for the vertical leg, and use the 'atan' function to get the angle of this relationship.

So I ended up with these four variables in the driver:

basex, topx, basez, topz

and I used this as the expression:

atan( (abs(basex - topx)*1.0000000000)  /  (abs(basez - topz)*1.0000000000) )

The reason for using the '1.0000000000' value was to force the calculation to be multiplied at this many decimal places for rotational accuracy.

Here's the Blend File:



NOTE: 


Select the rotational arm and rotate about 'Z' to see the effect.
Select the rod to see the driver in the graph editor
For some reason, the driver value can get stuck and not update the solution before the frame updates so maybe reducing the Multiply by 1.0000000000 to 1.0000 is good enough in this case as it should really decrease the effort of calculation. After doing this, and making the hole of the crank more fitting for the bent rod to twist and elongate elliptically, I was able to get a much better solve with the same logic.