Logo by Cyclops - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Visit us on facebook
 
*
Welcome, Guest. Please login or register. April 16, 2024, 05:45:27 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Need help, my first program  (Read 1548 times)
0 Members and 1 Guest are viewing this topic.
Klop
Guest
« on: April 28, 2007, 12:52:15 AM »

Hi everybody, I'm new here and I have a question :p

I'm making my very first fractal generation program for university, the problem is that nothing was taught to us about fractals except that the method we're using is the following (I'm using Java):

1. We have an initiator which is the initial Polygon (a vector of Points that connects the last to the first).
2. We have a generator which is a Polyline (a vector of Points that doesn't connect the last to the first) that replaces each of the initiator's vertices every time the function next() is called.

The only problem I'm having is with the scaling, rotating and translating of the generator so that each generator can replace each vertex of the initiator. If hope someone can help me with that. Thanks in advance.

PS: Keep in mind that the generator can be of any size and so can be any of the vertices of the initiator.
Logged
lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #1 on: April 28, 2007, 01:16:34 AM »

your problem description is pretty light on details (read: there are no details tongue stuck out), however i have recently had a similar university assignment. we were required to produce a koch "snowflake" fractal, and i can immediately refer you to my online solution: http://www.fractographer.com/cos340/cos340-a%20ass1.pdf (it's question 4)

the solution i used there is based on l-systems, which is a bit easier than using a recursive approach -- which is, i guess, why you were given that question in the first place! wink to further complicate the matter, my code is definitely not what you want to be reading if you've just started writing your first programs...

so, assuming you're familiar with vector arithmetic, you just need to keep making a new list of vertices which grows by a constant factor relative to the last each iteration. each line gets replaced with several new ones, in my case 4, so you'd be adding 3 new vertices (it's 3am, this is off the top of my head, so double checking my spam might be good) each iteration. with a scale factor of sqrt(3) you offset the middle of each edge along its normal direction (if the edge vector is <dx,dy> then the normal is +/- <-dy,dx>) and link that up to the beginning and end segments.

hope that helps! the coding itself is the hard part of course, but it's what you're there to learn mate wink
Logged

Klop
Guest
« Reply #2 on: April 28, 2007, 03:52:09 AM »

Thanks for your help, I contacted a teacher though and he explained it to me, I made a mistake there, I meant replacing each segment by the generator and not each vertex tongue stuck out

Anyways, I figured it out. first I find the length of the segment and the distance between the extremes of the generator and then I scale the generator (its clone, I don't want to modify the original) by (segment_length/generator_distance_extremes) so that the distance between the extremes of the generator becomes the same as the length of the segment.
Then I translate the generator so that it's first Point matches the first Point of the segment.
And finally I move both the first Point of the segment and the first Point of the generator to the origin (after storing the Point where they were), rotate them by alpha - beta (being alpha the angle of the second Point of the segment and beta the angle of the last Point of the generator), and then move them back.
This way the generator matches the segment, then all I have to do is replace it tongue stuck out

I'll bring screenshots later xD
Logged
Nahee_Enterprises
World Renowned
Fractal Senior
******
Posts: 2250


use email to contact


nahee_enterprises Nahee.Enterprises NaheeEnterprise
WWW
« Reply #3 on: April 28, 2007, 11:19:24 AM »

Klop wrote:
>
>    Hi everybody, I'm new here...
>    I'm making my very first fractal generation program for university.....
>    .....   I'll bring screenshots later....

Greetings!!  And welcome to this Forum.     smiley

Look forward to seeing how your images turn out on your assignment.

Logged

Klop
Guest
« Reply #4 on: April 29, 2007, 02:45:43 AM »

Thanks cheesy

Here they are:
http://i168.photobucket.com/albums/u167/jmorais24000/[XX].png

where [XX] is any number between 1 and 20. I'll bring colored ones later :p

EDIT:
Now the numbers go up to 23, numbers 22 and 23 are colored ones smiley
« Last Edit: April 30, 2007, 02:59:09 AM by Klop » Logged
Nahee_Enterprises
World Renowned
Fractal Senior
******
Posts: 2250


use email to contact


nahee_enterprises Nahee.Enterprises NaheeEnterprise
WWW
« Reply #5 on: April 30, 2007, 09:49:00 PM »

Have not looked at all of your plots yet (I started at # 23 and began working backwards).  I found # 21 interesting to see a Julia like spiral appearing in the density of the triangles.  The pattern of # 17 I also found interesting.

Keep us informed on your progress and any interesting images that you create.  And if you have questions, just post them to this forum.

Logged

Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
run Almost any fractal program on mac ! Macintosh Fractal Software « 1 2 » slock 18 16672 Last post January 30, 2013, 12:58:54 AM
by vinniefracker
Excellent program but how I can put the terrain in 3d yFract benoit-1842 0 1718 Last post August 24, 2012, 05:24:15 AM
by benoit-1842
How to program a mandel box ? Tutorial ! Programming flexiverse 13 5723 Last post April 13, 2013, 04:57:19 PM
by flexiverse
Fractracer - Does anyone know the program? Fractal Programs fantago 1 2638 Last post September 07, 2013, 03:07:57 AM
by Nahee_Enterprises
3d isosurface rendering program from Ryan Geiss 3D Fractal Generation Mrz00m 2 6673 Last post January 22, 2015, 12:47:56 PM
by DarkBeam

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.195 seconds with 24 queries. (Pretty URLs adds 0.009s, 2q)