Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => (new) Theories & Research => Topic started by: DarkBeam on January 25, 2012, 07:12:06 PM




Title: Lame Klein bottle
Post by: DarkBeam on January 25, 2012, 07:12:06 PM
 :embarrass: I am very lame, was thinking about making a Klein Bottle using four half-toruses. The problem is that one of them should have a variable radius, that closes the bottle in itself smoothly, and I am not able to do this :-\

Was thinkin about a function of atan(y,x) to do this;

Code:
#info DarkBeam's Klein Bottle
#include "DE-Raytracer.frag"
#group KBottle

#define PI 3.14159

//Radius of the tubes
uniform float tubeRadius; slider[0,0.3614,100.]

//Radius of the goup of tubes
uniform float groupRadius; slider[0,0.85,5.]

//Radius of the whole object (because it looks like a torus (-:)
uniform float objectRadius; slider[0,.7,1.7]

uniform float ggg; slider[0,.7,1.7]
uniform float hhh; slider[0,3.,12.]
float Tor(vec3 p, float R, float tR, float Tube){
      float j;
      float a = p.x,b = p.y,c = p.z;
j =sqrt(a*a+b*b)-R ;
j =sqrt(j*j+c*c);
return abs(j-tR)-Tube;
}

float ETor(vec3 p, float R, float tR, float Tube, float el ){  // THIS IS WRONG
      float j;
      float a = p.x,b = p.y,c = p.z;
j =sqrt(a*a+b*b);
      a = (atan(b,a))/hhh;
       j = j*(ggg-tubeRadius*a*a*a)-R;
j =sqrt(j*j+c*c);
return abs(j-tR)-Tube;
}

float YinYang(vec3 p, float R, float tR, float Tube){
      float j;
      float a = p.x,b = p.y,c = p.z;
      if (a>0) {b+=R;} else {b-=R;}
j =sqrt(a*a+b*b)-R ;
j =sqrt(j*j+c*c);
return abs(j-tR)-Tube;
}

float DE(vec3 p) {
float d1,d2,d3;
       d1=1000;//Tor(p,1.,.3,.1);
       if (p.z<0.0 &&1) {
           return .1-p.z;
}
       if (p.x>0) {
             p.y +=objectRadius;
           d1=ETor(p/groupRadius,2.*1.,.2,.02,-tubeRadius);
             p.y -=objectRadius;
} else {
             p.y +=2.;
d1=Tor(p.yzx,.2,.1,.02);
             p.y -= 2.;
}
       d3=YinYang(p,1.,.3,.02);
       d1=min(d1,d3);
return d1;
}
#preset default
FOV = 0.62536
Eye = -0.684574,2.97917,-0.56351
Target = 1.28819,-5.52322,0.968231
Up = -0.474302,-0.261493,-0.84063
AntiAlias = 1
Detail = -3
DetailAO = -1.57143
FudgeFactor = 0.66265
MaxRaySteps = 64
BoundingSphere = 4 Locked
Dither = 0 Locked
NormalBackStep = 1
AO = 0,0,0,0.90123
Specular = 4.4304
SpecularExp = 16
SpotLight = 0.435294,0.737255,1,0.5
SpotLightDir = 0.65626,0.5
CamLight = 1,0.941176,0.898039,1.0566
CamLightMin = 0
Glow = 1,1,1,0
GlowMax = 20
Fog = 0
HardShadow = 0
ShadowSoft = 12.9032
Reflection = 0
BaseColor = 0.701961,0.701961,0.701961
OrbitStrength = 0
X = 0.411765,0.6,0.560784,0.41748
Y = 0.666667,0.666667,0.498039,-0.16504
Z = 1,0.258824,0.207843,1
R = 0.0823529,0.278431,1,0.82352
BackgroundColor = 0.607843,0.866667,0.560784
GradientBackground = 0.3261
CycleColors = true
Cycles = 4.04901
EnableFloor = false
FloorNormal = 0,0,0
FloorHeight = 0
FloorColor = 1,1,1
tubeRadius = 0.07534
groupRadius = 0.29851
objectRadius = 0.43077
Rotations = 3
RotDenominator = 3
RotNumeratorX = -2
RotNumeratorY = -4
#endpreset

The problem is that the cut plane does not work well and I did not found a good mangling for that atan() :-\

Thanks for your endless patience :-*


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 25, 2012, 08:14:27 PM
If somebody finds the answer I will donate the Figure-8 immersion formula, that looks so cool ;D ;D ;D

Yes it's still a Klein Bottle but does not look like :hmh:


Title: Re: Lame Klein bottle
Post by: blob on January 25, 2012, 08:22:07 PM
Completely off-topic but I was wondering if an hyperbolic tesselation transform for dIFS was in the realm of the possible????


Title: Re: Lame Klein bottle
Post by: hobold on January 25, 2012, 11:00:28 PM
A torus with a varying radius? Here: http://en.wikipedia.org/wiki/Dupin_cyclide


Title: Re: Lame Klein bottle
Post by: fractower on January 25, 2012, 11:29:56 PM

From my second favorite math related sight http://paulbourke.net/geometry/klein/ (http://paulbourke.net/geometry/klein/)

Paul rules!!


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 26, 2012, 10:28:13 AM
Thanks but I found a workaround for my function - here it is.
For some values it goes wrong but hey it's normal :beer:

Code:
#info DarkBeam's Klein Bottle
#include "DE-Raytracer.frag"
#group KBottle

#define PI 3.14159

//Radius of the tubes
uniform float tubeRadius; slider[0,0.7,3.]

//Radius of the goup of tubes
uniform float groupRadius; slider[0,0.13,0.4]

//Radius of the whole object (because it looks like a torus (-:)
uniform float objectRadius; slider[0,.7,1.7]

uniform float ggg; slider[0.,1.6,4.]
//uniform float hhh; slider[0.,3.,12.]
float Tor(vec3 p, float R, float tR, float Tube){
      float j;
      float a = p.x,b = p.y,c = p.z;
j =sqrt(a*a+b*b)-R ;
j =sqrt(j*j+c*c);
return abs(j-tR)-Tube;
}

float ETor(vec3 p, float R, float tRmin, float tRmax, float Tube ){
      float j;
      float a = p.x,b = p.y,c = p.z;
j =sqrt(a*a+b*b);
      a = (atan(b,a)/PI-ggg+2);
      a = clamp(a,tRmin,tRmax);
       j = j-R;
j =sqrt(j*j+c*c);
return abs(j-a)-Tube;
}

float YinYang(vec3 p, float R, float tR, float Tube){
      float j;
      float a = p.x,b = p.y,c = p.z;
      if (a>0) {b+=R;} else {b-=R;}
j =sqrt(a*a+b*b)-R ;
j =sqrt(j*j+c*c);
return abs(j-tR)-Tube;
}

float DE(vec3 p) {
float d1,d2,d3;
       d1=1000;//Tor(p,1.,.3,.1);
       if (p.z<0.0 &&0) {
            return .1-p.z;
}
       if (p.x>0) {
            d1=ETor(p,2.*1.,tubeRadius-2*groupRadius,tubeRadius,.02);
} else {
             p.y +=2.;
d1=Tor(p.yzx,tubeRadius-groupRadius,groupRadius,.02);
             p.y -= 2.;
}
       d3=YinYang(p,1.,tubeRadius,.02);
       d1=min(d1,d3);
return d1;
}
#preset default
FOV = 0.62536
Eye = -0.684574,2.97917,-0.56351
Target = 1.28819,-5.52322,0.968231
Up = -0.474302,-0.261493,-0.84063
AntiAlias = 1
Detail = -3
DetailAO = -1.57143
FudgeFactor = 0.66265
MaxRaySteps = 64
BoundingSphere = 4 Locked
Dither = 0 Locked
NormalBackStep = 1
AO = 0,0,0,0.90123
Specular = 4.4304
SpecularExp = 16
SpotLight = 0.435294,0.737255,1,0.5
SpotLightDir = 0.65626,0.5
CamLight = 1,0.941176,0.898039,1.0566
CamLightMin = 0
Glow = 1,1,1,0
GlowMax = 20
Fog = 0
HardShadow = 0
ShadowSoft = 12.9032
Reflection = 0
BaseColor = 0.701961,0.701961,0.701961
OrbitStrength = 0
X = 0.411765,0.6,0.560784,0.41748
Y = 0.666667,0.666667,0.498039,-0.16504
Z = 1,0.258824,0.207843,1
R = 0.0823529,0.278431,1,0.82352
BackgroundColor = 0.607843,0.866667,0.560784
GradientBackground = 0.3261
CycleColors = true
Cycles = 4.04901
EnableFloor = false
FloorNormal = 0,0,0
FloorHeight = 0
FloorColor = 1,1,1
tubeRadius = 0.07534
groupRadius = 0.29851
objectRadius = 0.43077
Rotations = 3
RotDenominator = 3
RotNumeratorX = -2
RotNumeratorY = -4
#endpreset


Title: Re: Lame Klein bottle
Post by: fractower on January 26, 2012, 05:32:40 PM
It seems that everyone with a Shapeways account has done a Klein bottle. This is my attempt

http://www.shapeways.com/model/242965/ (http://www.shapeways.com/model/242965/)

The surface is is made from a 3d spirograph texture.


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 26, 2012, 06:07:32 PM
Quote from: fractower
From my second favorite math related sight http://paulbourke.net/geometry/klein/

Paul rules!!

The problem is that you can't (easily) extract a DE from a parametric equation. If that was possible easily I certainly had no need to ask ;)


Title: Re: Lame Klein bottle
Post by: kram1032 on January 26, 2012, 10:44:35 PM
Well, here you have an implicit formulation of the symmetric projection of the Klein bottle
http://www.wolframalpha.com/input/?i=klein+bottle

If you explicitly want the bottle-like one, I'm pretty sure, that requires yet another Polynomial of degree 12. Most likely one that, due to lack of symmetry, is even more complicated than the one given there...


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 26, 2012, 11:26:18 PM
I have further improved my routine removing the "intersected" zone, so now I have a "real" bottle that I can explore going inside it. Sorry, a Klein bottle has no inside ;)
Kram; I tried all parametrizations but none looked as pleasing as this; the symm one is like a "fat" bottle, very easy to implement as it is a single expression but a lot less elegant to my eye :)


Title: Re: Lame Klein bottle
Post by: kram1032 on January 27, 2012, 11:30:26 AM
Well, I guess that's a pure opinion thing, but I personally am a sucker for symmetry (any kind of, also fractal symmetry, obviously), so the symmetric version of the Klein bottle seems nicer to me.
The "bottle" one seems very much like giving it a real life meaning which it really hasn't.

The symmetry also helps to understand the shape better without your mind constantly interfering associations...


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 27, 2012, 12:49:27 PM
Images :o


Title: Re: Lame Klein bottle
Post by: cKleinhuis on January 27, 2012, 02:56:05 PM
ok, can we create drinking glasses from it and sell it as ff merchandise ?!
or is it open at the other end ??? :D


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 27, 2012, 04:30:14 PM
ok, can we create drinking glasses from it and sell it as ff merchandise ?!
or is it open at the other end ??? :D


Oh yeah, why don't you affiliate with those guys! http://www.kleinbottle.com/ :beer: :beer: :beer:

 ;D :worm:


Title: Re: Lame Klein bottle
Post by: kram1032 on January 27, 2012, 06:10:34 PM
Lawl...

Well, since the 3D projection of such a Klein Bottle will always intersect with itself, you have a part where liquid can be kept in... However, that part will not allow the liquid to get out again, so it's kinda pointless...

In an unprojected, "flat" version (by means of curvature and other things, the Klein Bottle actually behaves like the euclidean plane despite being limited in surface), you obviously couldn't keep any liquid. Especially once you start arguing what side is inside and after going in a circle once you suddenly realize, EVERY side is inside. :D
Or outside for that matter.


Title: Re: Lame Klein bottle
Post by: cKleinhuis on January 27, 2012, 08:38:35 PM
from the kleinbottle guys, it looks like it could keep something "inside" i really need to talk to those guys ....


Title: Re: Lame Klein bottle
Post by: knighty on January 27, 2012, 09:21:50 PM
Wow! Very nice klein bottle. Not lame anymore. Please change the title.  ;D

Well, here you have an implicit formulation of the symmetric projection of the Klein bottle
http://www.wolframalpha.com/input/?i=klein+bottle

If you explicitly want the bottle-like one, I'm pretty sure, that requires yet another Polynomial of degree 12. Most likely one that, due to lack of symmetry, is even more complicated than the one given there...
Here is a degree 6 formula :

((x^2+y^2+z^2)+2*y-1)*(((x^2+y^2+z^2)-2*y-1)^2-8*z^2)+16*x*z*((x^2+y^2+z^2)-2*y-1);

You can play with the numerical parameters. It's remarquable that doing so won't change the topology of the surface. It's in the structure of the polynomial not its parameters.

(I don't remember were I found the formula. That was some time ago.)



Title: Re: Lame Klein bottle
Post by: DarkBeam on January 27, 2012, 11:31:40 PM
from the kleinbottle guys, it looks like it could keep something "inside" i really need to talk to those guys ....


Also the mobius scarf and metallic platonic solids for sale :)
explore the site


Title: Re: Lame Klein bottle
Post by: Alef on January 29, 2012, 02:12:00 PM
I would prefare some darker glass for :beer: :beer: :beer: Are you using fragmentarium?


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 30, 2012, 10:47:50 AM
Wow! Very nice klein bottle. Not lame anymore. Please change the title.  ;D

Well, here you have an implicit formulation of the symmetric projection of the Klein bottle
http://www.wolframalpha.com/input/?i=klein+bottle

If you explicitly want the bottle-like one, I'm pretty sure, that requires yet another Polynomial of degree 12. Most likely one that, due to lack of symmetry, is even more complicated than the one given there...
Here is a degree 6 formula :

((x^2+y^2+z^2)+2*y-1)*(((x^2+y^2+z^2)-2*y-1)^2-8*z^2)+16*x*z*((x^2+y^2+z^2)-2*y-1);

You can play with the numerical parameters. It's remarquable that doing so won't change the topology of the surface. It's in the structure of the polynomial not its parameters.

(I don't remember were I found the formula. That was some time ago.)



My god Knighty!!!!! I casually opened the zip and another surprise! You are... Ran out of words! :verysurprised: :verysurprised: :verysurprised:


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 30, 2012, 12:10:19 PM
I would like to discuss also my method for finding a DE, without derivatives (that's the method that Knighty followed in its script)

Too bad, it is a bit too complicated for some surfaces, because it's needed to know the signs of every "polynomial component" of the surface.

Let's examine a very very simple example.

Let's define;
x2 = x*x;
y2 = y*y + z*z;
And examine the "lathed" Scarabaeus curve expression;

(x2 + y2) (x2 + y2 + R1 x)^2 - R2^2 (x2 - y2)^2 = 0

The problem for DE is that the field needs to be "approximately linear", on x,y,z. For example a sphere equation is;

x*x + y*y + z*z - R*R = 0

To make it "linear", we can take square root. It does not exist for negative values? Oh it's simple, bring R*R to the right.

x*x + y*y + z*z = R*R
Then;
sqrt(x*x + y*y + z*z) - abs(R) = 0
This gives a very good sphere DE.

Okay, applying the same method to the scarab curve is not so plain; (x2 + y2) (x2 + y2 + R1 x)^2 is always positive (a sum of squares) but (x2 - y2)^2 has a variable sign. If we expand we have (x2 - y2)^2 = (x^4 + y^4) - 2*(x*x*y*y)
Again we can separate positive and negative, because x*x*y*y is always >0 ;

ssqrt((x2 + y2) (x2 + y2 + R1 x)^2 + 2*R2*R2* (x*x*y*y))) - sqrt(R2)*ssqrt(x^4+y^4) where ssqrt(a) is sqrt(sqrt(a)) to make the vector field of power 1 because the highest power is 4. :)

That seems to works like a charm! :D

The problem is that many surfaces have lots mixed terms like x*y, or even power terms like x, x^3 ... , so separate those correctly is a trouble.

In particular Enneper implicit equation...

(http://upload.wikimedia.org/wikipedia/en/math/0/0/1/0016e4a9251b7b3c644802e18a3646f2.png)
(http://upload.wikimedia.org/wikipedia/en/math/e/7/4/e74f206bc633907ff8a7e83b8fffe320.png)
(http://upload.wikimedia.org/wikipedia/en/math/e/3/2/e32e5d818a01a6042c97f047bde5678e.png)

 :headbatting: :ugly:


Title: Re: Lame Klein bottle
Post by: knighty on January 30, 2012, 03:23:34 PM
That's interesting! unfortunately beside some 'simple' cases (like the sphere) the straighten operation is not (can't ?) be perfect. But you could also use derivatives of the straightened formula to get even better DE.

I had the same idea but in the case of escape time fractal distance estimation that i discussed some time ago with syntopia in his blog.


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 30, 2012, 05:22:48 PM
That's interesting! unfortunately beside some 'simple' cases (like the sphere) the straighten operation is not (can't ?) be perfect. But you could also use derivatives of the straightened formula to get even better DE.

I had the same idea but in the case of escape time fractal distance estimation that i discussed some time ago with syntopia in his blog.

For me your formula is wonderful but calculates three+1 times the function and it's hard to code (and slower than taking some roots). So wondering about a workaround. Later. :embarrass:


Title: Re: Lame Klein bottle
Post by: DarkBeam on January 30, 2012, 05:26:52 PM
Uh, in any case; Ennepers is 4-way symm. and in fact, look closer at the expressions.

z appears at even & odd powers.
x&y appear at even powers only.


This explains the symmetry and also reduces the problem a lot, because we must only pay attention to z sign. Let me work on this. :dink:


Title: Re: Lame Klein bottle
Post by: knighty on January 30, 2012, 09:17:00 PM
You are right. It's should be faster without using derivatives. :)


Title: Re: Lame Klein bottle
Post by: DarkBeam on February 09, 2012, 08:08:50 PM
Another merchandise idea

http://www.etsy.com/listing/66353455/worlds-smallest-klein-bottle

 :smooth: