Traditional Sciences

We have tried over most of our family life to go green, and with some success.

As I get time, I will flesh this area out with some of our projects.

Life follows math. The graphic I have chosen here is a national symbol of New Zealand, the silver fern. That one was generated entirely mathematically. The source code is below. I did not write the source code but I did convert it to a plugin for RealBasic.

What is more beautiful ? the complexity of the art in the living form of the fern ? the simplicity of the mathematics ? or the comfort one can find in knowing that each is not so very much different as to be necessarily mutually exclusive ?

static REALpicture Picture_Fractal_FernSet(double MaxIt,long vWidth,long vHeight)
{


REALpicture pic;
GWorldPtr outWorld;
Rect r;
long *dstpix;
int mx,my,p[4];
float a[4],b[4],c[4],d[4],e[4],f[4];

char red,green,blue;
float x=0,y=0,newx;
long j,k,px,py,xoffset,yoffset,xscale=80,yscale=75;
char col;


CGrafPtr oldPort;
GDHandle oldDevice;

GetGWorld(&oldPort, &oldDevice);

SetRect (&r, 0, 0, vWidth,vHeight );
NewGWorld (&outWorld, 32, &r, nil, nil, 0);
PixMapHandle outPM = GetGWorldPixMap (outWorld);
short dstRowBytes = (*outPM)->rowBytes & 0x7FFF;

Ptr dst = GetPixBaseAddr (outPM);

mx=vWidth; my=vHeight;
xoffset=mx/2;
yoffset=my-20;
a[0]=0; a[1]=.20; a[2]=-.15; a[3]=.85;
b[0]=0; b[1]=-.26; b[2]=.28; b[3]=.04;
c[0]=0; c[1]=.23; c[2]=.26; c[3]=-.04;
d[0]=.16; d[1]=.22; d[2]=.24; d[3]=.85;
e[0]=0; e[1]=0; e[2]=0; e[3]=0;
f[0]=0; f[1]=1.60; f[2]=.44; f[3]=1.6;
p[0]=328; p[1]=2621; p[2]=4915; p[3]=32767;

do {


j=rand();
k=(j newx=(a[k]*x+b[k]*y+e[k]);
y=(c[k]*x+d[k]*y+f[k]);
x=newx;
px=xoffset+x*xscale;
py=yoffset-y*yscale;

if (px<0) px=0;
if (px>vWidth) px=vWidth-1;
if (py<0) py=0;
if (py>vHeight) py=vHeight-1;

dstpix=(long*)dst;
dstpix+=(py*(dstRowBytes/4))+px;
red=((*dstpix&0x00ff0000)>>16)+1;
green=((*dstpix&0x0000ff00)>>8)+1;
blue=((*dstpix&0x000000ff))+1;
*dstpix=(red<<16)+(green<<8)+blue;

} while(MaxIt-->0);

SetGWorld(oldPort, oldDevice);
pic = REALBuildPictureFromGWorld (outWorld, true);

return pic;


}



New Products For May - Traditional Sciences


www.lakerotoma.com

Come stay in paradise !! Lake Rotoma, Bay of Plenty, New Zealand

Your IP Address is: 23.22.76.170
Copyright © 2013 The Kostyrko family personal website.