I would like to draw a cloud programmatically. For this reason I need to know where to draw the next circle around the ellipse.
Given the chord (circle radius), how can I calculate the next point in the ellipse?
Thanks!
I would like to draw a cloud programmatically. For this reason I need to know where to draw the next circle around the ellipse.
Given the chord (circle radius), how can I calculate the next point in the ellipse?
Thanks!
Copyright © 2021 JogjaFile Inc.
Suppose the ellipse is centered at $(0,0)$ with equation $x^2/a^2+y^2/b^2$, with major and minor axes alligned with the $x$ and $y$ axes. This ellipse can be parametrized by $(x,y)=(a \cos t, b \sin t)$, and as the parameter $t$ increases, the point moves around the ellipse in a counterclockwise direction.
If your first center is at $(x_1,y_1)$ then first find the $t$ value (call this $t_1$) by use of $\cos t_1=x_1/a,\ \sin t_1 = y_1/b.$ Now let $t$ be the parameter value for your "next" circle center, which is to be the first point, going around the ellipse counterclockwise, which is at distance $r$ from $(x_1,y_1).$ Set up the squared distance to $(x_1,y_1)$ as $$f(t)=a^2(\cos t - \cos t_1)^2 +b^2 (\sin t -\sin t_1)^2.$$ This starts out as $0$ when $t=t_1$, and you can (since it's a program) now increment $t$ and get the least $t$ beyond $t_1$ for which $f(t)=r^2.$ [This will likely involve some sort of bisection approach, once you find a value of $t$ for which $f(t)>r^2$, then back up, etc. (I tried getting an exact expression for this first $t$ value but it was a bit involved, maybe not possible in closed form...)
Anyway after the value of $t$ is found as above your "next center" say $(x_2,y_2)$ becomes $(a \cos t,b \sin t).$