V
V
Vitaly Stolyarov2018-03-24 22:05:50
Mathematics
Vitaly Stolyarov, 2018-03-24 22:05:50

How to find the coordinates of the ray that divides the figure into parts equal in area?

In three.js I use Shape. Based on it, I build a contour using Bezier curves.
It is necessary to find the Y coordinate along which the figure is divided along this contour into parts equal in area.
So far, only triangulation of the figure comes to mind, dividing in half and counting the area on each side, and so move towards the part with a larger area until the area of ​​\u200b\u200bboth parts is the same with an allowable error

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Stolyarov, 2018-03-25
@Ni55aN

Solution: https://codepen.io/Ni55aN/pen/aYyPoB
Algorithm:
1. Triangulate Shape (we immediately get ShapeGeometry)
2. Get the area of ​​the figure (from the resulting geometry)
3. Set the initial coordinate y = 0.5, relative to which Y will be the figure is divided
4. Cut off the upper part of the geometry
5. Get the area of ​​the remaining lower geometry
6. Calculate the error delta = 0.5-area/originalArea, where area is the area of ​​the lower part, originalArea is the area of ​​the entire figure. Thus, we obtain the coefficient by which we need to shift the coordinate in order to equalize the areas of the lower and upper parts
7. Repeat from step 4 with a new y = y + delta * h until the difference in the area of ​​the halves of the figures is acceptable, where h is the height of the figure

X
xmoonlight, 2018-03-24
@xmoonlight

1. We count the number of points inside the figure - this is the total area
2. Find the center of mass
3. If the figure can be rotated: find the line of symmetry passing through the center of mass and rotate the figure so that the line of symmetry is horizontal (along the X axis).
4. We cut off the figure in half with a horizontal beam passing through the center of mass.
5. Compare the areas of the upper and lower parts.
6. Move the beam up or down to equalize areas.
7. Profit!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question