How to find a crossing point between two lines? I need to find the point of intersection between two lines. For example:
The first point of the first line: 1107x332
The second point of the first line: 1193x368
The first point of the second line: 1150x450
The second point of the second line: 1150x250

I have the following code:
float x = -((x1*y2-x2*y1)*(x4-x3)-(x3*y4-x4*y3)*(x2-x1))/((y1-y2)*(x4-x3)-(y3-y4)*(x2-x1));
float y = ((y3-y4)*(-x)-(x3*y4-x4*y3))/(x4-x3);

But I have a problem with diving by 0 here: $x_4-x_3=1150-1150=0$.
$$x=\frac{-(x_1y_2-x_2y_1)(x_4-x_3)-(x_3y_4-x_4y_3)(x_2-x_1)}{(y_1-y_2)(x_4-x_3)-(y_3-y_4)(x_2-x_1)}$$
$$y=\frac{(y_3-y_4)(-x)-(x_3y_4-x_4y_3)}{x_4-x_3}$$
Here $x_1,y_1$ are the coordinates of the first point of the first line. $x_2,y_2$ are those of the second point of the first line and so on.
In my example, the lines are crossing somewhere, i.e. they are not parallel. What's wrong with my formulas?

Your code seems correct, but it does not work if one of the line is vertical, because you have the differences $x_2-x_1$ and $x_4-x_3$ at the denominator. So these case have to be treated  as special cases. Note that another special case is when the two lines are parallel.
