Regarding WhatEver''s code:
Shouldn''t that be (radius1*radius1)+(radius2*radius2)? If I understand correctly, TestVectorDotLength is the square of the distance between the centers of the spheres, and the spheres will collide if that number is less than the sum of the squares of the radii, but not necessarily if it is less than the square of the sum of the radii.
-riley
Sphere --> Ray intersection?!
It should be correct.
What my formula is doing is generating the square of the combined radiuses. So if the DOT of the vector created from the two center points is less than the square of the diameter, then the spheres are within each other.
If you do the squares first then the number is to large.
An example:
Lets say the two spheres have a 5 unit radius. That would mean the minimum distance from center to center would be 10 units. That makes the minimum DOT distance 100. Let's say the distance from center to center is 8 units. That makes the DOT distance 64 units, which means the spheres are touching. If the distance were 10, then they'd be tangent.
Broken down:
-Combining radiuss to make the DOT distance
(5+5)*(5+5) or 10*10 equals 100
-The DOT distance from center to center of the spheres
8*8 equals 64
If the DOT distance from center to center is less than the combined radiuses of the two spheres, then the spheres are intersecting.
[edited by - WhatEver on March 16, 2002 3:52:09 PM]
What my formula is doing is generating the square of the combined radiuses. So if the DOT of the vector created from the two center points is less than the square of the diameter, then the spheres are within each other.
If you do the squares first then the number is to large.
An example:
Lets say the two spheres have a 5 unit radius. That would mean the minimum distance from center to center would be 10 units. That makes the minimum DOT distance 100. Let's say the distance from center to center is 8 units. That makes the DOT distance 64 units, which means the spheres are touching. If the distance were 10, then they'd be tangent.
Broken down:
-Combining radiuss to make the DOT distance
(5+5)*(5+5) or 10*10 equals 100
-The DOT distance from center to center of the spheres
8*8 equals 64
If the DOT distance from center to center is less than the combined radiuses of the two spheres, then the spheres are intersecting.
[edited by - WhatEver on March 16, 2002 3:52:09 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement