This commit is contained in:
Miloslav Ciz 2023-07-05 15:15:51 +02:00
parent ba68a469d5
commit aa7684dc19
10 changed files with 53 additions and 10 deletions

View file

@ -53,7 +53,7 @@ Triangles also play a big role e.g. in [realtime](realtime.md) [3D rendering](3d
[Sierpinski triangle](sierpinski_triangle.md) is a [fractal](fractal.md) related to triangles.
**Testing if point lies inside 2D triangle**: one way to do this is following. For each triangle side test whether the winding of the tested point and the side is the same as the winding of whole triangle -- if this doesn't hold for any side, the point is outside the triangle, otherwise it is inside. In order words for each side we are testing whether the tested point and the remaining triangle point are on the same side (int the same half plane). Here is a [C](c.md) code:
**Testing if point lies inside 2D triangle**: one way to do this is following. For each triangle side test whether the winding of the tested point and the side is the same as the winding of whole triangle -- if this doesn't hold for any side, the point is outside the triangle, otherwise it is inside. In order words for each side we are testing whether the tested point and the remaining triangle point are on the same side (in the same half plane). Here is a [C](c.md) code:
```
int pointIsInTriangle(int px, int py, int tp[6])