Viewing 0 reply threads
  • Author
    Posts
    • #8848 Score: 0
      tmk
      Participant
      4 pts

      作业3的OBJ_Loader.h中inTriangle方法为什么是判断点在叉积上的投影,而不是判断点减去另一个三角形顶点(得到一个在三角形平面上的向量)叉积上的投影?

      // 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;
                  else
                      return false;
              }
      
Viewing 0 reply threads
  • You must be logged in to reply to this topic.