1

I mean I want to have some directed objects in my game, like a laser beam or a rocket facing somewhere.

How would you store these objects for collisions? (consider them like a circular shape to make thing easier)


My hypothesis' are:

-Either store two coordinate vectors

-Or Store a coordinate vector and an angle


Each have their advantages and drawbacks: -Storing more data would mean more load in memory -Storing less data would mean more load in calculations

I just don't know which would lead to a more optimized way, which is more generally acceptable?

Thank you for the feedback!

Dávid Tóth
  • 2,788
  • 1
  • 21
  • 46

1 Answers1

1

From my experience two coordinate vectors is better.

And if you query and need angle a lot you can store angle also.

Also from my experience, for games speed is more important than memory

premature optimization is the root of all evil http://c2.com/cgi/wiki?PrematureOptimization

Gorkem
  • 1,697
  • 1
  • 12
  • 20
  • Thank you, I accept this answer! Can I ask for a bit more detailed explanation please? – Dávid Tóth Apr 10 '13 at 15:14
  • lets take two basic examples i pick randomly. http://en.wikipedia.org/wiki/Line-line_intersection and http://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line. There are no mention of angles. Also another one : http://stackoverflow.com/questions/1073336/circle-line-collision-detection – Gorkem Apr 10 '13 at 15:25