How to compute the center of a polygon in 2D and 3D space
Consider a simple convex polygon in 2D Cartesian space. If given a list of
vertex coordinates sorted in a counter-clockwise orientation like this
[[x0, y0], ..., [xn, yn]]. How could you compute the center of the polygon
(the point inside the polygon that is equidistant to all vertices)?
Also consider a second case where the polygon is placed in 3D Cartesian
space and its normal vector is not parallel to any of the Cartesian axes.
How could you compute the center, without rotating the polygon?
I can read C/C++, Fortran, MATLAB and Python, however any pseudo-code is
also well appreciated.
No comments:
Post a Comment