home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / programm / 2123 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  1.7 KB

  1. Path: sparky!uunet!mcsun!uknet!root44!hrc63!mrcu!paj
  2. From: paj@uk.co.gec-mrc (Paul Johnson)
  3. Newsgroups: comp.programming
  4. Subject: Re: Collision Detection
  5. Message-ID: <1854@snap>
  6. Date: 28 Jul 92 08:12:28 GMT
  7. References: <18052.2a6ea82e@levels.unisa.edu.au> <Jul27.233802.41110@yuma.ACNS.ColoState.EDU>
  8. Reply-To: paj@uk.co.gec-mrc (Paul Johnson)
  9. Organization: GEC-Marconi Research Centre, Great Baddow, UK
  10. Lines: 27
  11.  
  12. In article <18052.2a6ea82e@levels.unisa.edu.au> Andrew writes:
  13. > Does anybody out there know of a fast efficient way to detect and handle
  14. > colliding objects in two dimensions (there may be multiple objects colliding
  15. > as well)...
  16. > it may be a similar problem to gas particles colliding...
  17.  
  18. Depending on the numbers of objects and their sizes relative to the
  19. screen, it may be worth while setting up an array or hash table of
  20. screen zones.  If you have only a few percent of the screen occupied
  21. by objects then a hash table will be more memory efficient.  I'll let
  22. you work out the tradeoffs for yourself.
  23.  
  24. The idea is that the screen is split into (say) 100x100 zones.  If an
  25. object is in (or partly in) a zone then it is entered into a list of
  26. objects in that zone.  Then you only have to do collision detection on
  27. the small number of objects which are nearby.
  28.  
  29. If your objects follow simple trajectories then you can also do the
  30. collision detection when the trajectory is set up.
  31.  
  32. Paul.
  33. -- 
  34. Paul Johnson (paj@gec-mrc.co.uk).        | Tel: +44 245 73331 ext 3245
  35. --------------------------------------------+----------------------------------
  36. These ideas and others like them can be had | GEC-Marconi Research is not
  37. for $0.02 each from any reputable idealist. | responsible for my opinions
  38.