# C++ Help with Separating Axis Theorem

I am trying to detect collision between two triangles using Separating Axis Theorem however I am unaware what is wrong with my code. The CollisionHelper::isTriangleIntersectingTriangle is called every frame and passes in the vertices of both triangles. It never returns true, however. I’ve been stuck on this for days now. Any help is appreciated.

``glm::vec3 CalcSurfaceNormal(glm::vec3 tri1, glm::vec3 tri2, glm::vec3 tri3) {     //Subtracts each coordinate respectively     glm::vec3 u = tri2 - tri1;     glm::vec3 v = tri3 - tri1;      glm::vec3 nrmcross = glm::cross(u, v);     nrmcross = glm::normalize(nrmcross);     return nrmcross; }  bool SATTriangleCheck(glm::vec3 axis, glm::vec3 tri1vert1, glm::vec3 tri1vert2, glm::vec3 tri1vert3, glm::vec3 tri2vert1, glm::vec3 tri2vert2, glm::vec3 tri2vert3) {     int t1v1 = glm::dot(axis, tri1vert1);     int t1v2 = glm::dot(axis, tri1vert2);     int t1v3 = glm::dot(axis, tri1vert3);     int t2v1 = glm::dot(axis, tri2vert1);     int t2v2 = glm::dot(axis, tri2vert2);     int t2v3 = glm::dot(axis, tri2vert3);      int t1min = glm::min(t1v1, glm::min(t1v2, t1v3));     int t1max = glm::max(t1v1, glm::max(t1v2, t1v3));     int t2min = glm::min(t2v1, glm::min(t2v2, t2v3));     int t2max = glm::max(t2v1, glm::max(t2v2, t2v3));       if ((t1min < t2max && t1min > t2min) || (t1max < t2max && t1max > t2min))             return true;     if ((t2min < t1max && t2min > t1min) || (t2max < t1max && t2max > t1min))             return true;      return false; }  bool CollisionHelper::isTriangleIntersectingTriangle(glm::vec3 tri1, glm::vec3 tri2, glm::vec3 tri3, glm::vec3 otherTri1, glm::vec3 otherTri2, glm::vec3 otherTri3) {     //Triangle surface normals, 2 axes to test     glm::vec3 tri1FaceNrml = CalcSurfaceNormal(tri1, tri2, tri3);     glm::vec3 tri2FaceNrml = CalcSurfaceNormal(otherTri1, otherTri2, otherTri3);      glm::vec3 tri1Edge1 = tri2 - tri1;     glm::vec3 tri1Edge2 = tri3 - tri1;     glm::vec3 tri1Edge3 = tri3 - tri2;     glm::vec3 tri2Edge1 = otherTri2 - otherTri1;     glm::vec3 tri2Edge2 = otherTri3 - otherTri1;     glm::vec3 tri2Edge3 = otherTri3 - otherTri2;      //axes     //TODO: may need to (un)normalize the cross products     glm::vec3 axis1 = tri1FaceNrml;     glm::vec3 axis2 = tri2FaceNrml;     glm::vec3 axis3 = glm::normalize(glm::cross(tri1Edge1, tri2Edge1));     glm::vec3 axis4 = glm::normalize(glm::cross(tri1Edge1, tri2Edge2));     glm::vec3 axis5 = glm::normalize(glm::cross(tri1Edge1, tri2Edge3));     glm::vec3 axis6 = glm::normalize(glm::cross(tri1Edge2, tri2Edge1));     glm::vec3 axis7 = glm::normalize(glm::cross(tri1Edge2, tri2Edge2));     glm::vec3 axis8 = glm::normalize(glm::cross(tri1Edge2, tri2Edge3));     glm::vec3 axis9 = glm::normalize(glm::cross(tri1Edge3, tri2Edge1));     glm::vec3 axis10 = glm::normalize(glm::cross(tri1Edge3, tri2Edge2));     glm::vec3 axis11 = glm::normalize(glm::cross(tri1Edge3, tri2Edge3));      //Perform SAT     if (SATTriangleCheck(axis1, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis2, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis3, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis4, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis5, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis6, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis7, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis8, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis9, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis10, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;     if (SATTriangleCheck(axis11, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;      return false; } ``