Equalise point-distance when optimising points on graph

27 Views Asked by At

Recently I have been learning about optimisation-techniques and built a simple "gradient-descent brachistochrone solver thingy" to try out some methods.

One thing currently still hurting the results is the distancing of the points. Obviously, if they are first generated an equal distance on the x-axis apart from each-other, when the resulting graph becomes non-linear the distances between them start to vary quite significantly.

different points spacing example image

Especially between the first two points there is obviously a massive "hole".

What I would like to as is, if there is any well-established method of spacing these points by their distance from each-other instead of evenly along one axis. This at first doesn't seem to be too hard a problem; just move them a bit to be at the right place for their heights. This doesn't really work however, because when changing the "x-position" of the points their height must be re-adapted as well, leading to another distance-discrepancy and so on and so forth.

As all algorithms I came up with required an ungodly number of iterations to complete, and I was unable to find the correct keywords to google this problem, this is now asked in form of a post on this forum.

Thanks, Robbe.

1

There are 1 best solutions below

1
On

Suppose that ou use the parametrization $$x=r(t-\sin(t)) \qquad \qquad y=r(1-\cos(t))$$ the length os the curve between $0$ and $2\pi$ is given by $$L=\int_0^{2\pi} \sqrt{\text{d}x^2+\text{d}y^2}\,dt=r \sqrt 2\int_0^{2\pi} \sqrt{1-\cos(t)}\,dt =8r$$

So, if you want the points to be at the same distance along the curve, select a first point2 $t_1$ for which the arclength is given by $$L_{0,t_1}=r \sqrt 2\int_0^{t_1} \sqrt{1-\cos(t)}\,dt=8 r \sin ^2\left(\frac{t_1}{4}\right)$$ $$L_{t_n,t_{n+1}}=r \sqrt 2\int_{t_n}^{t_{n+1}} \sqrt{1-\cos(t)}\,dt=4 r \left(\cos \left(\frac{t_n}{2}\right)-\cos\left(\frac{t_{n+1}}{2}\right)\right)$$ Since you want both distances to be equal, knowing $t_n$, you need to solve for $t_{n+1}$ the equation $$\cos \left(\frac{t_{n+1}}{2}\right)=2 \cos \left(\frac{t_{n}}{2}\right)-1$$ which is more than simple.

Knowing the $t_n$, just compute $x_n=r(t_n-\sin(t_n))$.

Please let me know how it works for you.