#define FINENESS .1

#define DISTANCE 0

#define CONTOUR 5

#define LIMIT 360

 

float thfunc (float x, float y, float z)

{

// This is where I define my 3 variable functon.

if (x==DISTANCE) x = DISTANCE +.01;

if (x==-DISTANCE) x = -DISTANCE + .01;

return ( -y*60/(x*x+y*y) + log (x*x/10+y*y/10) + y/10)-z/10;

}

 // I included a file called point.cpp. I have left that out, so that you have some inconvenience!! Evil me!

 

void plot (Point p)

{

putpixel (p.x+300,-p.y+200,3);

}

 

 

int getNoOfRoots(float xi, float xf,float y, float z)

{

float prev=0;

int n=0;

Point p;

for (p.x= xi; p.x<=xf; p.x+= 1)

{

p.y= thfunc(p.x,y,z);

if (p.y!=0)

{

if ((prev/p.y)<0)

n++;

}

else n++;

prev = p.y;

}

return n;

} // end getNoOfRoots()

 

 

 

float getRoot (float xi, float xf, int n, float y, float z)

{

// gets the n'th root

float prev=0;

int counter=0;

Point p;

for (p.x= xi; p.x<=xf; p.x+= 1)

{

p.y= thfunc(p.x,y,z);

if (p.y!=0)

{

if ((prev/p.y)<0)

counter++;

}

else counter++;

if (counter == n) break;

prev = p.y;

}

return p.x;

}

 

 

void twoVarPlot(float z)

{

for (float y=-100; y<=100;y+= FINENESS)

{

int temp = getNoOfRoots(-100,100,y,z);

for (int i = 1; i<=temp ; i++)

{

Point p;

p.x = getRoot(-100,100,i,y,z);

p.y = y;

plot (p);// Hey.. You have to write your own class called Point with p.x and p.y as public float fields/

}

}

}

void main (void )

{

int gm, gd;

gd= DETECT;

initgraph( &gd,&gm, "c:\\tc"); // This works on my comp. May not in your comp.

for (int i = -LIMIT; i<LIMIT; i+=CONTOUR

)

{

twoVarPlot (i);

}

getch();

}

 

If you think that this program sucks and my indentation sucks and I am too ill mannered when I program, fret not. I am a mechanical engg. student, and odds are will not ever step into a software development environment, so I can be as ill mannered as I like, as long as I get the curves, no pun intended.

 

Go back to the main fluid mechanics page

Hosted by www.Geocities.ws

1