Answer the question
In order to leave comments, you need to log in
How to implement a spiral movement algorithm?
I implement an algorithm for moving a point in a spiral (Archimedean spiral).
Due to the inaccuracy of the algorithm, it happens that on 3 or more circles the points diverge over a large distance, that is, drawing is lost. How to eliminate this defect?
The code is still raw, but here is a link to JSFiddle: https://jsfiddle.net/u6t1nawz/3/
Answer the question
In order to leave comments, you need to log in
I would make something like this system of equations.
r = sqrt(t)
phi = a r
t - parameter, conditional "time"; phi is the polar angle, r is the length of the radius vector.
Well, respectively, x = r cos phi, y = r sin phi.
In general, the radius (well, or angle) should increase at the rate of the square root.
There is a physical meaning in this case - this is the solution of the difur r′(t)=1/r. I only missed the two and the integration constant, because we don’t seem to need them. The method is not exact, but if you look at the length of the arc of the spiral, there is a quadratic term there.
If you need a VERY stable gap (for example, arrange some circles in a spiral), I have a recurrent algorithm.
How to write a helix algorithm?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question