DUMBFUCK DJ Yoshi wrote:Uh...no? Pythagorean Theorem is for triangles...if you're talking about collisions on the edge, you'd have to go into fairly complex mathematics, and in the middle, it'd be even harder, I assume.
Go back to 7th grade, dumbass. No shit it's for triangles. a^2 + b^2 = c^2.
THE SAME FUCKING THING YOU USE FOR DISTANCE:
Distance = SQRT((x2-x1)^2 + (y2-y1)^2))
You're a moron, and I wish you not post here anymore...at least until you learn what you're talking about. -.-
Okay, you know what; I have a math test tomorrow. I'm in the mood to pwn you and study at the same time, so I'll give you a lesson on the relation to the distance formula and the Pythagorean Theorem. Here it goes:
In the above grid, you see a right triangle, with two legs, each with the sides of two units, and a green hypotenuse. Assume that we want to find the DISTANCE between the start and finish point. We'll use the "distance" formula to decide it.
The start point is (4,1)
The end point is (2,3)
The "distance" formula says we do SQRT((x2-x1)^2 + (y2-y1)^2)).]
So, lets plug in some numbers.
SQRT((x2-x1)^2 + (y2-y1)^2))
SQRT((2-4)^2 + (3-1)^2))
SQRT((-2)^2 + (2)^2))
SQRT(4 + 4)
SQRT(8)
Approx.
2.82427125
Okay, I showed all my work and made it idiot proof (We may have an exception with you...) and that shows that the distance is approximately 2.82427125 using what you call the "distance" formula. Now, as you said, the Pythagorean Theorem deals with
TRIANGLES. That is correct, but the distance formula was created FROM the Pythagorean Theorem.
The theorem stats that A^2 + B^2 = C^2, assuming that A and B are the distance of the legs and C is the distance of the hypotenuse, correct? If you do not know that, go back to the 7th grade; I'm too lazy to post links to some proofs of it.
Anyway, please refer back to the grid I drew so perfectly. Notice the imaginary red line that is added to form a right triangle? One can be added to ANY set of coordinates, so long as it's set EXACTLY where two axis meet. Example, if I had the coordinates, (10,2) and (13,1) I'd plot the imaginary point on (13,2) or (10,1) to form a right triangle, making the distance you're figuring the hypotenuse.
Now, back to our example:
The start point is (4,1)
The end point is (2,3)
Distance of leg 1 is the distance between point (2,3) and (2,1), which you can count as 2 units.
Distance of leg 2 is the distance between point (4,1) and (2,1), which you also can count as 2 units.
Now, the Pythagorean Theorem states that now you must square them, to receive the distance of the hypotenuse (The distance you're trying to figure in the first place) also squared. Then, you must unsure it, or take the square root of it.
(2)^2 + (2)^2 = (Hypotenuse/Distance)^2
4 + 4 = (Hypotenuse/Distance)^2
8 = (Hypotenuse/Distance)^2
SQRT(8) = Hypotenuse/Distance
Approx.
2.82427125 = Hypotenuse/Distance
There you do. The distance formula is nothing more than the Pythagorean Theorum written as an equation.
NOW GET THE FUCK OUT OF MY GRILL, MORON!
:asshole:
Gyrovorbis wrote:I've got news for you, using the Pythagorean theorem, you'd be getting DIAMETER not RADIUS. You'd have to half the diameter.
I still fail to see how that'd make a respectable collision function...grill:
Maybe we're looking at this different, because I dunno what you mean.
I FIRST find the radius:
(((image width) \ 2) + ((image height \ 2))) \ 2
And test collision by using the Pythagorean Theorem to determine the distance from the center of one image to the center of the other, and then see if the distance is less than or equal to the radius. If so, one circle is in the other's grill, and thus they collided. That's a pixel perfect way to make circle collisions; the way I would have used.