Results 1 to 10 of 14

Thread: Ray and convex polygon intersection

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Ray and convex polygon intersection

    Does anyone have code for ray and convex polygon intersection? I have ray-triangle, but the code goes a little over my head partially.
    http://code.google.com/p/nxpascal/so...Math3D.pas#428

    We can assume a few things...
    Header:
    Code:
      TWordArray = array[0..0] of word;
      PWordArray = ^TWordArray;
    
    function RayPolyIntersect(const rayStart, rayDirection: TVector;
      const vi: PWordArray; Count: integer; BothSided: boolean;
      intersect: PVector; intersectNormal: PVector): Boolean;
    - vi[] is index array to face vertices.
    - Polygon is flat. If it's really not, it will still be treated as flat. Function can estimate it close enough.
    - Polygon is convex. It is the only type of polygon you will see on 3D-models, ever.

    On little theory, i would assume it go like this:
    - We can get the intersection point, something like ray-plane intersect.
    - Then somehow with crossproduct and dotproduct, we would determine if intersection point is outside the polygon.
    Last edited by User137; 20-01-2013 at 06:11 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •