Like the Golden Apple.. but with more calories
The equation is:
bool GoldenDonnut(float x, float y, float z,int Iter)
{
int ic;
const float delta=0;
const float angle=atan2(ny,nx)*3;
const float radius=sqrt(nx*nx+ny*ny);
const float t_radius=radius-3.5;
const float ctx =sinf(angle)*radius-delta;
const float cty =cosf(angle)*radius-delta;
const float ctz =nz-delta;
const float ctw =t_radius*t_radius+nz*nz-delta;
float w=ctw;
x=ctx;
y=cty;
z=ctz;
for(ic=0;ic<Iter;ic++){
if(x>1)x=2-x;
else
if(x<-1)x=-2-x;
if(y>1)y=2-y;
else
if(y<-1)y=-2-y;
if(z>1)z=2-z;
else
if(z<-1)z=-2-z;
if(w>1)w=2-w;
else
if(w<-1)w=-2-w;
const float vm=sqrt(x*x+y*y+z*z+w*w);
if(vm<0.5){
x*=4;
y*=4;
z*=4;
w*=4;
} else
if(vm<1){
const float vsq=vm*vm;
x/=vsq;
y/=vsq;
z/=vsq;
w/=vsq;
}
x=x*2+ctx;
y=y*2+cty;
z=z*2+ctz;
w=w*2+ctw;
if ((x*x+y*y+z*z+w*w)>3600) break;
}
if(ic<Iter)return false;else return true;
}
Hope that Spring ends soon!!
I really want to breathe again!!
The equation is:
bool GoldenDonnut(float x, float y, float z,int Iter)
{
int ic;
const float delta=0;
const float angle=atan2(ny,nx)*3;
const float radius=sqrt(nx*nx+ny*ny);
const float t_radius=radius-3.5;
const float ctx =sinf(angle)*radius-delta;
const float cty =cosf(angle)*radius-delta;
const float ctz =nz-delta;
const float ctw =t_radius*t_radius+nz*nz-delta;
float w=ctw;
x=ctx;
y=cty;
z=ctz;
for(ic=0;ic<Iter;ic++){
if(x>1)x=2-x;
else
if(x<-1)x=-2-x;
if(y>1)y=2-y;
else
if(y<-1)y=-2-y;
if(z>1)z=2-z;
else
if(z<-1)z=-2-z;
if(w>1)w=2-w;
else
if(w<-1)w=-2-w;
const float vm=sqrt(x*x+y*y+z*z+w*w);
if(vm<0.5){
x*=4;
y*=4;
z*=4;
w*=4;
} else
if(vm<1){
const float vsq=vm*vm;
x/=vsq;
y/=vsq;
z/=vsq;
w/=vsq;
}
x=x*2+ctx;
y=y*2+cty;
z=z*2+ctz;
w=w*2+ctw;
if ((x*x+y*y+z*z+w*w)>3600) break;
}
if(ic<Iter)return false;else return true;
}
Hope that Spring ends soon!!
I really want to breathe again!!
:origin()/pre00/ee83/th/pre/f/2011/144/5/d/the_golden_donnut_by_aexion-d3h47oi.png)
God bless you friend