# After Effects: Detect point of intersection between two paths

I have two curves/paths (path A and B) and a null point A that follows path A with an arbitrary speed.

I need a null point B that follows the path B but with a speed dependent to null point A x position. In other words, point B must follow the path B but accordingly to point A x position.

As you see in the image, at time 0 and 1, point B has the x position shared with point A while point B y position is on the intersection of the vertical axis, passing trough point A, and path B.

I need an expression for null point B position that can do that.

• Have you looked at path point expressions? The video on this page looks like it would get you most of the way there. pixelsandpaths.com/posts/tutorials/…
– tomh
Commented Mar 25, 2022 at 14:30
• Hmm.. That's a tricky one. I can track the red path if I parent both sliders together, but then the x positions go out of sync. Or I can track the x position of A onto B, but then B doesn't follow its own path correctly. Bet @stib knows.
– tomh
Commented Mar 25, 2022 at 15:15

OK, I can't do the maths, so I'm going straight to hell for this terrible hack instead:

1. Make a solid the size of your comp
2. Make a shape layer containing two curves the shape of Path A and Path B. Make them have some thickness (a few pixels).
3. Put the shape layer above the white solid.
4. Set the white solid to Alpha Invert Track Matte, so two holes are cut in it, using the shape layer to cut them. The shape layer will automatically become invisible.

1. Put a bright red vertical line behind your white background. Animate it from left to right.
2. Add another white solid as the bottom layer, as a background so you can't see the holes.

Pre-comp all of the above.

In your master comp which now contains only your new precomp, use the Tracker to Track Motion on your PreComp.
Track the small red dots that cut through the holes. Attach both trackers to nulls, etc.

It's really ugly but it works:

• Hi tomh, thank you for your help. That will work but i didn't clarify that i need a parametric solution cause i need to create multiple graph very quickly. I already have the expression to let the point A follow the path A. Of course I can use the same expression for point B and path B, but in some way i need to set extra math to make point B aligned to point A on vertical axis during time. Commented Mar 27, 2022 at 13:05
• I think with the right use of comps, you could parameterise this method
– tomh
Commented Mar 27, 2022 at 16:08

Hoped this is useful to you even if it's quite late

• Welcome! Please summarize the contents of the linked GIF in case it becomes unavailable in the future. Commented Jan 17, 2023 at 18:38