Question: I know there are many algorithms to verify whether two line segments are intersected.

The line segments I'm talking about are length line constructed by 2 end points.

But once they encountered parallel condition, they just tell the user a big "No" and  

pretend there is no overlap, share end point, or end point collusion.

I know I can can calculate the distance between 2 lines segments.  

If the distance is 0, check the end points located in the other line segments or not.  

And this means I have to use a lot of if else and && || conditions.

This is not difficult, but my question is

**"Is there a trick( or mathematics) method to calculate this special parallel case?"**

**I hope this picture clarify my question  

<http://judark.myweb.hinet.net/parallel.JPG>**

Answer: 
Yes, given the formulas for both of the lines, test whether their slopes are equal. If they are, the lines are parallel and never intersect.

If you have points on each of the lines, you can use the [slope formula](http://cs.selu.edu/~rbyrd/math/slope/).

If both are perpendicular to the x-axis, they will both have infinite slopes, but they will be parallel. All points on each line will have equal x coordinates.

To deal with line segments, calculate the point of intersection, then determine if that point of intersection exists for both of the segments.
I assume the case you're interested in is where the two line segments are parallel (as determined by checking the slope, as Whirlwind says), and you're trying to determine whether the two segments overlap.

Rather than worrying about the distance between the lines, I would think the easiest way to do that would to if either endpoint of one segment lies within the other:

```
if (segment_contains_point(segment_A, segment_B.start) || 
    segment_contains_point(segment_A, segment_B.end)) {
        // lines overlap
}

```