Plotting / animating Clifford attractors

 Classic List Threaded
7 messages
Reply | Threaded
Open this post in threaded view
|

Plotting / animating Clifford attractors

 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 variableshttp://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)-- --
Reply | Threaded
Open this post in threaded view
|

Re: Plotting / animating Clifford attractors

 On Sat, Sep 7, 2019 at 8:39 PM RT <[hidden email]> 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 variableshttp://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)What you have programmed is not even close to:xn+1 = sin(a yn) + c cos(a xn)yn+1 = sin(b xn) + d cos(b yn) You must do a loop because the second value in x or y is calculated during the first time through the loop.-- -- -- DAS
Reply | Threaded
Open this post in threaded view
|

Re: Plotting / animating Clifford attractors

 In reply to this post by RT From the site you linked: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:maxiterx(k+1) = sin(a*y(k)) + c*cos(a*x(k));y(k+1) = sin(b*x(k)) + d*cos(b*y(k));endplot3(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 GreenOn Sat, Sep 7, 2019 at 8:39 PM RT <[hidden email]> 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 variableshttp://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)-- --
Reply | Threaded
Open this post in threaded view
|

Re: Plotting / animating Clifford attractors

 Thanks!!!On Sat, Sep 7, 2019 at 9:02 PM Brett Green <[hidden email]> wrote:From the site you linked: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:maxiterx(k+1) = sin(a*y(k)) + c*cos(a*x(k));y(k+1) = sin(b*x(k)) + d*cos(b*y(k));endplot3(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 GreenOn Sat, Sep 7, 2019 at 8:39 PM RT <[hidden email]> 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 variableshttp://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)-- -- --
Reply | Threaded
Open this post in threaded view
|

Re: Plotting / animating Clifford attractors

 You're welcome!- Brett GreenOn Sat, Sep 7, 2019 at 9:16 PM RT <[hidden email]> wrote:Thanks!!!On Sat, Sep 7, 2019 at 9:02 PM Brett Green <[hidden email]> wrote:From the site you linked: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:maxiterx(k+1) = sin(a*y(k)) + c*cos(a*x(k));y(k+1) = sin(b*x(k)) + d*cos(b*y(k));endplot3(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 GreenOn Sat, Sep 7, 2019 at 8:39 PM RT <[hidden email]> 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 variableshttp://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)-- -- --
Reply | Threaded
Open this post in threaded view
|

Re: Plotting / animating Clifford attractors

 In reply to this post by RT RT 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) At the bottom of that page is a description of how the plots were made, did you read that? Looks quite a bit more involved than a plain "plot (x, y)". Philip -- Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Reply | Threaded
Open this post in threaded view
|

Re: Plotting / animating Clifford attractors

 In reply to this post by RT El dissabte, 7 de setembre de 2019, a les 20:38:53 EDT, RT va escriure:   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)       Did you see the link to the source code in C by Paul Richards? http://paulbourke.net/fractals/clifford/paul_richards/main.cpp