Just length and width is all I need. The center of a 2D lopsided square. I figure once you know how to do it in 2D you can easily do it in 3D anyway if needed.

Probably your easiest approach is to break it into triangles, which also simplifies the problem of what to do if two sides aren't parallel. Find the centroid and area of one triangle, then the centroid and area of the other, and get a weighted average.

To get the centroid of a triangle you find the intersection of its medians, so you'd take a line from halfway along one vector and draw it to the opposite corner, and then do that with a different vector, find the intersection, and there you are. I can't remember the area formula in terms of vectors for the life of me, but I'd bet it's related to the cross-product. (Actually check that; the area is the cross-product, the absolute value of it at least. Doh.)

Lummox JR

#8 Oct 19 2009, 2:15 pm (Edited on Oct 19 2009, 2:40 pm)

In that diagram, A is 28 (14-(-14)), B is 62 (31-(-31)), C is 17 (31-14), h is 110 (55-(-55)). With these values A, B, C, h, we can find the center as:

More difficult than I thought it was. So, we can compute:
Cx = (2*28*17 + 28^2 + 17*62 + 28*62 + 62^2)/(3*(28+62)) = 31
Cy = (110(2*28+62))/(3*(28+62)) = 48.0740741

These values Cx, Cy, are from point -55, 31

[Edit]
Yeah, Cy is right, because it's going to be a little more left leaning than "centered". So, in the end, the Center is at location (6.9259259,0)

A is 28 (14-(-14)), B is 62 (31-(-31)), C is 17 (31-14), h is 110 (55-(-55)). With these values A, B, C, h, we can find the center as:
Cx = (2ac+a^2+cb+ab+b^2)/(3(a+b))
Cy = (h(2a+b))/(3(a+b))
Cx = (2*28*17 + 28^2 + 17*62 + 28*62 + 62^2)/(3*(28+62)) = 31
Cy = (110(2*28+62))/(3*(28+62)) = 48.0740741

... Nevermind. Too darn complicated for my inferior math skills. Isn't there a library for this somewhere?

It also appears that I need to calculate the Center of Gravity, not just the center. (Apparently there's a difference.) I've found a site that explains how to do this:

It also appears that I need to calculate the Center of Gravity, not just the center. (Apparently there's a difference.) I've found a site that explains how to do this:

I just don't know how to translate what its saying to do into math.

The formulas mentioned here will suffice, unless your trapezoids are not of uniform density (e.g., varying thickness of the material from one end to the other). When density is uniform, the geometric center is the same as the center of mass.

I'm not sure what the formulas mentioned here result in, but from the look of the picture on that site it'll end up something like this:

Now that may be mathematically the center of the shape, but it certainly is not the center of gravity, since if that were a piece of wood and you attempted to balance it at the intersection, the south side would be notably heavier than the north side.

Do you know how to determine the coordinates of an intersection? If you have four points, and you draw two lines between them making an X, how do you determine where the intersection is?