Jump to content


- - - - -

Separating axis test


1 reply to this topic

#1 Nyad

    Member

  • Members
  • PipPip
  • 44 posts

Posted 28 March 2008 - 12:46 PM

Hi I am trying to understand this code from the separating axis test.


bool TestIntersection(Object o1, Object o2) {

    float min1, max1, min2, max2;

    for (int i = 0, n = o1.NumFaceDirs(), i < n; i++) {

        GetInterval(o1, o1.GetFaceDir(i), min1, max1);

        GetInterval(o2, o1.GetFaceDir(i), min2, max2);

        if (max1 < min2 || max2 < min1) return false;

    }

    for (int i = 0, n = o2.NumFaceDirs(), i < n; i++) {

        GetInterval(o1, o2.GetFaceDir(i), min1, max1);

        GetInterval(o2, o2.GetFaceDir(i), min2, max2);

        if (max1 < min2 || max2 < min1) return false;

    }

    for (int i = 0, m = o1.NumEdgeDirs(), i < m; i++)

        for (int j = 0, n = o2.NumEdgeDirs(), j < n; j++) {

            Vector axis = Cross(o1.GetEdgeDir(i), o2.GetEdgeDir(j));

            GetInterval(o1, axis, min1, max1);

            GetInterval(o2, axis, min2, max2);

            if (max1 < min2 || max2 < min1) return false;

        }

    return true;

}


What I don't understand is this line:
Vector axis = Cross(o1.GetEdgeDir(i), o2.GetEdgeDir(j));
what is this EdgeDir?
is it
v1=[5.0f,6.0f,4.0f]
v2=[3.0f,1.0f,8.0f]
edgedir= [5-3,6-1,4-8]
?

#2 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 28 March 2008 - 03:08 PM

Exactly.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users