- Home /
Getting the area of the intersection of two polygons.
This is two questions in one. 1) Does Unity have something to calculate the intersection of two polygons? 2) Does Unity have a way of calculating the area of a polygon?
Answer by sparkzbarca · Nov 10, 2012 at 09:06 AM
A Does unity have someway to detect where 2 shapes collide? thats call collision detection.
the formula for the area of a polygon is well known
http://www.mathopenref.com/polygonregulararea.html
squareing and tangent and all the hard math stuff does indeed have functions in mathf
like mathf.tan
You just write the formula found on the website using the mathf functions for things like the square of a number and the tangent.
Thanks, but with collision detection you can know whether two objects collided. What I want is to get the polygon that represents the intersection of two polygons.
The link you provide gives the formula to calculate regular polygons. I don't mean regular polygons, just polygons, that is, irregular polygons. It's pretty trivial too, you just get the list of triangles of the mesh and calculate each triangles area but I wanted to know if Unity does already have a function for that.
sorry im confused, if 2 squares intersect how does that make another square or shape.
Or are you like saying basically you want to kind of place one shape over another and get only the area they share and not the areas they dont.
A kind of venn diagram of that takes the 2 circles or whatever and returns only the overlap?
Exactly, that's intersection in geometry. Suppose you have translucent foil paper, one sheet of color yellow and one sheet of color blue. You place them overlapping. The area that you'll see in color green, is the intersection of both sheets, I.$$anonymous$$ polygons.
Answer by Loius · Nov 10, 2012 at 09:43 PM
As far as I'm aware, Unity doesn't know what a polygon is - it only keeps track of individual triangles.
You could teach it about polygons and intersection, like you mentioned, but it's not a default option.
Your answer
![](https://koobas.hobune.stream/wayback/20220613083550im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Intersection area of two objects? 0 Answers
Problem with getting colliding objects 3 Answers
low impact alternitve to onTriggerEnter 1 Answer
Intersection of two lines 0 Answers
Finding the polygon/face your'e currently looking at? 2 Answers