Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Ray and convex polygon intersection

  1. #11
    1 other optimization that i'm adding, is approximating the face normal better. It is possible that polygon is not entirely flat. (See attached image) I will be using the method on right. These indices can be count like:
    p0 = 0
    p1 = 1+Count div 5
    p2 = Count-1-Count div 5
    I figured that 5 vertex polygon is smallest one to benefit from this change. It is possible that 3 periodic vertices are in line formation too, and in that case, the left side method (0, 1, 2) would make a really bad normal approximation.
    Attached Images Attached Images

  2. #12
    why not do this:
    p0 = 0;
    p1 = Count div 3;
    p2 = Count * 2 div 3;
    this will give you an even spread of plane base points across the entire polygon.
    btw in your example this will give you exactly the same points as you have on the right picture.

  3. #13
    You're really good at math, and thanks again It wasn't straightforward to come up with pattern that cover all polygon sizes, including triangles.

    The function works fine with triangles still, and it's now in use in the editor too. I hope the (0, 1, 2) vertices weren't necessary somehow for your projection formula, would guess no. Regards to projection, what did it actually do? It transforms vertices to plane of face normal's space? (that sounded weird) It's cool idea, and i noticed immediately how few calculations it's doing. Definitely much much faster than if dealing with normal way like 3D ray-triangle. Kind of genious.

  4. #14
    yes that's pretty much how it works. all the vertices of the polygon and the intersection point are on the same plane, so project them and work with 2d instead of 3d.

Page 2 of 2 FirstFirst 12


Posting Permissions

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