I am to write a code for a colision detection where it detects whether two 3D spheres are colliding. Each 3D sphere has a center (an x, y, z coordinate) and a radius. Two spheres are colliding if the distance between their two centers is less then or equal to the sum of their radii. The distance D between 2 spheres with centers (x1, y1, z1) and (x2, y2, z2) is given by the formula:D = √[(x₂ - x₁)² + (y₂ - y₁)² +(z₂ - z₁)²]
I need to define a class Sphere and create two sphere objects and initialize them with user inputs. I also need to use the == operator to compare the two spheres. I need to display a message of if they are colliding nad if they are not colliding.
Thank you.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here