Rectangular from four non-corner points

Hi guys, I have 4 centroid points, from these 4 points (non-corner) I intended to create a rectangular, given I only know the location of the four points. Is there a way to do this?

Thanks in advance!

The problem of your approach is that those four points can define an infinite number of rectangles.
Better take the approach of defining corners.

Hi @architectcoding!

I think you’re right. But with the information I have, I’m not sure of the best way to do this. Briefly, I actually have 4 solids “line” like the in the image below, what I’m trying to do is get the center lines of the 4 solids, so that I can get its center curve. So far I have only comes to extracting its centroid and trying to form a rectangular from those points. I guess there should be a better approach to my problem?

If you have the center curves, you could just offset those curves by 1/2 the distance between the other center points.

That’s exactly the information I don’t have at the moment.:persevere:

I’m confused. By the first image, it looks like you have 4 points that are at the center of the lines. Can’t you make lines using those 4 points (index 0 and 2, and index 1 and 3) to make the center lines?

That’s not corner points, you can’t make a rectangular from those points. The best you can get is a diamond shaped polygon.

I know it’s not, I said the center points, not corner points. That is why I said this:

If you have the horizontal line and the vertical line, offset them by half the length of the other.

Assuming the four solids are individual objects, getting the points which make up all edges of the geometry and doing a line by best fit through points may work better.

If you only need to consider the global coordinate system and your box is axis-aligned, you can use BoundingBox.ByGeometry providing your 4 points as the input, get the min and max points then use them to infer the other two corner points to create a rectangle.

If you need to create a rectangle with a specified rotation to the global coordinate system, you can use simple trigonometry and all cases should be solvable (in theory) so long as you accept cases where the some of the points do not touch the boundary curves of rectangle (but remain colinear).

3 Likes