How can we check that whether the given two non parallel lines will intersect each other or not?? I stored the x and y coordinates of starting and ending point of line1 and line2 in a 2d array, as
1 2
float l1[2][2];
float l2[2][2];
Now how would I check whether there comes a point where l1==l2 (they intersect each other)
bool doNonParellelLinesIntersect(line line1, line line2)
{
returntrue;
}
I think I'm missing something, the definition of parallel lines is that they do not intersect, so the definition of non parallel would be that they do intersect.
If you are referring to line segments, do any of the basic algebra methods of solving equations with both an x and a y value, such as linear substituiton, then check if that point actually exists on both lines.
If you are using this for a game, do the much, much easier, more efficent method of hit boxes.
@ Intrexa: Why would I want to create and track an entire object if I'm "shooting" something in a game that I made? Isn't it much easier to do the calculation then blit an animation to the screen that stops at the relevent point (either at the intersection with the object or just past the drawing point of the screen)? Besides with the simplicity of Hitboxes you end up testing for collisions with EVERY object on the screen regardless of it's location relative the the "ballistics" path.