T
T
TCloud2019-09-18 15:18:54
JavaScript
TCloud, 2019-09-18 15:18:54

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/
5d821fb8d142d003965933.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
RAX7, 2019-09-19
@OTCloud

M
Mercury13, 2019-09-18
@Mercury13

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?

K
Karpion, 2019-09-18
@Karpion

And what is needed? Constant pitch, equal distance between points? Then the angle must be taken inversely proportional to the radius - it works if the radius is greater than the step.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question