Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4531442
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T13:54:27+00:00 2026-05-21T13:54:27+00:00

I have a triangle (red, below). (or a 2D mesh of triangles) How can

  • 0

I have a triangle (red, below). (or a 2D mesh of triangles)

How can I compute the polygons (and in turn tessellate them) that result from subtracting a second triangle (green) from the first?

enter image description here

(I’m using Python and I’m looking for an explanation and pseudo-code of an approach I can take, rather than recommendations for opaque libraries. (I currently use gluTess*() to do the tessellation of polygons, but an explanation of how to do the tesselltation myself would be interesting; my pressing problem is really the Boolean operation itself though.) It will be exciting to learn and understand the solution. My triangles are always counter-clockwise winding, if that makes any difference.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T13:54:27+00:00Added an answer on May 21, 2026 at 1:54 pm

    Let’s walk through some scenarios…

    Case 1: Triangles do not overlap (or they are tangent but not overlapping)
    Case 1

    Test for this case by using a point-in-polygon algorithm to see if any of the three vertices of one of the triangles lies inside of or on the other.

    If we are in Case 1, we don’t need to do anything.

    Case 2: Green triangle is inside of red triangle.

    Case 2

    Test for this case by either using a point-in-polygon algorithm to see if all three of the green vertices are inside of the red triangle. Another way to test this is to see if any of the 3 line segments of the green triangle intersect with any of the 3 line segments of the red triangle; use an algorithm like this for intersection (additionally you have to also check to make sure at least one green vertex in inside the polygon – just to make sure your lack of intersecting lines isn’t because you are actually running into Case 1).

    Now for this case, draw a line segment from each of the green vertices to each of the red vertices (total of 9 new line segments). If any of these new line segments cross into the green triangle then remove them (you can check for this by using the line segment intersection method against each of the green triangle’s sides). Now, test to see if any of the remaining new line segments intersect with each other; if any two do, then eliminate one, and retest until you have no more new line segments intersecting with each other.

    Case 2 - Solving

    Case 3: Green triangle overlaps red triangle, where two sides of the green triangle enter into the red triangle and also leave the red triangle.

    Case 3

    Test for this case by checking to see that exactly two green sides each intersect with two red sides. Again use the line segment intersection algorithm.

    Now for this case, draw a line segment from each of the intersection points (each place where a green side intersects with a red side) to each of the red vertices. If any of these line segments basically duplicate the red edges then remove them. If any of these new line segments cross into the green triangle then remove them (you can check for this by using the line segment intersection method against each of the green triangle’s sides). Now, test to see if any of the remaining new line segments intersect with each other; if any two do, then eliminate one, and retest until you have no more new line segments intersecting with each other.

    Case 3 - Solving

    Case 4: Green triangle overlaps red triangle, where two sides of the green triangle enter into the red triangle but they do not leave the red triangle out another side.

    Case 4

    Test for this case by checking to see that exactly two green sides each intersect with exactly one red side (it doesn’t necessarily have to be the same side for each). Again use the line segment intersection algorithm.

    Now for this case, draw a line segment from the green vertex that is inside of the red triangle (use the point-in-a-polygon algorithm to determine which green vertex is inside of the triangle) to each of the red triangle vertices.

    enter image description here

    Case 5: Green triangle overlaps red triangle, where only one side of the green triangle enter into the red triangle and where that same green side exits a different side of the red triangle.

    enter image description here

    Test for this case by checking to see that exactly one green side intersects with exactly two red sides. Again use the line segment intersection algorithm.

    Now for this case, draw a line segment from each of the intersection points (each place where a green side intersects with a red side) to each of the red vertices. If any of these line segments basically duplicate the red edges then remove them. If any of these new line segments cross into the green triangle then remove them (you can check for this by using the line segment intersection method against each of the green triangle’s sides). Now, test to see if any of the remaining new line segments intersect with each other; if any two do, then eliminate one, and retest until you have no more new line segments intersecting with each other.

    Case 5 = Solving

    And hopefully at this point you are done!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some triangle polygons and drawing them in a traditional way: (android-java code)
I have a polygon soup of triangles that I would like to construct a
We have triangle made of blocks. The topmost row has 1 block, the next
I have a triangle drawn by a user and all the points are stored
I have one triangle ad one circle moving objects on plane.How will i know
I have a reference model, (for example a triangle), with its 'up' vector definied
I want to draw a circle which will have (inside) triangle fans with the
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you guys had any experiences (positive or negative) by placing your source code/solution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.