Logo by Sockratease - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. March 28, 2024, 08:14:09 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: 1 [2] 3 4 ... 9   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Polyhedrons, many many polyhedrons...  (Read 44906 times)
0 Members and 1 Guest are viewing this topic.
knighty
Fractal Iambus
***
Posts: 819


« Reply #15 on: January 26, 2012, 09:47:35 PM »

Hi,
Great and wonderful website Adrian. Indeed it's a great source of inspiration (thanks blob).

here is a fragmentarium script for regular and convex polyhedra family. Hope you will like it:
Code:
#info fold and cut regular polyhedra Distance Estimator (knighty 2012)
#define providesInit
#define providesColor
#include "DE-Raytracer.frag"
#include "MathUtils.frag"

#group polyhedra

// Symmetry group type.
uniform int Type;  slider[3,5,5]

// U 'barycentric' coordinate for the 'principal' node
uniform float U; slider[0,1,1]

// V
uniform float V; slider[0,0,1]

// W
uniform float W; slider[0,0,1]

//vertex radius
uniform float VRadius; slider[0,0.05,0.5]

//segments radius
uniform float SRadius; slider[0,0.01,0.1]

uniform bool displayFaces; checkbox[true]
uniform bool displaySegments; checkbox[true]
uniform bool displayVertices; checkbox[true]

#group polyhedraColor
uniform vec3 face0Color; color[0.0,0.0,0.0]
uniform vec3 face1Color; color[0.0,0.0,0.0]
uniform vec3 face2Color; color[0.0,0.0,0.0]
uniform vec3 verticesColor; color[0.0,0.0,0.0]
uniform vec3 segmentsColor; color[0.0,0.0,0.0]

#define PI 3.14159
vec3 nc,p,pab,pbc,pca;
void init() {
float cospin=cos(PI/float(Type)), scospin=sqrt(0.75-cospin*cospin);
nc=vec3(-0.5,-cospin,scospin);
pab=vec3(0.,0.,1.);
pbc=normalize(vec3(scospin,0.,0.5));
pca=normalize(vec3(0.,scospin,cospin));
p=normalize((U*pab+V*pbc+W*pca));
}

vec3 fold(vec3 pos) {
for(int i=0;i<Type;i++){
pos.xy=abs(pos.xy);
float t=-2.*min(0.,dot(pos,nc));
pos+=t*nc;
}
return pos;
}

float D2Planes(vec3 pos) {
float d0=dot(pos,pab)-dot(pab,p);
float d1=dot(pos,pbc)-dot(pbc,p);
float d2=dot(pos,pca)-dot(pca,p);
return max(max(d0,d1),d2);
}

float D2Segments(vec3 pos) {
pos-=p;
float dla=length(pos-min(0.,pos.x)*vec3(1.,0.,0.));
float dlb=length(pos-min(0.,pos.y)*vec3(0.,1.,0.));
float dlc=length(pos-min(0.,dot(pos,nc))*nc);
return min(min(dla,dlb),dlc)-SRadius;//max(max(dla,dlb),max(dlc,dlp))-SRadius;
}

float D2Vertices(vec3 pos) {
return length(pos-p)-VRadius;
}

float DE(vec3 pos) {
pos=fold(pos);
float d=10000.;
if(displayFaces) d=min(d,D2Planes(pos));
if(displaySegments) d=min(d,D2Segments(pos));
if(displayVertices) d=min(d,D2Vertices(pos));
return d;
}

vec3 color(vec3 pos, vec3 normal){
pos=fold(pos);
float d0=1000.0,d1=1000.0,d2=1000.,dv=1000.,ds=1000.;
if(displayFaces){
d0=abs(dot(pos,pab)-dot(pab,p));
d1=abs(dot(pos,pbc)-dot(pbc,p));
d2=abs(dot(pos,pca)-dot(pca,p));
}
if(displaySegments) ds=D2Segments(pos);
if(displayVertices) dv=D2Vertices(pos);
float d=min(min(d0,min(d1,d2)),min(ds,dv));
vec3 col=face0Color;
if(d==d1) col=face1Color;
if(d==d2) col=face2Color;
if(d==ds) col=segmentsColor;
if(d==dv) col=verticesColor;
return col;
}

#preset default
FOV = 0.62536
Eye = -3.59281,-1.35854,-1.5123
Target = 4.11696,1.54296,1.75405
Up = 0.476591,-0.750108,-0.458475
AntiAlias = 1
Detail = -3
DetailAO = -1.57143
FudgeFactor = 1
MaxRaySteps = 88
BoundingSphere = 2
Dither = 0.4386
NormalBackStep = 1
AO = 0,0,0,0.90123
Specular = 4.4304
SpecularExp = 16
SpotLight = 1,1,1,0.75
SpotLightDir = 0.6923,0.78462
CamLight = 1,0.827451,0.768627,0.6415
CamLightMin = 0
Glow = 1,1,1,0
GlowMax = 20
Fog = 0
HardShadow = 0
ShadowSoft = 8.254
Reflection = 0
BaseColor = 0.721569,0.721569,0.721569
OrbitStrength = 0.37662
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.501961,0.737255,0.956863
GradientBackground = 0.86955
CycleColors = true
Cycles = 4.04901
EnableFloor = false
FloorNormal = 0,0,0
FloorHeight = 0
FloorColor = 1,1,1
Type = 5
U = 1
V = 0.54545
W = 0
VRadius = 0.08427
SRadius = 0.02921
displayFaces = true
displaySegments = true
displayVertices = true
face0Color = 0.796078,0.611765,0.172549
face1Color = 0.164706,0.74902,0.12549
face2Color = 0.164706,0.305882,0.764706
verticesColor = 1,0,0
segmentsColor = 0.25098,0.760784,0.490196
#endpreset
Logged
Adrian
Guest
« Reply #16 on: January 27, 2012, 09:44:35 AM »

Hi Knighty

Fragmentarium built very easily and quickly here, on an older machine running Ubuntu.
I like your script. Quite good fun to play with the polyhedra like that, and I notice that
functional part of the script is very short.

Adrian.
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #17 on: January 27, 2012, 10:47:12 AM »

Hi,
Great and wonderful website Adrian. Indeed it's a great source of inspiration (thanks blob).

here is a fragmentarium script for regular and convex polyhedra family. Hope you will like it:
Code:
#info fold and cut regular polyhedra Distance Estimator (knighty 2012)
#define providesInit
#define providesColor
#include "DE-Raytracer.frag"
#include "MathUtils.frag"

#group polyhedra

// Symmetry group type.
uniform int Type;  slider[3,5,5]

// U 'barycentric' coordinate for the 'principal' node
uniform float U; slider[0,1,1]

// V
uniform float V; slider[0,0,1]

// W
uniform float W; slider[0,0,1]

//vertex radius
uniform float VRadius; slider[0,0.05,0.5]

//segments radius
uniform float SRadius; slider[0,0.01,0.1]

uniform bool displayFaces; checkbox[true]
uniform bool displaySegments; checkbox[true]
uniform bool displayVertices; checkbox[true]

#group polyhedraColor
uniform vec3 face0Color; color[0.0,0.0,0.0]
uniform vec3 face1Color; color[0.0,0.0,0.0]
uniform vec3 face2Color; color[0.0,0.0,0.0]
uniform vec3 verticesColor; color[0.0,0.0,0.0]
uniform vec3 segmentsColor; color[0.0,0.0,0.0]

#define PI 3.14159
vec3 nc,p,pab,pbc,pca;
void init() {
float cospin=cos(PI/float(Type)), scospin=sqrt(0.75-cospin*cospin);
nc=vec3(-0.5,-cospin,scospin);
pab=vec3(0.,0.,1.);
pbc=normalize(vec3(scospin,0.,0.5));
pca=normalize(vec3(0.,scospin,cospin));
p=normalize((U*pab+V*pbc+W*pca));
}

vec3 fold(vec3 pos) {
for(int i=0;i<Type;i++){
pos.xy=abs(pos.xy);
float t=-2.*min(0.,dot(pos,nc));
pos+=t*nc;
}
return pos;
}

float D2Planes(vec3 pos) {
float d0=dot(pos,pab)-dot(pab,p);
float d1=dot(pos,pbc)-dot(pbc,p);
float d2=dot(pos,pca)-dot(pca,p);
return max(max(d0,d1),d2);
}

float D2Segments(vec3 pos) {
pos-=p;
float dla=length(pos-min(0.,pos.x)*vec3(1.,0.,0.));
float dlb=length(pos-min(0.,pos.y)*vec3(0.,1.,0.));
float dlc=length(pos-min(0.,dot(pos,nc))*nc);
return min(min(dla,dlb),dlc)-SRadius;//max(max(dla,dlb),max(dlc,dlp))-SRadius;
}

float D2Vertices(vec3 pos) {
return length(pos-p)-VRadius;
}

float DE(vec3 pos) {
pos=fold(pos);
float d=10000.;
if(displayFaces) d=min(d,D2Planes(pos));
if(displaySegments) d=min(d,D2Segments(pos));
if(displayVertices) d=min(d,D2Vertices(pos));
return d;
}

vec3 color(vec3 pos, vec3 normal){
pos=fold(pos);
float d0=1000.0,d1=1000.0,d2=1000.,dv=1000.,ds=1000.;
if(displayFaces){
d0=abs(dot(pos,pab)-dot(pab,p));
d1=abs(dot(pos,pbc)-dot(pbc,p));
d2=abs(dot(pos,pca)-dot(pca,p));
}
if(displaySegments) ds=D2Segments(pos);
if(displayVertices) dv=D2Vertices(pos);
float d=min(min(d0,min(d1,d2)),min(ds,dv));
vec3 col=face0Color;
if(d==d1) col=face1Color;
if(d==d2) col=face2Color;
if(d==ds) col=segmentsColor;
if(d==dv) col=verticesColor;
return col;
}

#preset default
FOV = 0.62536
Eye = -3.59281,-1.35854,-1.5123
Target = 4.11696,1.54296,1.75405
Up = 0.476591,-0.750108,-0.458475
AntiAlias = 1
Detail = -3
DetailAO = -1.57143
FudgeFactor = 1
MaxRaySteps = 88
BoundingSphere = 2
Dither = 0.4386
NormalBackStep = 1
AO = 0,0,0,0.90123
Specular = 4.4304
SpecularExp = 16
SpotLight = 1,1,1,0.75
SpotLightDir = 0.6923,0.78462
CamLight = 1,0.827451,0.768627,0.6415
CamLightMin = 0
Glow = 1,1,1,0
GlowMax = 20
Fog = 0
HardShadow = 0
ShadowSoft = 8.254
Reflection = 0
BaseColor = 0.721569,0.721569,0.721569
OrbitStrength = 0.37662
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.501961,0.737255,0.956863
GradientBackground = 0.86955
CycleColors = true
Cycles = 4.04901
EnableFloor = false
FloorNormal = 0,0,0
FloorHeight = 0
FloorColor = 1,1,1
Type = 5
U = 1
V = 0.54545
W = 0
VRadius = 0.08427
SRadius = 0.02921
displayFaces = true
displaySegments = true
displayVertices = true
face0Color = 0.796078,0.611765,0.172549
face1Color = 0.164706,0.74902,0.12549
face2Color = 0.164706,0.305882,0.764706
verticesColor = 1,0,0
segmentsColor = 0.25098,0.760784,0.490196
#endpreset


 surprised scared white That is quite stunning!  A Beer Cup Knighty
Logged

No sweat, guardian of wisdom!
blob
Strange Attractor
***
Posts: 272



« Reply #18 on: January 27, 2012, 04:31:10 PM »

Cool shader knighty!  A Beer Cup



* crryyd-6b.jpg (71.12 KB, 573x409 - viewed 825 times.)
Logged
subblue
Conqueror
*******
Posts: 116



WWW
« Reply #19 on: January 27, 2012, 05:13:26 PM »

Brilliant stuff Knighty!
Logged

www.subblue.com - a blog exploring mathematical and generative graphics
knighty
Fractal Iambus
***
Posts: 819


« Reply #20 on: January 27, 2012, 08:16:48 PM »

Thank you!  embarrass

There is more to come but it requires some work.

Adrian: The fold and cut 'technique' allows for such short algorithm. It consist on applying a folding operation about the planes that define the fundamental domain. Then compute the distance to some basic shape. This way we get all mirror images of the basic shape just like a kaleidoscope.  smiley
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #21 on: January 27, 2012, 11:40:40 PM »

How about a rotating hypercube? cheesy It is a wonderful anim I saw in many places!
Hypercube coords should be (1,1,1,1) with all possible signs. (I think cheesy) I cannot believe you managed to show wireframe so easily! You live inside a graphics card? grin
Logged

No sweat, guardian of wisdom!
knighty
Fractal Iambus
***
Posts: 819


« Reply #22 on: January 28, 2012, 07:20:51 PM »

Well... the simplest method I can think of involves computing the minimal distance between a line and each of the 32 segments in 4D space.

This is a projection form 4D space to 3D space. In general, having a 4D distance field, the distance from a point in 3D to the projection of the 4D object to 3D space (in reality the silhouette of the 4D object as it is projected) is the minimal distance along the 4D ray going through our 3D point.

Another method is to render its stereoraphic projection onto 3D space. Just what syntopia asked for in the thread about knots. I am trying to work it out. smiley
Logged
knighty
Fractal Iambus
***
Posts: 819


« Reply #23 on: January 29, 2012, 08:32:55 PM »

Ok! here it is. syntopia is served!  afro

* polychora03.zip (2.46 KB - downloaded 402 times.)
Logged
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #24 on: January 29, 2012, 10:16:05 PM »

Knighty, that is truly amazing! I cannot believe you did this. Is this true 4D->3D perspective projection?

I can't wait to explore this script some more and see if I can figure out how you did it.

Here is a few quick test renders:



* pc1.jpg (37.99 KB, 600x425 - viewed 811 times.)

* pc2.jpg (47.65 KB, 595x430 - viewed 827 times.)

* pc3.jpg (45.24 KB, 599x429 - viewed 801 times.)
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #25 on: January 30, 2012, 09:42:44 AM »

This is the most brilliant script of all times - not only for Fragmentarium w00t !! surprised crazy
Logged

No sweat, guardian of wisdom!
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #26 on: January 30, 2012, 10:20:28 AM »

i couldnt get those shapes out of the script ? what parameters do you use ?!
Logged

---

divide and conquer - iterate and rule - chaos is No random!
knighty
Fractal Iambus
***
Posts: 819


« Reply #27 on: January 30, 2012, 03:04:15 PM »

 grin
i couldnt get those shapes out of the script ? what parameters do you use ?!
I can't tell exactly which parameters syntopia used but the script comes with 3 presets to begin with. (the last one is interresting because it's almost just like what you would see if you live inside the hypersphere wink ).

Is this true 4D->3D perspective projection?
No, it is a stereographic projection. the polychoron is projected first onto the hypersphere then onto the 3D space with a stereographic projection. this is the same as Jehn-3D. This evening, I hope, I'll post another version that will hopefully looke much like Jehn-3D but without the faces (that requires transparency): the vertices and segments should look thicker as we go further from the origin. And also a better and more intuitive (sic.) rotation.
 
That said, I'm planning to write a detailed explanation on how it is done but before (or after. It depends on the complexity of these things) I want to do stellated polyhedrons and a dive into 3D tesselated hyperbolic plane. Not eazy but doable. cheesy
Logged
blob
Strange Attractor
***
Posts: 272



« Reply #28 on: January 30, 2012, 04:30:27 PM »

I want to do stellated polyhedrons and a dive into 3D tesselated hyperbolic plane. Not eazy but doable. cheesy

Cool, looking forward to playing with those. In the meantime this polychora shader is awesome.  A Beer Cup



* rr787d-2b.jpg (84.34 KB, 600x450 - viewed 775 times.)
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #29 on: January 30, 2012, 05:16:02 PM »

That said, I'm planning to write a detailed explanation on how it is done but before (or after. It depends on the complexity of these things) I want to do stellated polyhedrons and a dive into 3D tesselated hyperbolic plane. Not eazy but doable. cheesy

Look at this code, this is the source of Poincare3D by Zueuk. I did not dare to try this but you may like grin ;

Code:
// You must call the argument "vp".
int PluginVarPrepare(Variation* vp)
{
    VAR(cx) = -VAR(poincare3D_r) * cos(VAR(poincare3D_a)*M_PI_2) * cos(VAR(poincare3D_b)*M_PI_2);
    VAR(cy) =  VAR(poincare3D_r) * sin(VAR(poincare3D_a)*M_PI_2) * cos(VAR(poincare3D_b)*M_PI_2);
    VAR(cz) = -VAR(poincare3D_r) * sin(VAR(poincare3D_b)*M_PI_2);

    VAR(c2) = sqr(VAR(cx)) + sqr(VAR(cy)) + sqr(VAR(cz));

    VAR(c2x) = 2 * VAR(cx);
    VAR(c2y) = 2 * VAR(cy);
    VAR(c2z) = 2 * VAR(cz);

    VAR(s2x) = sqr(VAR(cx)) - sqr(VAR(cy)) - sqr(VAR(cz)) + 1;
    VAR(s2y) = sqr(VAR(cy)) - sqr(VAR(cx)) - sqr(VAR(cz)) + 1;
    VAR(s2z) = sqr(VAR(cz)) - sqr(VAR(cy)) - sqr(VAR(cx)) + 1;

    // Always return TRUE.
    return TRUE;
}

// You must call the argument "vp".
int PluginVarCalc(Variation* vp)
{
    double r2 = sqr(FTx) + sqr(FTy) + sqr(FTz);

    double x2cx = VAR(c2x)*FTx, y2cy = VAR(c2y)*FTy, z2cz = VAR(c2z)*FTz;

    double d = VVAR / (
        VAR(c2) * r2 - x2cx - y2cy - z2cz + 1
        );

    FPx += d * (
        FTx * VAR(s2x) + VAR(cx) * (y2cy + z2cz - r2 - 1)
    );
    FPy += d * (
        FTy * VAR(s2y) + VAR(cy) * (x2cx + z2cz - r2 - 1)
    );
    FPz += d * (
        FTz * VAR(s2z) + VAR(cz) * (y2cy + x2cx - r2 - 1)
    );

    return TRUE;
}

(Note; in a "normal" formula, replace FT stuff with current coordinates - x,y,z while FP are the resulting coords, but instead of do += you should do a normal assignment. I know also that it is not so easy. Aexion told me that there are methods to convert ifs to escape time; should be something like "if length(newcoord)<length(oldcoord) apply transform")

There are other three variations but some use a random() thingy so it's not a normal transform.  sad This looks promising... In apo does a stunning work!
« Last Edit: January 30, 2012, 05:19:57 PM by DarkBeam » Logged

No sweat, guardian of wisdom!
Pages: 1 [2] 3 4 ... 9   Go Down
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.234 seconds with 24 queries. (Pretty URLs adds 0.012s, 2q)