Você está na página 1de 35

ANNA UNIVERSITY: CHENNAI

CS2405 COMPUTER GRAPHICSLAB


GENERATION OF VOLUMETRIC ESCAPE TIME FRACTALS
MINI PROJECT REPORT

SUBMITTED BY ,
S.RAJA PRABHA

[951712205036]

S.SINDHU PARKAVI

[951712205049]

C.VAISHNAVI

[951712205061]

DEPARTMENT OF INFORMATION TECHNOLOGY


MEPCO SCHLENK ENGINEERING COLLEGE
MEPCO NAGAR, SIVAKASI.
2015-2016

CERTIFICATE

This

is

to Certify that it is the bonafide

work

done by S.RAJA

PRABHA,S.SINDHU PARKVAI and C.VAISHNAVI for their Mini Project


on GENERATION OF VOLUMETRIC ESCAPE TIME FRACTALS in the
CS2405 COMPUTER GRAPHICS LAB at Mepco Schlenk Engineering
College, Sivakasi during the year 2015-2016.

Staff in charge

Head of the Department

ACKNOWLEDGEMENT
We have taken efforts in this project. However, it would not have been possible
without the kind support and help of many individuals and our reputed
institution Mepco Schlenk Engineering College, Sivakasi. We would like to
extend our sincere thanks to our Principal Dr. S. Arivazhagan ME., PhD.
We would like to express my special gratitude and thanks to Dr.T.Revathi ME.,
PhD. Senior Professor & Head of the Department for giving us such a
wonderful experience.
We are highly indebted to, Mrs.R.Venitta Raj AP(Sr.Grade)/IT , Mr.B.D.Deebak
AP/IT for their guidance and constant supervision as well as for providing
necessary information regarding the project & also for their support in
completing the project.
We would like to express our gratitude towards our parents and members of IT
Department of this prestigious institution for their kind co-operation and
encouragement which help us in completion of this project.

ABSTRACT

Generation of volumetric Escape time fractals is to create solid fractals, It uses


quaternion representations for transforming points in three or four dimension. It
is an extension of complex function transformation of analysis and rendering. It
relies on iterative mathematical calculations. It forms the volumetric cloud of
points with values corresponding to escape time at certain position in three
dimensional space. This algorithm is very fast and can handle shapes with caves
and holes, which is important in fractal objects. These fractals are used in
interactive fractal presentation and magnification on cell phones equipped with
the Java-language programming environment.

TABLE OF CONTENTS
1.Program statement

2.Program Description

3.Language Used

4. Algorithm

12

5. Procedure

19

6. Code

23

7.ScreenShots

37

8.Conclusion

38

PROGRAM STATEMENT

The implementation of escape time fractals relies on iterative


mathematical calculations. In particular, the method is based on
monitoring the number of iterations necessary to determine whether an
orbit sequence tends to infinity or not. One of the most popular
approaches is to use nonlinear equations with chaotic solutions. The
solutions are most interesting if they involve at least two variables x and
y, which can be used to represent horizontal and vertical positions on a
graphics screen. With complex numbers, used in equations where x and
yare elements of the complex number z, the simplest andmost popular
equation used as an example is z =z^2 + c;where c is a complex constant.
This way we can render the most popular escape-time fractals such
asMandelbrot and Julia sets Interestingly, these kinds of fractals have
become so popular that interactive fractal presentation and magnification
is now possible on cell phones equipped with the Java-language
programming environment. One such example is mFrac, a distributed
fractal explorer for mobile devices such as phones and PDAs.

PROGRAM DESCRIPTION

A combination of linear and quadratic functions may be used toproduce


fractal forms with a beautiful and visually balanced shape.Therefore, we
decided to extend previous methods to the third dimension.2-D algorithms are
observed to be visually appealing fractals often occur when the orbit
slowlyescapes to infinity. The same rule can be applied to solids. In a similar
manner, we start by choosing 30 coefficients of the generalized function
limiting ourselves to the simplest nonlineraties.

LANGUAGE USED

OPENGL:
The OpenGL graphics system is a software interface to graphics hardware.
(GL stands for Graphics Library.) It allows you to create interactive
programs that produce color images of moving, three dimensional objects.
With OpenGL, you can control computer-graphics technology to produce
realistic pictures, or ones that depart from reality in imaginative ways. OpenGL
is a software interface to graphics hardware.
This interface consists of more than 700 distinct commands (about 670
commands as specified for OpenGL Version 3.0 and another 50 in the OpenGL
Utility Library) that you use to specify the objects and operations needed to
produce interactive three-dimensional applications. OpenGL is designed as a
streamlined, hardware-independent interface to be implemented on many
different hardware platforms. To achieve these qualities, no commands for
performing windowing tasks or obtaining user input are included in OpenGL;
instead, you must work through whatever windowingsystem controls the
particular hardware youre using. Similarly,OpenGL doesnt provide high-level
commands for describing models of three-dimensional objects. Such commands
might allow you to specify relatively complicated shapes such as automobiles,
parts of the body, airplanes, or molecules. With OpenGL, you must build your
desired model from a small set of geometric primitivespoints, lines, and
polygons. The OpenGL specification describes an abstract API for drawing 2D

and 3D graphics. Although it is possible for the API to be implemented entirely


in software, it is designed to be implemented mostly or entirely in hardware.
A sophisticated library that provides these features could certainly be built on
top of OpenGL. The OpenGL Utility Library (GLU) provides many of the
modeling features, such as quadric surfaces and NURBS curves and surfaces.
GLU is a standard part of every OpenGL implementation.
HEADER FILES
In Windows we need to include the gl.h header for OpenGL 1.1 support and link
against OpenGL32.lib. Both are a part of the Windows SDK. In addition, you
might

want

the

headers wglext.h and glext.h which

from http://www.opengl.org/registry .wglext.h has

typedefs

you
for

can

get

Windows-

specific extensions, and glext.h is the header which holds mostly platformagnostic extensions and OpenGL core functionality which is later than OpenGL
version 1.1.
Linux
On Linux you need to link against libGL.so, which is usually a symlink to
libGL.so.1, which is yet a symlink to the actual library/driver which is a part of
your graphics driver. For example, on my system the actual driver library is
named libGL.so.256.53, which is the version number of the nvidia driver I use.
You also need to include the gl.h header, which is usually a part of a Mesa or
9

Xorg

package.

Again,

you

might

need glext.h and glxext.h from http://www.opengl.org/registry . glxext.h holds


GLX extensions, the equivalent to wglext.h on Windows.
If you want to use OpenGL 3.x or OpenGL 4.x functionality without the
functionality which were moved into the GL_ARB_compatibility extension, use
the new gl3.h header from the registry webpage. It replaces gl.h and
also glext.h (as long as you only need core functionality).
Last but not the least, glaux.h is not a header associated with OpenGL. I assume
you've read the awful NEHE tutorials and just went along with it. Glaux is a
horribly outdated Win32 library (1996) for loading uncompressed bitmaps. Use
something better, like libPNG, which also supports alpha channels.
DRAWING POINTS
OpenGL has the command glBegin(glPoints) to plot the points. GlVertex2f(x,y)
and GLVertex3f(x,y,z) are the ways to plot 2D and 3D points on the console.
FRACTALS
A fractal is a natural phenomenon or a mathematical set that exhibits a
repeating pattern that displays at every scale. If the replication is exactly the
same at every scale, it is called a self-similar pattern.
ALGORITHM:
10

{Pseudocode illustrate method for generating EscapeTime fractals}


{built with 3-D points}
program fractals;
const
MaxColors=80; {Numbers of layers in 3-D}
{ variables }
var
x, y, z : Real; { current point in fractal space }
a : array [0..29] of Real; { fractal code (fractal coefficients) }
fDimX, fDimY, fDimZ : Real; { dimensions of fractal space (e.g.=8.0f) }
iSizeX, iSizeY, iSizeZ : Integer; { e.g.=300, 3D dimensions of solid }
fScaleX, fScaleY, fScaleZ : Real; { scales of dimensions (e.g.=4.0f) }
n : Integer; { a color/layer of a point }
iKernelColor : Integer; { a threshold color; i.e. the number of the first
visible layer of a fractal (e.g.=5). Layers are

11

numbered from 0 }
iMaxBound : Integer; { e.g.=1000 }
fMaxSolution : Real; { e.g.=1000000.0f }
{ Calculate current solution for x, y and z. Increment. }
procedure AdvanceXY;
var
xnew, ynew : Real;
begin
xnew:a[0]+x_a[1]+y_a[2]+z_a[3]+
x_x_a[4]+y_y_a[5]+z_z_a[6]+
x_y_a[7]+x_z_a[8]+y_z_a[9];
ynew:a[10]+x_a[11]+y_a[12]+z_a[13]+
x_x_a[14]+y_y_a[15]+z_z_a[16]+
x_y_a[17]+x_z_a[18]+y_z_a[19];
z:a[20]+x_a[21]+y_a[22]+z_a[23]+

12

x_x_a[24]+y_y_a[25]+z_z_a[26]+
x_y_a[27]+x_z_a[28]+y_z_a[29];
x:xnew;
y:ynew;
n:n+1;
end;
{ Generates points of fractal. Display. }
procedure GeneratePoints;
var
k, i, j : Integer;
fScreenX, fScreenY, fScreenZ : Real;
begin
fWidthDiv:iWidth/fScaleX; fHeightDiv:iHeight/fScaleY;
fDepthDiv:iDepth/fScaleZ;
for k:0 to iSizeZ do

13

for i:0 to iSizeX do


for j:0 to iSizeY do
begin
x:fDimX+i/fWidthDiv;
y:fDimY_j/fHeightDiv;
z:fDimZ_k/fDepthDiv;
n:0;
while (noMaxColors) and ((x_x+y_y+z_z)ofMaxSolution) do
AdvanceXY;
{ render only one layer of fractal }
if n=iKernelColor then
begin
{ put point on screen in 3D space (centering it) }
fScreenX:iiSizeX _ 0.5;
fScreenY:jiSizeY _ 0.5;

14

fScreenZ:k_iSizeZ _ 0.5;
PutPoint3D( fScreenX, fScreenY, fScreenZ );
end;
end;
end;
{ Set parameters of a fractal (from _1.2 to 1.2). Prepare fractal environment
}
procedure SetParams;
var
i : Integer;
begin
x:0; y:0; z:0;
{ randomly chosen parameters }
For i:0 to 30 do
a[i]:(random(25)_12 )/10.0;

15

end;
{ Test the solution. See Pickover and Sprott for details }
procedure TestSoln;
begin
If n=iMaxBound then n:0; { solution is bounded }
if ( x_x+y_y+z_z )>fMaxSolution then { solution escaped }
begin
if n>100 then n:iMaxBound
else n:0;
end;
end;
begin
randomize;
{ set some initial values }
iSizeX :100; iSizeY :100; iSizeZ:100;

16

fDimX:8.0; fDimY :8.0; fDimZ:8.0;


fScaleX:_4.0; fScaleY:4.0; fScaleZ:4.0;
n:0; iKernelColor:6; iMaxBound:1000; fMaxSolution:1000000.0;
{ main loop }
repeat
if n=0 then SetParams;
AdvanceXY; TestSoln;
if n=iMaxBound then
begin
GeneratePoints(); n:0; { drawfractal }
end;
until keypressed; { loop until a key is pressed }
end

PROCEDURE TO CREATE OPENGL IN MICROSOFT VISUAL


STUDIO 2012
17

Create file -> New project

Then choose Win32 Console Application and give its name and loaction.

18

Click ok and give finish

Give next and deselect sdl and click finish.

19

In filename, right click and choose properties.

In linker choose Input and add class libraries

20

Then add opengl32.lib, glut32.lib, glu32.lib

Click Ok and type the code

PROGRAM CODE:
#include "stdafx.h"
#include<math.h>
#include<stdlib.h>
#include<GL/gl.h>
#include<GL/glu.h>

21

#include<GL/glut.h>
#include<conio.h>
const int MaxColors=80;
float x=0.0, y=0.0, z=0.0 ;
float a[30];
float fDimX=8.0, fDimY=8.0, fDimZ=8.0;
int iSizeX=40, iSizeY=40, iSizeZ=40,iDepth=140,iHeight=140,iWidth=140;
float fScaleX=-4.0, fScaleY=4.0,
fScaleZ=4.0,fWidthDiv,fHeightDiv,fDepthDiv;
int iKernelColor=6,iMaxBound=1000;
static int n=0;
float fMaxSolution=1000000.0;

void AdvanceXY()
{
float xnew, ynew;
22

xnew=a[0]+x*a[1]+y*a[2]+z*a[3]+
x*x*a[4]+y*y*a[5]+z*z*a[6]+
x*y*a[7]+x*z*a[8]+y*z*a[9];
ynew=a[10]+x*a[11]+y*a[12]+z*a[13]+
x*x*a[14]+y*y*a[15]+z*z*a[16]+
x*y*a[17]+x*z*a[18]+y*z*a[19];
z=a[20]+x*a[21]+y*a[22]+z*a[23]+
x*x*a[24]+y*y*a[25]+z*z*a[26]+
x*y*a[27]+x*z*a[28]+y*z*a[29];
x=xnew;
y=ynew;
printf("\n%d",n);
n=n+10;
}
void GeneratePoints()

23

{
int k=0, i=0, j=0;
float fScreenX, fScreenY, fScreenZ;
fWidthDiv=iWidth/fScaleX;
fHeightDiv=iHeight/fScaleY;
fDepthDiv=iDepth/fScaleZ;
for (k=0;k<=iSizeZ;k++)
{
printf("OUTER FOR %d ",k);
for (i=0;i<=iSizeX;i++)
{
for (j=0;j<=iSizeY;j++)
{
x=fDimX+i/fWidthDiv;
y=fDimY-j/fHeightDiv;

24

z=fDimZ-k/fDepthDiv;
n=0;
while ((n<MaxColors) && (((x*x)+(y*y)+(z*z))<fMaxSolution))
AdvanceXY();
if(n>=iKernelColor )
{
fScreenX=i-iSizeX * 0.5;
fScreenY=j-iSizeY * 0.5;
fScreenZ=k-iSizeZ * 0.5;
glBegin(GL_POINTS);
printf("\n POINTS:");
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(fScreenX,fScreenY,fScreenZ);
glColor3f(0.0f,0.0f,1.0f);
printf("\nScreen inside pixel x,y,z %f %f
%f",fScreenX,fScreenY,fScreenZ);
25

glEnd();
glFlush();
}
}
}
}
glFlush();
}

void SetParams()
{
int i;
x=0; y=0; z=0;
for (i=0;i<30;i++){
float random=rand()%25;

26

float r=random-12.0;
//printf("\nrandom%f and %f",random,r);
a[i]=(((random)-12.0 ))/(10.0);
//printf("\nfractal%f",a[i]);
}
}
void TestSoln()
{
if (n==iMaxBound )
n=0;
// printf("\t X,Y,Z %d %d %d %d",x,y,z,fMaxSolution);
if (( x*x+y*y+z*z )>fMaxSolution){
if (n>100)
{
printf("\t\tFRAINMAX");

27

n=iMaxBound;
}
else
n=0;
}
}
void callm()
{
int ch=10000;
/*iSizeX =100; iSizeY =100; iSizeZ=100;
fDimX=8.0; fDimY =8.0; fDimZ=8.0;
fScaleX=-4.0; fScaleY=4.0; fScaleZ=4.0;
n=0; iKernelColor=6; iMaxBound=1000; fMaxSolution=1000000.0;*/
do
{

28

if (n==0)
SetParams();
AdvanceXY();
// GeneratePoints();
printf("\t%d",n);
TestSoln();
if (n==iMaxBound)
{
printf("INSIDE LOOP");
GeneratePoints();
n=0;
}
// printf("%d",ch);
ch--;
}while(ch>=0);

29

}
void mydisplay()
{
glClear(GL_COLOR_BUFFER_BIT);
callm();
glColor3f(2.0f,0.0f,2.0f);
glBegin(GL_POINTS);
printf("\nPOINTS");
glVertex3f(0.5,-0.7,-1.7);
// glVertex3f(50.0f,50.0f,50.0f);
glEnd();
glFlush();
}
/*void mydisplay(int button,int state,int x,int y)
{

30

if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN)


{
glClear(GL_COLOR_BUFFER_BIT);
//

callm();
glColor3f(1.0f,1.0f,0.0f);

glBegin(GL_POINTS);
glVertex3f(0.5,0.5,0.5);
glVertex3f(50.0,50.0,50.0);
// printf("%f %f %f",fScreenX,fScreenY,fScreenZ);
glEnd();
glFlush();
}
}*/
void init()
{

31

glClearColor(0.0,0.0,0.0,0.0);
glColor3f(0.0,1.0,0.0);
//callm();
}
void reshape (int w, int h)
{
glViewport (0,0,(GLsizei)w,(GLsizei)h);
// glViewport(200,200,100,100);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-4.25, 4.25, -5.0, 5.0, 2.5, 25.0);
glMatrixMode (GL_MODELVIEW);
}
int main(int argc,char **argv)
{

32

glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(400,400);
glutInitWindowPosition(100,100);
glutCreateWindow("3d fractals");
init();
printf("3dFRACTALS");
glutDisplayFunc(mydisplay);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}

33

BUILDING AND RUNNING PROJECTS:

Run the Project

34

CONCLUTION:
Thus Generation of volumetric escape time fractals has been
implemented General quadratic mappings, when extended to the third
dimension, produce a wide range of visually striking objects. From our
observations, the most visually interesting forms are relatively smooth and have
balanced (symmetrical) shapes.

35

Você também pode gostar