• This topic has 0 replies, 1 voice, and was last updated 3 years ago by tmk.
Viewing 0 reply threads
  • Author
    • #8848 Score: 0
      4 pts


      // Check to see if a Vector3 Point is within a 3 Vector3 Triangle
              bool inTriangle(Vector3 point, Vector3 tri1, Vector3 tri2, Vector3 tri3)
                  // Test to see if it is within an infinite prism that the triangle outlines.
                  bool within_tri_prisim = SameSide(point, tri1, tri2, tri3) && SameSide(point, tri2, tri1, tri3)
                                           && SameSide(point, tri3, tri1, tri2);
                  // If it isn't it will never be on the triangle
                  if (!within_tri_prisim)
                      return false;
                  // Calulate Triangle's Normal
                  Vector3 n = GenTriNormal(tri1, tri2, tri3);
                  // Project the point onto this normal
                 <strong> Vector3 proj = math::ProjV3(point, n);</strong>
                  // If the distance from the triangle to the point is 0
                  //	it lies on the triangle
                  if (math::MagnitudeV3(proj) == 0)
                      return true;
                      return false;
Viewing 0 reply threads
  • You must be logged in to reply to this topic.