Okay. Right now I am writing this program from scratch that is supposed to do basic collision detection for class.
I have run into a problem that, as is, will end up with me doing a ridiculously long series of if statements just to check for the smallest and largest variables in a serious of x and y float variables I have declared.
The current code I am trying to make is being made to detect and determine the intersection of two line segments.
Basically, what I want to do is this, in pseudocode.
1 2 3 4 5 6 7
Now that the user has input the four x and y values for the endpoints of both lines.
Find the max and min values of both values for both lines. Then calculate the slope for both lines.
Once slope is calculated, begin checking if the xy values within the max/min range of both lines intersect.
if they do not, continue checking, if they do, what is the intersecting pair of values?
Once found, print out the intersecting values to the screen, then end the function.
For something like this. I think Arrays wouldn't be a very smart choice.
What I didn't include in there is that the values are being multiplied by the respective slopes of both lines when increasing the value
@Peter:
Wow... Wish I had thought of that possibility. I forgot about function overloading...
It may seem unnecessarily cumbersome, but it is supposed to ensure that, in the event that the x values of both end points are equal, they will both contain the same number. The best part is this makes the code more compact.