25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Home   Projects   Up   Sitemap   Search   Blog   Forum+Chat   About Us   Privacy   Terms of Use   Feedback   FAQ   Images   Services   Payments   Humor   Music  

Convert parameters of an IFS fractal to rectangular or polar notation

After seeing a few IFS (iterated function set) fractal images, you will no doubt wonder if you can create one "to order" with specific characteristics. It's not easy. In fact, it's very difficult.

To design a fractal, you must decide on the scaling, rotation, and translation numbers to use. Those are easiest to understand and work with when they are in polar form.

However, most IFS fractal display programs (except mine) require their .IFS input files to be in rectangular form, so you need to translate the values after you finish your attempt at a design.

IFSHELP.BAS asks you for the polar data, and outputs the equivalent rectangular values.

TOPOLAR.BAS sometimes succeeds in translating rectangular values back to polar.

If you want to design fractals easily, you should use or study the code of the later and more capable C++ versions, IFS2PFS.CPP or WSHOWFS.CPP.

There now is also an online calculator where you can design and view your fractals on a web page.

IFSHELP.BAS

10 'IFSHELP.BAS 1-24-91 
11 'COPYRIGHT (C)1991 STEVEN WHITNEY.
12 'Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY.
13 'Initially published by http://25yearsofprogramming.com.
20 '2-23-91 REFERENCE COMPUTERS IN PHYSICS ARTICLE PAGE 503
30 'ASKS FOR POLAR COORDINATE INPUT INFORMATION
40 'AND OUTPUTS RECTANGULAR VALUES FOR IFS FILE CREATION
50 PRINT:PRINT
60 PI=3.1415926#
70 INPUT "MULTIPLY X BY (S/B <= 1)";R
80 INPUT "MULTIPLY Y BY (S/B <= 1)";S
90 PRINT
100 PRINT "If X-axis rotation equals Y-axis rotation, then fractal sub-images"
110 PRINT "will be symmetrically rotated."
111 PRINT
120 PRINT "If the two rotations are not equal, then fractal sub-images"
130 PRINT "can be squished.  Such squishing, for example, will turn a "
131 PRINT "plus-sign (+) into an x (x) rather than a plus sign rotated."
132 PRINT
140 INPUT "X-AXIS ROTATION (+DEGREES=COUNTERCLOCKWISE)";THETA
150 INPUT "Y=AXIS ROTATION (+DEGREES=COUNTERCLOCKWISE)";PHI
160 INPUT "TRANSLATION IN X-DIRECTION";E
170 INPUT "TRANSLATION IN Y-DIRECTION";F
180 PRINT:PRINT
190 PRINT "A = ";CINT(100 * R * COS(THETA * PI/180))
200 PRINT "B = ";CINT(100 * -S * SIN(PHI * PI/180))
210 PRINT "C = ";CINT(100 * R * SIN(THETA * PI/180))
220 PRINT "D = ";CINT(100 * S * COS(PHI * PI/180))
230 PRINT "E = ";E
240 PRINT "F = ";F
250 PRINT
260 GOTO 70


10 'TOPOLAR.BAS 3-10-91 
11 'COPYRIGHT (C)1991 STEVEN WHITNEY.
12 'Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY.
13 'Initially published by http://25yearsofprogramming.com.
20 'USER INPUTS IFS VARIABLES, PROGRAM RECONVERTS THE NUMBERS
30 'BACK INTO POLAR FORM  (SOMETIMES, WHEN IT WORKS.)
40 '3-10-91  STILL DOESN'T WORK RIGHT ALL THE TIME
45 '5-25-99  IFS2PFS.CPP HAS THE CORRECT METHOD.
50 ON ERROR GOTO 250
60 PI = 3.1415926#
70 'FNA CALCULATES THE ARCCOSINE    (SOMETIMES DIVISION BY ZERO A PROBLEM)
80 DEF FNA (X) = (-ATN(X / SQR(-X * X + 1)) + PI / 2) * (180 / PI)
90 PRINT
100 	INPUT "A= "; A
110 	INPUT "B= "; B
120 	INPUT "C= "; C
130 	INPUT "D= "; D
140 	PRINT
150 	R = SQR(A * A + C * C)
160 	S = SQR(B * B + D * D)
170 	THETA = FNA(A / R)
180 	PHI = FNA(D / S)
190 	PRINT "R (X SCALING FACTOR) = "; R
200 	PRINT "S (Y SCALING FACTOR) = "; S
210 	PRINT "THETA (X ROT.IN DEG.)= "; THETA * SGN(C)
220 	PRINT "PHI (Y ROT.IN DEG.)  = "; PHI * SGN(C)
230 	PRINT
240 GOTO 90
250 'ERROR HANDLING, CURRENTLY HAS TO DEAL WITH DIVISION BY ZERO
260 PRINT ERR; ERL
270 RESUME NEXT
280 END

 

 

Valid HTML 4.01 Transitional
Yahoo! Search
Search the web Search this site
Valid CSS