I have found this equation in a paper which represents a helix-shaped movement of an object:
When I plotted the S
vector in Matlab I got a different result, not helix shape.
Where is the problem, is it in the equation or in the code?
l
is a random number in [-1,1]
r
is a random vector in [0,1]
b
is a constant for defining the shape of the logarithmic spiral.
Matlab code:
dim =3;
Max_iter =10;
X_star=zeros(1,dim);
ub = 100;
lb = -100;
X=rand(1,dim).*(ub-lb)+lb;
S = [];
t=0;
while t<Max_iter
a=-1+t*((-1)/Max_iter);
r=rand();
b=1;
l=(a-1)*rand + 1;
for j=1:size(X,2)
D= abs(X_star(j) - X(1,j));
X(1,j)= D * exp(b.*l).* cos(l.*2*pi) + X_star(j);
end
X_star=X(1,:);
S = [S X];
plot(S);
t = t+1;
end