CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Triangle-triangle intersection in 2D

    I need to compute the area of the region of intersection between two 2D triangles. (Well, actually, the total intersection between two sets of triangles, but let's start with just two.)

    So far my research has pointed to a barycentric coordinate test as the fastest approach. This easily lets me test whether one tri is completely contained in the other, or has some of its vertices inside the other.

    But there's a case which isn't covered by the simple point-in-triangle test: the six-point ("Jewish") star. Here, all six vertices are outside the other triangle, yet there's clearly lots of overlap.

    I was wondering if anyone knows a simple, definitive rule for solving this problem. Otherwise, I'll just need to start figuring out conditions on barycentric coordinate signs and the like.

    Incidentally, once I've found all points along the (convex) overlap region, I can use the area-of-convex-polygon formula to get the intersection area. Each of these points will either be a triangle vertex inside the other triangle, or an intersection of two triangle edges.

  2. #2
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    Re: Triangle-triangle intersection in 2D

    Quote Originally Posted by Lindley View Post
    I was wondering if anyone knows a simple, definitive rule for solving this problem. Otherwise, I'll just need to start figuring out conditions on barycentric coordinate signs and the like.
    How about looking at the points where the sides of the different triangles intersect. If the triangles intersect, their sides must intersect as well, so this approach should always work. Not sure how it will work out performance wise, though.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  3. #3
    Join Date
    Oct 2006
    Posts
    616

    Re: Triangle-triangle intersection in 2D

    See this page on polygon intersection area (+code in C and java).

    Regards,
    Zachm

  4. #4
    Join Date
    Nov 2011
    Posts
    3

    Re: Triangle-triangle intersection in 2D

    Hi Lindley ,

    I find your message while searcing the algorithm for fingding the intersection area of two triangles. There are lots of documantry about this but anyone of them dont help me and i am lost. Could you help me to find my way ?

    If you interest i would be greatfull.

    sincerely

  5. #5
    Join Date
    Nov 2011
    Posts
    3

    Re: Triangle-triangle intersection in 2D

    Is there anybody to help for this problem ? it is about my final project and dont have much time.I really need your help.

  6. #6
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Triangle-triangle intersection in 2D

    Unfortunately I don't think I ever finished solving this problem; instead I modified my approach to take an entirely different tack.

  7. #7
    Join Date
    Nov 2011
    Posts
    3

    Re: Triangle-triangle intersection in 2D

    Thank you again for your interest. but as you see i am still verdant of matlab programing. maybe you can help me at least about how to compute the convex hull of this two triangle in the code.

    clc
    clear all




    P(1, = [0.9 2.1];
    P(2, = [2.8 5.2];
    P(3, = [5.7 2.3];




    Q(:, = ...
    [2.7 1.1
    5.6 4.1
    8.0 1.8];




    X = [P(:,1)
    P(1,1)];

    Y = [P(:,2)
    P(1,2)];

    line(X,Y)



    A = [Q(:,1)
    Q(1,1)];

    B = [Q(:,2)
    Q(1,2)];

    line(A,B)

  8. #8
    Join Date
    Jan 2012
    Posts
    1

    Post Re: Triangle-triangle intersection in 2D

    Hello Lindley,

    I am 1st PhD student, and recently I have worked on how to determine the intersection points of triangles. So could you please do me a favor? Thank you so much.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured