Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Moving fractal tree in DBPro

Author
Message
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Apr 2006 22:46 Edited at: 9th Apr 2006 14:54
Hi all

Found this code for qbasic and have modfiy it to work in DBPro takes about 2000 conts before it starts to look bent.



has oragianl code in there as well.

might work in DBC.

ps. on a p3 1 ghz gets about 4 fps.

I'm not getting you down am I, Ho Look! another fancy Door?
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Apr 2006 00:16
An update got the rnd >.5 bit sorted now compltes abit quicker.



I'm not getting you down am I, Ho Look! another fancy Door?
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 10th Apr 2006 05:52 Edited at: 10th Apr 2006 08:28
You could speed it up a bit more by using FastSync.
Also, change all drawing commands to write to a bitmap ( or directly to the backbuffer ), then paste it as a sprite.

Also, for all your math's operations, if you stick with values that are powers of 2 ( 2, 4, 8, 16... 128, etc ), then you can easily bit-shift to speed up the math operations.

for example;
St# = Pi / 128.0
becomes:
St# = Pi >> 7
( as 2^7 = 128 )

Or;
FOR x = Stp TO TPoints STEP Stp * 4
becomes:
FOR x = Stp TO TPoints STEP Stp << 2

... etc

[Edit] And another possibilty is, step it up so that it doesn't do 2000 itterations, but 200, save each stage as a seperate sprite, then play it all back once all are generated
[/Edit]
[Edit 2]
Also, sticking entirely with Integers ( or DWords ), avoiding Floats will speed things up too
[/Edit]

Team EOD :: All-Round Nice Guy
Want Better dbHelp Files?
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Apr 2006 15:50 Edited at: 10th Apr 2006 16:29
cheers JessTicular nice to have someone who knows there maths and how to use it, will be giving thoses ideas ago later on.


err if I have done this right it should look like this, yes!

old
St# = Pi / 128.0
new
stt# = Pi >> 7

old = 0.245436...

new = 4.203....e 045

so is something not working or is it I do not understand use of sign yet.

P.s. Am I allowed to do this or not
#constant St = Pi / 128.0
because if so it no work.

I'm not getting you down am I, Ho Look! another fancy Door?
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 11th Apr 2006 05:42 Edited at: 11th Apr 2006 05:44
St# = Pi / 128.0
new
stt# = Pi >> 7

is correct ( you realize that you've spelt it differently, yeah? )
However, since you're dealing with floats, it may not work...

#constant St = Pi / 128.0

Wouldn't work, no, as it detects Pi as a variable, and has a fit ( as far as I can tell ).
What you want to do, instead of using Constants ( they are simply a Search/Replace before compile ), use Globals so that you actually do the calculation, and it then doesn't have to be done ever again

Jess.

Team EOD :: All-Round Nice Guy
Want Better dbHelp Files?
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Apr 2006 07:26

Well this what happends when I try to put the >> part in
press o for old calac and n for new calac.

Whenever I try to make it lose the float parts, it will not work.

open to anyone to try and make it quicker.

I'm not getting you down am I, Ho Look! another fancy Door?
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Apr 2006 14:08
I think you might need to look at the following (from your second post):



I think rn is an integer and will always take the value zero according to this code - or is it declared as a float somewhere? Either way it will never exceed 0.1!

Also, you could take



outside the "x" loop at line 79.
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Apr 2006 14:18 Edited at: 11th Apr 2006 14:27
Green Gandalf I belive you are right because if do not make it float I get div by zero error, only way I could think of making function.

It also seem that any whole number does not work due to the way it does the calaulation, and that is were I am stabing around in the dark.

if anyone is intnrested here where I got it from.
http://www.josechu.com/moving_fractal/index.htm

I'm not getting you down am I, Ho Look! another fancy Door?
TheUser
19
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 13th Apr 2006 19:25
I think that Alfa is a random float number.

It is: Alfa = INT(RND * 8) * St

As (in qbasic) RND goes from 0.0000... to 0.99999...., and St is Pi/128, Alfa is a small random angle which goes from 0.0 to 0.196 radians. Or from 0.0 to 11.25 degrees.

Of course -Alfa goes from -0.0 to -0.196 radians

I think that every branch, big or small, rotates that float random quantity on each iteration.


yours,
TheUser
19
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 13th Apr 2006 19:53
I think that Alfa is a small random angle that goes from -0.196 radians (-Alfa) to 0.196 radians. It is a float (RND in qbasic is a float that goes from 0.0000... to 0.9999....)

It is the angle rotated by every branch, big or small, on each iteration.

Login to post a reply

Server time is: 2025-05-15 12:58:38
Your offset time is: 2025-05-15 12:58:38