cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Translate the entire conversation x

How to plot Barnsley fern fractal?

Cornel
19-Tanzanite

How to plot Barnsley fern fractal?

Hi,

How a Mathcad program will look like in which Barnsley fern  fractal plot can be seen?

Cornel_0-1755789749960.jpeg

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:Cornel)

Here is the main part of my sheet in P10 format

View solution in original post

12 REPLIES 12
Werner_E
25-Diamond I
(To:Cornel)

Maybe not exactly what you are asking for (beacuse I guess you had Prime in mind, not Mathcad) but this thread possibly can give you some inspirations for own attempts. 

Fractals in Mathcad - PTC Community

 

Viktor's sheet uses xy-plots to show the results, so it may work in Prime as well (apart from the list box for selecting the fractal type). For testing purpose you may manually set variable "A" to a value from 1 to 101.
Creating a bitmap would provide better resolution and (if desired) a wider range of different colors. Its a real PITA that Prime does not provide an image operator and so bitmap images created could be displayed automatically directly in the sheet.

 

Fractal A=78 uses exactly the IFS matrix for the Barnsley fern:

Werner_E_0-1755793081656.png

 

Fractals.gif

Werner_E
25-Diamond I
(To:Werner_E)

I wondered why Viktors sheet won't render the stem of the fern and found the error in two parameters of the first iteration function which where erroneously exchanged. It should read

Werner_E_0-1755805992097.png

farn.gif

 

Hi,

Here is the Prime 11 version with @Werner_E correction to get stem of fern.

The list box works on conversion.

 

Cheers

Terry

Werner_E
25-Diamond I
(To:Cornel)

Here is my version for plotting IFS driven iterations.

My approach uses a function to come up with the final coordinates instead of range variables so we could inspect multiple different fractals side by side.

Also the function does not mind how many iteration function are defined - it automatically deals with the number of functions provided in the matrix.

I also automated the creation of the list box to select a fractal. Once a new fractal type is added to the list (providing a name and the IFS matrix) the list box automatically updates and presents the fractal names in alphabetical order.

This uses a scripted component and the converter was not able to convert it correctly to a scripted Prime component. Rather the Prime file remains unusable. Its a shame how much work and modifications we have to apply to make a converted Prime sheet to look and work as expected.

 

Because scripted components are used you have to answer the security query at load time with "no" in case of Mathcad and with "yes" in case of the Prime sheet 😉

 

The plots are so much limited in Prime that its not possible to duplicate the look we have in Mathcad. We cannot remove the axis, cannot set a background color and as our plots uses more than 5000 points we are not even allowed to set the size of the points plotted which come out far too tiny.  So to have at least the best contrast available the plot is made in black in pure white background. Too bad!

Even when I do likewise in Mathcad its quite a difference to the Prime result:

Werner_E_0-1755837128296.pngWerner_E_1-1755837141275.png

I have added a couple of fractals from Viktor's sheet but not all (just 25 of the 101 provided in Viktor's sheet). Feel free to add more fractals from Viktor's sheet or make your own attempts. It should be quite obvious how to add more fractals to the list.

 

Attached are my original Mathcad (15) sheet and the converted and reworked Prime 11 sheet.

EDIT: Added random IFS in P11 sheet. So far no remarkable results. The best so to day has been

Werner_E_0-1755849525725.png

Note that the last column are not actually probabilities  (otherwise they would have to add up to 1). My program turns them into probability values by dividing them by the sum of that column.

 

Werner_E
25-Diamond I
(To:Werner_E)

Synchronized the Mathcad and the Prime version (= added the random IFS in MC15)

Here are some random IFS plots from MC15

random26.gifrandom2.gif

 

Furthermore I added "Chaos"

Werner_E_0-1755856176561.png

 

EDIT: Modified "Random" so that also the number of iteration functions is chosen randomly from 2 to 9.

Modified files are attached here

RandomN-150.gif

StuartBruff
23-Emerald IV
(To:Cornel)

Here's another (probably very similar) take on the Barnsley Fern.  It's a slight revamp of an old (Mathsoft) Mathcad 11 updated for Mathcad Prime 11.

 

2D Plot - Barnsley Fern

 

2025 08 23 B.png

 

Greyscale Bitmap - Barnsley Fern and Variants

 

2025 08 23 A.png

 

RGB Bitmaps - Barnsley Fern

 

2025 08 23 E.png

 

2D Plot - Random (Babylon 5 Shadow!)

 

2025 08 23 D.png

 

Clearly still needs work.  I used the ComboBox in an earlier Mathcad Express 7 variant, taking advantage of its inline capability.   I've got another development worksheet that I've just added a ListBox to, but I don't know how to inline it.  It would have been nice to have an Advanced version of the ListBox, so that I could easily automate filling it from the IFS library in the attached worksheet.

 

Stuart

 

 

 

 

 

 

Catalina
Moderator
(To:Cornel)

Hi @Cornel,

I wanted to see if you got the help you needed.

If so, please mark the appropriate reply as the Accepted Solution or please feel free to detail in a reply what has helped you and mark it as the Accepted Solution. It will help other members who may have the same question.

Of course, if you have more to share on your issue, please pursue the conversation.

Thanks,


Catalina
PTC Community Moderator
PTC
Cornel
19-Tanzanite
(To:Catalina)

Sorry, I do not have yet Prime 11 installed on my laptop (only Prime 10.1 at this moment). My company has not introduced yet this 11th version (I understood that it will be introduced, but do not know exactly the date). So I cannot see the above solutions yet.

StuartBruff
23-Emerald IV
(To:Cornel)

OK. I’ve got MP10. I’ll see if I can put together an MP10 version this afternoon (GMT+1 Summer Time)).
Werner_E
25-Diamond I
(To:Cornel)


@Cornel wrote:

Sorry, I do not have yet Prime 11 installed on my laptop (only Prime 10.1 at this moment). My company has not introduced yet this 11th version (I understood that it will be introduced, but do not know exactly the date). So I cannot see the above solutions yet.


Why didn't you say so a week ago after the first reply?

 

Feel free to use the converter in your MP10 and try to convert the MC15 file I had attached. Sure will need some rework to make it running, though. After all a week ago you just asked how a Mathcad program would look like and you sure can see how it does if you convert either my MC15 sheet or the one provided in the link to the old thread i posted.

StuartBruff
23-Emerald IV
(To:Cornel)

MP10 version of my MP11 IFS worksheet attached.

 

Stuart

Werner_E
25-Diamond I
(To:Cornel)

Here is the main part of my sheet in P10 format

Announcements

Top Tags