Is this a good intersection function for two line segments? Here is the code that I used:
double Line::GetSlope() {
    return (start.GetY()-end.GetY())/(start.GetX()-end.GetX());
}

double Line::GetYIntercept() {
    return start.GetY() - GetSlope()*start.GetX();
}

bool Line::IsIntersecting(Line line) {
    double thisSlope = GetSlope();
    double thisYIntercept = GetYIntercept();

    double lineSlope = line.GetSlope();
    double lineYIntercept = line.GetYIntercept();

    if (lineSlope == thisSlope && thisYIntercept == lineYIntercept) return true;
    if (lineSlope == thisSlope && thisYIntercept != lineYIntercept) return false;

    double intersectionX = (lineYIntercept - thisYIntercept)/(thisSlope - lineSlope);

    return (std::min(start.GetX(), end.GetX()) <= intersectionX && intersectionX <= std::max(start.GetX(), end.GetX())) && (std::min(line.start.GetX(), line.end.GetX()) <= intersectionX && intersectionX <= std::max(line.start.GetX(), line.end.GetX()));
}

So what it does is make the graph of the line segments as an extended line (thus the slopes and y-intercepts), then checks for an intersection by solving for x (intersectionX), then checks if the intersection's x is between both lines (return (std::min(start.GetX(), end.GetX()) <= intersectionX && intersectionX <= std::max(start.GetX(), end.GetX())) && (std::min(line.start.GetX(), line.end.GetX()) <= intersectionX && intersectionX <= std::max(line.start.GetX(), line.end.GetX()));).
Is this method correct, and an optimal method of checking if two lines intersect? If not, are there any more efficient methods?
If this post is in the wrong place, please do inform me, so that I can change it to the right place.
 A: In general, computing coordinates of the intersection point is not very robust against potential rounding issues. One operation that is more robust is an orientation check (i.e. detemine whether a point c lies to the left or to the right of the directed line through points a and b). This corresponds to checking whether a certain determinant is positive or negative (or 0, if the points are collinear). Checking whether two line segments intersect can be done using only orientation tests. (As I don‘t know the background of the question, I won‘t give away the answer how exactly this is done).
As a side remark, for geometric computations in C++, I can highly recommend the library CGAL.
A: Not sure about your code, but the only way to solve it is something equivalent to the following: say segment A is defined by points $s_a, e_a$ and segment B by $s_b, e_b$. Then the points in segment $A$ are $s_a + (e_a - s_a)t_a$ for $t_a\in [0,1]$. For B, the equivalent thing.
An intersection would be a point for which a $t_a\in[0,1]$ and a $t_b\in[0,1]$ exist that solve the equation
$$
 (e_a - s_a)t_a - (e_b - s_b)t_b = s_b - s_a
$$
If you are on a plane it's just a 2 by 2 in-homogeneous linear system. The segments intersect if the system can be solved (the det is != 0) and the solutions $t_a, t_b$ are in $[0, 1]$. 
