how do I write a code about 2 3-D spheres colliding? It first asks that I have to entire in an x,y, z coordinate as the two colliding spheres are 3D spheres and it also asks if the distance between their two centers is less than 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₁)²] In this task, you will accept user inputs for the center and radius of two 3D spheres. You will define a class Sphere and create two Sphere objects and initialize them with the user inputs. The objects will also contain built-in methods to calculate their volumes. If the two spheres are identical (two spheres are identical if they have the same center coordinates; you must use the == operator to compare the two Sphere objects), then display a message and exit the program. If they are colliding, display an appropriate message and exit the program. If they are not colliding, display an appropriate message and also display how larger the volume of one sphere is compared to another (‘larger’ refers to the ratio of volume of the bigger sphere to the volume of the smaller sphere).   First of all, how do I even start this? Second of all how do I even go about doing this ??

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 7SA
icon
Related questions
icon
Concept explainers
Question

how do I write a code about 2 3-D spheres colliding?

It first asks that I have to entire in an x,y, z coordinate as the two colliding spheres are 3D spheres and it also asks if the distance between their two centers is less than 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₁)²]


In this task, you will accept user inputs for the center and radius of two 3D spheres. You will define a class Sphere and create two Sphere objects and initialize them with the user inputs. The objects will also contain built-in methods to calculate their volumes. If the two spheres are identical (two spheres are identical if they have the same center coordinates; you must use the == operator to compare the two Sphere objects), then display a message and exit the program. If they are colliding, display an appropriate message and exit the program. If they are not colliding, display an appropriate message and also display how larger the volume of one sphere is compared to another (‘larger’ refers to the ratio of volume of the bigger sphere to the volume of the smaller sphere).

 

First of all, how do I even start this? Second of all how do I even go about doing this ??

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning