geometry - C++ Checking For Two Spheres Intersecting/Collidiing -


im getting c++ , have been researching how have 2 spheres interact 1 another. of have found complex or actual math formulas. there more simplistic way of creating function recognize when side of sphere makes contact another? im not asking work, appreciate kind of clean visual, pseudo code or or code snippet, me understand more. or maybe links havent found?

thanks!

check if distance between spheres' centers less sum of radii.

class sphere { public:     double centerx, centery, centerz, radius;     // ....  };  double distancebetween( const sphere& a, const sphere& b ) {     return sqrt( pow( a.centerx - b.centerx, 2 ) + pow( a.centery - b.centery, 2 ) + pow( a.centerz - b.centerz, 2 ) ); }  bool arecolliding( const sphere& a, const sphere& b ) {     return distancebetween( a, b ) < ( a.radius + b.radius ); } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -