Jump to content


- - - - -

2d collision / Separating Axis Theorem


  • You cannot reply to this topic
4 replies to this topic

#1 Akinak

    Member

  • Members
  • PipPip
  • 52 posts

Posted 03 April 2008 - 07:31 AM

hi there every body
in this picture it seems that for 2d collision detection
Posted Image
its necessary to project on both normal vector to the edge of both
polygons
since projecting them on only boxes axes gives us intersection but projecting on triangle wont give intersection.
now is there any way to find wich polygons axes are enough for correct collision test ?

#2 Nico

    New Member

  • Members
  • Pip
  • 4 posts

Posted 03 April 2008 - 11:54 AM

It is sufficient to check the edge normal vectors of both shapes and their cross products as potential seperating axis. You can simplify this if there are several of parallel edges (as in the case of two AABBs e.g.). So the number of tests you must do to prove the shapes are not overlapping is equal to the number of unique vectors of the set (normals and cross products).
You might also want to remember which axis separated the shapes in this frame and check that one first the next time, in order to exit the test early.

ps.:
Eberly (of course) has an indepth documentation of all this here:MethodOfSeparatingAxes.pdf and in his book on Game Engine
Architecture.

#3 Akinak

    Member

  • Members
  • PipPip
  • 52 posts

Posted 04 April 2008 - 05:37 AM

i think some edges arent necessary to check /
for example:
let CC be a vector frome center of A to B
and Vn the normal vector to one of A's edges /
if the angle between CC & Vn is < 90 then checking this edge is useless ( in the other word this edge is in other side of polygon A that cant have intersection with B )

[edit]
since my english is poor , is use international language of pictures !
Posted Image

#4 .oisyn

    DevMaster Staff

  • Moderators
  • 1822 posts

Posted 04 April 2008 - 11:10 AM

How true that might be, if you do that you're no longer allowed to remove parallel edges. For example, the edge opposite to the blue one is parallel to the blue edge. Since they share an axis, the projection will be the same, and the edge can be removed for the purpose of the SAT. However, with your optimization you take the direction of the edges' normals into account, so you can no longer remove parallel edges. It depends on the types of volumes what is more optimal.

Another thing, "center" is a pretty arbitrary point. Your statement is true for any point on A and any point on B :).

@Nico: this is a 2D test. The edges are the 2d equivalent of the planes in 3d, and there are no equivalents for the edges in 3d so the crossproduct part is not necessary.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#5 Akinak

    Member

  • Members
  • PipPip
  • 52 posts

Posted 05 April 2008 - 05:38 AM

Quote

if you do that you're no longer allowed to remove parallel edges
with this optimization, we dont need to remove parallel edges/
if you compute edges clockwise & all normals left handed / then automatically one of parallel edges will be removed ( although they are parallel , but their left hand normal vectors have 180 degree difference )
so we no longer need any other optimization to remove parallel edges ...

Quote

Another thing, "center" is a pretty arbitrary point. Your statement is true for any point on A and any point on B .
yes , thats true ...

im now working on time in collision to handle objects with fast velocity that can pass an intersection in one frame/ handling linear velocity should be easy, but for angular velocity , i dont have any idea .. ??!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users