How to understand that two lines go next to each other in the program?

53 Views Asked by At

I have a graph with two lines that measure the volume flow of some goods. Every 5 minutes I receive new points for two lines. When I visually see that two lines are next to each other and go through zero, I understand that there are negative/positive volume flow. By saying that they go near each other, I mean two lines go in the same direction at almost the same angle (see the screenshot - red vertical line for negative flow and green for positive).

positions

However, I puzzle over the problem of creating an algorithm to check whether two lines are near each other.

I need anything - description of the algorithm or pseudocode.

1

There are 1 best solutions below

0
rotabor On

In a selected interval calculate dY/dX, which is the tangent of the slope angle. This value characterizes parallelism of two trends very well.

In your case the sought value between point 1 and point 2 is (rate2 - rate1) / (timestamp2 - timestamp1).