help-octave
[Top][All Lists]

## Re: Plotting / animating Clifford attractors

 From: RT Subject: Re: Plotting / animating Clifford attractors Date: Sat, 7 Sep 2019 21:16:26 -0400

Thanks!!!

On Sat, Sep 7, 2019 at 9:02 PM Brett Green <address@hidden> wrote:
Definition
xn+1 = sin(a yn) + c cos(a xn)
yn+1 = sin(b xn) + d cos(b yn)
where a, b, c, d are variables that define each attractor.

In your code, t is a linearly spaced array, and so is x. That's not what you want - you want a recurrence relation. Also, you want a 3D plot if you wish to produce images like those. Here is an example:

x(1)=1;
y(1)=1;
a = -1.24458;
b = -1.25191;
c = -1.815908;
d = -1.90866;

maxiter = 1000;
z = linspace(1,maxiter+1,maxiter+1);
for k=1:maxiter
x(k+1) = sin(a*y(k)) + c*cos(a*x(k));
y(k+1) = sin(b*x(k)) + d*cos(b*y(k));
end

plot3(x,y,z)

However, this won't produce plots like the one on that page either. At the end of the page is the note,

Question: How are the colour effects here achieved?
Answer: The main thing happening here is that I don't draw the attractor to the final image. Rather I create a large grid of 32 bit (int or float) and instead of drawing into that in colour I evaluate points on the attractor and just increment each cell of the grid if the attractor passes through it. So it's essentially a 2D histogram for occupancy. One wants to evaluate the attractor much more/longer than normal in order to create a reasonable dynamic range and ultimately smooth colour gradients. I then save this 2D grid, the process of applying smooth colour gradients comes as a secondary process ... better than trying to encode the right colour during the generation process. One can even just save the grid as a 16 or 32 bit raw, open in PhotoShop and apply custom gradient maps there.
Of course this is "just" a density mapping of the histogram and doesn't immediately allow for colouring based upon other attributes of the attractor path, such as curvature. But such attributes can be encoded into the histogram encoding, for example the amount added to a cell being a function of curvature.

I would start with getting the data points using a loop like what I gave, and then thinking of a nice way to process it like the note above.

- Brett Green

On Sat, Sep 7, 2019 at 8:39 PM RT <address@hidden> wrote:
I'm trying to plot and animate some Clifford attractors and I'm having problems with the syntax / equation.  The image that is produce looks nothing like the website images and idea how I can adjust the code?

What they look like along with the equation variables
http://paulbourke.net/fractals/clifford/

Code: I'm using:
x=1;
y=1;
t= linspace (0,1000);
a = -1.24458; b = -1.25191; c = -1.815908; d = -1.90866;

x=sin(a*y.*t)+c*cos(x.*t);
y=sin(b*x.*t)+d*cos(y.*t);
plot(x,y)

--
--

--