Triangle Fractal

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Guest

Post by Guest »

Okay.... what better way is there?
User avatar
Don Pwnious
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 833
Joined: Tue Jun 15, 2004 5:32 pm
Location: on the streets wit my j23
Contact:

Post by Don Pwnious »

Thats the part i have to figure out
1/8th time- 14secs
1/8th speed - 110mph
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Triangle Fractal

Post by Falco Girgis »

Arce wrote:If anyone of you ever checked out my development topic, you'd know that I would like some guidence on this. As I'm sure we all know, there is a random fractal with a triangle, and inside is a triangle, dividing it into three triangles, and a triangle in those three dividing each into three, and so on. I would like to make a program that does that in blitz. I have no clue where to strat. Guidence would be nice, IF anyone had the time over all the NEStix stuff.
That's the most undescriptive, terrible description you could of written. I think I may of even figured out how to do it. Then I reread your post, and now I don't what in the HELL you want to do. Draw a picture or something.
User avatar
Don Pwnious
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 833
Joined: Tue Jun 15, 2004 5:32 pm
Location: on the streets wit my j23
Contact:

Post by Don Pwnious »

wait how is fractional triangles fun??
1/8th time- 14secs
1/8th speed - 110mph
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Post by Falco Girgis »

Okay, from what I saw (he drew me a little picture so you guys would have no clue). First off, you need to know how to draw pixels. Once you can do that, you need to make a function that is able to graph a line using the pixels. The formula you'd use is:

Code: Select all

y2 - y1          rise
--------    =   ------
x2 - x1          run
You'd be basically graphing slope there, dammit, I'll think of more later. I had an idea, but it won't be easy. The line drawing thing is essential though. So like, yeah.
User avatar
Don Pwnious
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 833
Joined: Tue Jun 15, 2004 5:32 pm
Location: on the streets wit my j23
Contact:

Post by Don Pwnious »

yes of course

Code: Select all

Global y1 = 0
global y2 = 0

global x1 = 0
global x2 = o
(except replace 0 with something else)
then make the slope formula a function.
then draw image
1/8th time- 14secs
1/8th speed - 110mph
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Post by MarauderIIC »

You draw 3 lines, take the midpoints of each, draw 3 lines btwn those. But then the tricky parts: Know to get the midpoints in top section, bottom right section, bottom left section. Inside the 2nd is easy. But you just have to know how to select which ones you need. I think you'd make, after the 1st, 4 new triangles class copies (one for top sec, one br sec, one bl sec, one mid sec).
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Guest

Post by Guest »

Before I gave up, I tried several things not at all unlike the just mentioned.
User avatar
Don Pwnious
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 833
Joined: Tue Jun 15, 2004 5:32 pm
Location: on the streets wit my j23
Contact:

Post by Don Pwnious »

So im guessing someone should lock this topic since it wont be any use to anyone.
Last edited by Don Pwnious on Sun Oct 10, 2004 11:43 am, edited 1 time in total.
1/8th time- 14secs
1/8th speed - 110mph
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Post by Falco Girgis »

Arce, you'll never be a good programmer. Programming is about pushing yourself to the limits, it's about doing stuff that you believed yourself not capable of, it's about PWNing the thing that needs to be done, it's about sticking it to the man!

If I gave up on all of the stuff that I couldn't get, we wouldn't be here now. There would be no TheChaosrift.com, I wouldn't be working on NEStix. Nope. Programming is not supposed to be easy.

When you get knocked on your ass, you get back up and ram your foot right back up its ass!
User avatar
Don Pwnious
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 833
Joined: Tue Jun 15, 2004 5:32 pm
Location: on the streets wit my j23
Contact:

Post by Don Pwnious »

What HE QUITED THE TRIANGLE THING?????
1/8th time- 14secs
1/8th speed - 110mph
User avatar
JS Lemming
Game Developer
Game Developer
Posts: 2383
Joined: Fri May 21, 2004 4:09 pm
Location: C:\CON\CON

Post by JS Lemming »

No offense, but you guys are clueless. First off, you don't make fractals with objects like triangles, that is what the actuall fractal is for. You make the fractal out of points or pixels. Compile the code foo.

Code: Select all

;Set graphics mode
Graphics 1024,768

;Seed the random generator
SeedRnd(MilliSecs())

;Set buffer to backbuffer
SetBuffer BackBuffer()

Global manx# = 0.0
Global many# = 0.0

Global n#

Global timer = 0

Cls

Color 150,150,150
Text 0,600,"Generating Fractal"
Text 0,612,"Press Space to cancel"
Text 0,624,"Press Esc to exit"

Flip

For i = 0 To 430000
	
	n = Rnd(0,1)
		
	If n <= (0.333333)
	
		Color Rand(100,255),0,0
		;Color 255,0,0
		;Color Rand(0,255),Rand(0,255),Rand(0,255)
	
		manx = manx * .5
		many = many * .5

	ElseIf n > (0.333333) And n <= (0.666666)
	
		Color 0,Rand(100,255),0
		;Color 0,255,0
		;Color Rand(0,255),Rand(0,255),Rand(0,255)
	
		manx = .5 * (.5 + manx)
		many = .5 * (1 + many)
	
	ElseIf n > (0.666666)
	
		Color 0,0,Rand(100,255)	
		;Color 0,0,255
		;Color Rand(0,255),Rand(0,255),Rand(0,255)
	
		manx = .5 * (1 + manx)
		many = .5 * many
		
	EndIf

	If timer < 0
		Flip
		timer = 1500
	Else
		timer = timer - 1
	EndIf
		
	If KeyDown(57) Then Exit

	pix(manx,many)
	
Next


Flip

While Not KeyDown(1)

	;just sit back and take a gander

Wend

End


Function pix(x#,y#)

	Plot(x*GraphicsWidth(),y*GraphicsHeight())
	;Oval x*GraphicsWidth(),y*GraphicsHeight(),4,4,1

End Function
Yeah I made that baby a long time ago... I don't know about you guys but fractals make me feel all warm and fractally inside.

PS: I have some things noted out. try switching them out for different effects. I have it set to somewhat random color but within bounds currently, it gives it a nice shimmer effect.

OH! And just in case you don't have blitz or too lazy to compile, here is a screenie.

Image
Small girl at the harbor wrote:Look Brandon, that crab's got ham!
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Post by Falco Girgis »

JS Lemming wrote:No offense, but you guys are clueless. First off, you don't make fractals with objects like triangles, that is what the actuall fractal is for. You make the fractal out of points or pixels.
I disagree. Yes, clueless I was sorta. But you VERY well coulda made something semi-similar out of lines as well. A fractal is not a preset thing. A fractal is chaos. Almost undefinable. You can't set rules for how fractals are made, nor can you make rules for one fractal and use it for another.
dictionary.com wrote: Fractals:
A geometric pattern that is repeated at ever smaller scales to produce irregular shapes and surfaces that cannot be represented by classical geometry. Fractals are used especially in computer modeling of irregular patterns and structures in nature.
There is no predetermined way to make a fractal.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Post by Falco Girgis »

Oh, hey, did you just add that picture?
That's awesome.
:bow: :worship:
User avatar
JS Lemming
Game Developer
Game Developer
Posts: 2383
Joined: Fri May 21, 2004 4:09 pm
Location: C:\CON\CON

Post by JS Lemming »

True, but come on! Pixels are better then lines!
Small girl at the harbor wrote:Look Brandon, that crab's got ham!
Post Reply