Using the geometry library, you have a computeHeading
method available. Please see the documentation.
You could therefore compute the heading between points A and B and compare it with the heading of points C to D.
var heading = google.maps.geometry.spherical.computeHeading(path.getAt(0), path.getAt(1));
Where path
is your first polyline. Then do the same for the second one and compare the results.
Hope this helps.