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).
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.