5 ms·
I've always defaulted to squaring the radii for circle collision to avoid the sqrt. Is it a premature optimization these days?
by hnaccy 6y ago
I've always defaulted to squaring the radii for circle collision to avoid the sqrt.
Is it a premature optimization these days?
- munchbunny 6y agoNo, it’s not premature. Skipping sqrt operations in the inner loops, which collision detection often is, is a generally good idea because the sqrt operation isn’t cheap.
- stephc_int13 6y agoThis is not premature at all and it does not add complexity to the code, quite the opposite.
- kabdib 6y agoMy 8-bit games just used rectangles; for circles I just overlapped two inside the geometry in a fat "+" shape. This was on a platform with pixel-accurate collision detection in hardware, and I always thought that the sloppy geometry-based detection was more fun for players. N-squared for single-digit N worked just fine, too.
- 082349872349872 6y agoHistorial note: To avoid sqrt, the Atari baseball cartridge went the 1897 Indiana legislature one better, using octagons as circles. π ~= 3,314? Unte im finyish du kaxa okwa bik, 4 600 mm bi wit dek xante im. Na desh kuwang, unte im 2 300 mm gova bik, unte 14 000 mm fo imim du gang im. - 1 Da Bosmang Da Bik Imalowda 7:23