If you rewrite this method in terms of determinants, then it also has the bonus of generalizing correctly to arbitrarily many dimensions! And it also gives you a nice picture - imagine adding and subtracting simplices with one point at the origin (triangles in 2D, tetrahedra in 3D).
Another interesting thing about the metrix in that answer. If you invert it, the rows become the coefficients for the plane equations of the faces. You also don't need to fully invert it - IIRC the adjoint is sufficient.
I use this in measuring field areas. Like the text reads, this is Green's Theorem.
The area of a triangle ABC can be determined by doing the cross product of any of the vectors that are the translation from a vertex to another (e.g. AB⨯AC = |AB|.|AC|.sin{^BAC}). More rigorously, this is the area of a lozenge, which then has to be divided by two.
Imagining a point X inside a convex polygon, it is easy to see a set of triangles with vertex X in common.
In fact, the polygon can not only be concave but point X can be outside the polygon, since the sine will compensate for negative and positive angles, subtracting any weird triangle out of the sum in the end.
Computationally, the point X should be as close as possible to every vertex, so that rounding errors are minimized.
I worked at a company, HouseCanary, writing software for doing home appraisals. We used this formula to calculate the square footage of a home based on a computer drawing. The funny thing is that for an appraisal, you have to show your calculations. We thought showing the points and a shoelace formula whitepaper would be enough. It wasn't. So, my boss wrote code that dumps the whole calculation onto a pdf so someone who works in lending can say "that looks right".
12 comments
[ 3.5 ms ] story [ 33.1 ms ] threadhttps://stackoverflow.com/questions/1838401/general-formula-...
Another interesting thing about the metrix in that answer. If you invert it, the rows become the coefficients for the plane equations of the faces. You also don't need to fully invert it - IIRC the adjoint is sufficient.
The area of a triangle ABC can be determined by doing the cross product of any of the vectors that are the translation from a vertex to another (e.g. AB⨯AC = |AB|.|AC|.sin{^BAC}). More rigorously, this is the area of a lozenge, which then has to be divided by two.
Imagining a point X inside a convex polygon, it is easy to see a set of triangles with vertex X in common.
In fact, the polygon can not only be concave but point X can be outside the polygon, since the sine will compensate for negative and positive angles, subtracting any weird triangle out of the sum in the end.
Computationally, the point X should be as close as possible to every vertex, so that rounding errors are minimized.