Given the cor开发者_开发技巧dinates of all corners of a quadrilateral, how can the cordinates of its center be found?
Thanks.
I suppose you are talking about the centroid or center of masses. In a quadrilateral there are two general ways of getting the coordinates:
Intersection point of the two bimedians (A bimedian is the line joining the center points of two opposing sides).
The midpoint of the line joining the midpoints of both diagonals of the quadrilateral.
Hope this helps.
Origin = x=0,y=0
a(0,0) b(10,0)
c(0,5) d(10,5)
a+(b-a/2)=5
a+(c-a/2)=2.5
centre co-ordinate = 5,2.5
or dx-ax/2=5
dy-ay/2=2.5
with those formulas it wouldn't matter if the sides were uneven the centre can always be calculated.
Regards Ray
If your shape is defined by a piecewise continuous curve you can do numerical integration using Gaussian quadrature of a contour integral for the center of mass. This is the most general algorithm for 2D planar shapes. It'll even work for shapes with holes inside.
You get the contour integral using Green's Theorem.
You can also cut up the quadrilateral in two triangles, take their centre and find the centre between them.
Doesn't really change anything but it might be easier to think about (ps. I don't say this would yield a particularly better solution).
精彩评论