title: Value of parametric constant t in Plane and Ray intersection?
body: <p>I am implementing ray and rectangle intersection test . For that first I test if ray is intersecting plane if it does then I see if it lies in bounds of rectangle.</p>
  
  <p>Following is the code: </p>
  
  <pre><code>float intersectQuad(Ray r, float3 p1, float3 p2, float3 p3, float3 p4, float3* normal)
  {
     float3 x1 = p2 - p1;
     float3 x2 = p4 - p1;
     float t;
  
     float3 n = normalize(cross(x2, x1));
     float denom = dot(n, r.dir); 
  
      if (denom &gt; 0.00000000001) 
      { 
         float3 p0l0 = normalize(p1 - r.origin); 
         t = dot(p0l0, n) / denom; 
  
         printf(" %f ", t);
  
         if( t &gt; 0.000000000001f )
         {
           float3 hitPoint = r.origin + r.dir * t;
  
           float3 V1 = normalize(p2 - p1);
           float3 V2 = normalize(p3 - p2);
           float3 V3 = normalize(p4 - p3);
           float3 V4 = normalize(p1 - p4);
           float3 V5 = normalize(hitPoint - p1);
           float3 V6 = normalize(hitPoint - p2);
           float3 V7 = normalize(hitPoint - p3);
           float3 V8 = normalize(hitPoint - p4);
  
           if (dot(V1,V5) &lt; 0.0f) return 0.0f;
           if (dot(V2,V6) &lt; 0.0f) return 0.0f;
           if (dot(V3,V7) &lt; 0.0f) return 0.0f;
           if (dot(V4,V8) &lt; 0.0f) return 0.0f;
  
           *normal = n;
           return t;
         }
      } 
  
   return 0.0f; 
  }
  </code></pre>
  
  <p>My understanding is the value of <code>t</code> should be <code>0.0f &lt; t &lt; 1.0f</code> 
  but when I print values of <code>t</code> I some time see values <code>&gt; 1.0f</code>.</p>
  
  <p>Is there something wrong in my code?</p>