How would I go, if I need to invert the area of a triangle, in 2D. Need this logic for a game. As I'm trying to mark everything but the area of the triangle.
I hope enough info is provided.
How would I go, if I need to invert the area of a triangle, in 2D. Need this logic for a game. As I'm trying to mark everything but the area of the triangle.
I hope enough info is provided.
Copyright © 2021 JogjaFile Inc.
If you know some vectors and linear algebra you can transform the point you wonder if inside into the coordinate system with center in one of corners of triangle and unit axes pointing at the other corners.
Now if any one of the coordinates in the new coordinate system is negative OR the sum >1 then you are outside the triangle.
So if we have one vector pointing to one corner $\bf o$. Then two other vectors pointing to the other corners (from that corner) $\bf p_1,p_2$:
Just to show it works: