Logo by Pauldelbrot - 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. July 27, 2021, 06:48:46 AM


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   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: Generalized shape inversion applied to the Mandelbox  (Read 3009 times)
0 Members and 1 Guest are viewing this topic.
CozyG
Forums Freshman
**
Posts: 13


« on: July 24, 2017, 11:29:09 PM »

Earlier this year I was exploring inversive geometry and implementing some new ideas as "variations" for IFS in JWildfire. I ended up writing a paper summarizing some of that work/play: Inversive Diversions and Diversive Inversions. And I'm giving a talk on it at the Bridges Math/Art conference later this week!

Now I'm experimenting with applying similar ideas to escape-time fractals. Which led me to implementing Mandelbox modifications in Fragmentarium. Well actually I've started with a 2D version of the Mandelbox, as I wanted to start simple.

The images and code below are my first attempt at modifying the circle inversions in the 2D Mandelbox to use a more generalized shape inversion. The idea is that the geometry to calculate inversion only requires determining two distances:
        d(OP), the distance from  the origin O of the inversion to the point P being inverted (transformed to P'
        d(OS), the distance from O to the unique point S on the boundary of inversion that lies on the line segment OP
Inversion is then:
        P' = P * [d(OS)]^2 / [d(OP)]^2

In the case of a circle, d(OS) is a constant: the radius of the circle of inversion. But the same equation can be applied to non-circular shapes as long as there is a way to determine d(OS), given O and P. Shapes that have a polar coordinate parameterization are good candidates to use for 2D shape inversion, as finding d(OS) can be done by calculating the polar angle of P relative to origin O, then plugging this back into the polar parametric equation to get the radial distance of the parameterized shape at the given angle, which is d(OS). The same reasoning applies to generalizing sphere inversion to 3D shape inversion. And shapes that have a spherical coordinate parameterization are good candidates to use for 3D shape inversion via a similar strategy. For more details and examples see the paper mentioned above. And for much more detail check out the references my paper cites -- I'm largely building off the more rigorous work of others, and maybe adding a few novel twists.

I think this may be a new technique to add to the Mandelboxen toolkit. But it's also possible that I've been exploring ground that's been covered before. I've only been deep diving into the Mandelbox for the last few months, so I've been playing catchup on many years of great brainstorming sessions on the forum! And looking at lots of Fragmentarium fragments and MB3D formulas for similar ideas. And there is a set of formulas, probably best represented by MB3D's ABoxVaryShapes, that on first glance may seem similar. However, as best I can tell these all modify the calculated distance from the origin of inversion to the iterated point --
 what I've labelled above as d(OP). Whereas the shape inversion that I'm implementing modifies the distance from the origin of inversion (and following the ray OP) to the boundary of the inversion -- d(OS). Does anyone know of similar techniques applied to the Mandelbox?

Okay time for pictures! Here's a few from my recent experiments in Fragmentarium. To highlight how shape inversions change a 2D Mandelbox all images have the same parameters except for different shape inversions. And I hacked in an overlay to show the boundary of the shape inversions.The first image uses a standard circle inversion. The second uses an ellipse inversion. The third uses a square inversion.







Fragmentarium frag files are in attachment. There are presets included for the images above and several more shapes.

Next step: moving to 3D shape inversions!

* Mandelbox2D_ShapeInversion2.zip (5.76 KB - downloaded 349 times.)
« Last Edit: July 27, 2017, 10:09:46 AM by CozyG » Logged
simon.snake
Fractal Bachius
*
Posts: 640


Experienced Fractal eXtreme plugin crasher!


simon.fez SimonSideBurns
« Reply #1 on: July 25, 2017, 12:19:35 AM »

Only the last of your pictures is showing.  The other two are broken links.

Scrub that, just refreshed and they all appear.  Must be my end.
Logged

To anyone viewing my posts and finding missing/broken links to a website called www.needanother.co.uk, I still own the domain but recently cancelled my server (saving ú30/month) so even though the domain address exists, it points nowhere.  I hope to one day sort something out but for now - sorry!
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #2 on: July 25, 2017, 01:06:18 AM »

I get no pics (refresh doesn't do it) and Server not found for the zip  lips are sealed ...

@CozyG when posting a frag, your zip should be small enough, < 256k, to attach to the post ( under Additional Options... ), this way you don't have to worry about third party storage sites or site filter settings preventing others from enjoying your work, same with images, post them in the FF gallery first and then link with BB code in your post (here) ... just a thought wink
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
CozyG
Forums Freshman
**
Posts: 13


« Reply #3 on: July 25, 2017, 01:56:00 AM »

I get no pics (refresh doesn't do it) and Server not found for the zip  lips are sealed ...

@CozyG when posting a frag, your zip should be small enough, < 256k, to attach to the post ( under Additional Options... ), this way you don't have to worry about third party storage sites or site filter settings preventing others from enjoying your work, same with images, post them in the FF gallery first and then link with BB code in your post (here) ... just a thought wink

Ugh, apologies for the broken links. It may be time for me to break up with DropBox -- whatever happened to your simple URLs that just worked, DB? I've revised the links, can you see the images now?

I posted the frag as a link instead of an attachment because I was having trouble getting forum attachment upload to work. Which turned out to be a browser problem on my end -- when I switched from Chrome to Firefox it worked fine. I've got way too many extensions mucking things up on Chrome, my Firefox install is much more vanilla. So now the frag is an attachment and I'm hoping the revised links work.
« Last Edit: July 25, 2017, 02:05:47 AM by CozyG » Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #4 on: July 25, 2017, 02:49:17 AM »

...still no pics but I got the frag so I can make my own wink  A Beer Cup
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #5 on: July 25, 2017, 01:24:01 PM »

Thanks for posting, I like the example images.


The way I envision this, is  that the condition "minimum_radius_squared" is a sphere shape, but the shape could be almost  anything, even a blob.

This is a simple code which  can be used to distort a sphere shape conditional limit.

Code:
// abox minR2 bias

z = fabs(z + limit) - fabs(z - limit) - z;

float m = scale; // default 2.0
float minR2 = minimumR2; // default .25
float rr = dot(z,z);

float temp = length(z);
if (sqrLength == 1 ) temp = rr;
minR2 = minR2 + z.x * zxScale / temp;  //  defaults 0  = no distortion
minR2 = minR2 + z.y * zyScale / temp;
minR2 = minR2 + z.z * zzScale / temp;


if (rr < minR2) m *= native_divide(1.0, minR2);
else if (rr < 1.0) m *= native_divide(1.0, rr);

Logged
CozyG
Forums Freshman
**
Posts: 13


« Reply #6 on: July 27, 2017, 04:10:43 PM »

@3dickulus: I've now switched to putting my images on a hosted website, if you get a chance please let me know if you can see them now?

@mclarekin:

Yep that sounds similar to the way I'm approaching shape inversion, but I think there are some differences. In the originating post I'm showing examples where the boundary of inversion ("circle of inversion" in the default case) is modified into a non-circular shape. Whereas the code you posted is modifying the minimum bounds check, below which a scaling is done instead of an inversion. As you point out, this can also be represented by a shape. But I think my definition of "shape" is a bit more restrictive, which to differentiate I'll call for now an independent shape or "ishape" for short. An ishape is in some sense independent of the point being iterated, as the surface of the ishape is intrinsic to it and stays the same regardless of the point's changing position. Back to inversive geometry, the two values needed to calculate the inverse of a point are d(OP), the distance from the inversion origin O to the iterated point P along a ray OP from O to P, and d(OS) the distance from O to the surface of the inversion along the same ray OP. Then for any point Z on the same ray OP, for an ishape [d(OS) for Z] = [d[OS] for P]. Or to rephrase, the calculated distance from inversive origin to intersection with the inversive surface depends only on the angle between the iterated point P and the inversive origin. Since the minimum bounds check is determining what points inversion is actually performed on, for my strategy I'm also requiring that it be replaced with an ishape.

In the code you posted, the way that minR2 is modified means it is not an ishape, although it may be a shape under a looser definition, and in any case it gives interesting results. So why am I trying to stick with ishapes? Well that's a good question, and I do have an answer, though not necessarily a good one. My intuition is that replacing spheres of inversion and conditional bounding spheres with ishapes (instead of more general distortions) may make it easier to find that sweet spot of just enough distortion to be interesting but not so much as to get the "pulled taffy" effect. My thinking is that when combined with inversion (which is already scaling differentially, albeit conformally for sphere inversion), a modifier that guarantees constant scaling for all points along a ray will keep things "more conformal" than a modfier that doesn't. Any thoughts?


Logged
CozyG
Forums Freshman
**
Posts: 13


« Reply #7 on: July 27, 2017, 04:31:23 PM »

I've been extending my Fragmentarium code for testing out 2D Mandelbox shape inversions. In addition to replacing the circle of inversion with an inversion shape, the new version allows replacing the conditional minimum radius with a shape.  Different shapes can be used for inversion and minradius. It also shows an overlay of the inversion shape and min shape.

Here's a few examples. First, a baseline image with two circle shapes that behave like a normal conditional circle inversion:


Changing the circle inversion to a square and the circle minradius to an ellipse:


Changing the circle inversion to a hexagon and the circle minradius to a superellipse:


There is also an option to use a third shape, the max shape. I plan to make a separate post tomorrow about use of the max shape...
New version of the fragment is attached.

* Mandelbox2D_ShapeInversion5.zip (6.61 KB - downloaded 336 times.)
Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #8 on: July 28, 2017, 02:27:35 AM »

Yes! I see the pics now, very cool. I might have to add a "CozyG" folder to the Examples wink (if that's ok with you)
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #9 on: July 28, 2017, 03:10:36 AM »

This is very cool, thanks for posting,  It is much easier to see what is happening with your 2D images

This could turn into a very big formula with lots of options. grin

The MinR2 and MaxR2 shapes could be setup  with more controls.  ie the square shape able to be stretched to a rectangle, offset and then the shape rotated about  ( 0, 0)

When I have some spare time I will code up the 3D version for MandelbulberV2.

There is also options with the scaling that happens up to  MaxR2. i.e.
Code:
{
rr = z.Dot(z);
z += offset;
z *= scale;
DE = DE * fabs(scale) + 1.0;
double maxScale = scale4;
double midPoint = (maxScale - 1.0) * 0.5;
rr += offset0;
double maxR2 = scale1;
double halfMax = maxR2 * 0.5;
double factor = midPoint / (halfMax * halfMax);


double tempM = rr + offsetA0;
if (rr < halfMax)
{
m = maxScale - (rr * rr) * factor;
m = 1.0 + (maxR2 - rr) * (maxR2 - rr) * factor;
if ( m > tempM) m = tempM + (tempM - m);
z *= m;
DE *= m;

}
else if (rr < maxR2)
{
m = 1.0 + (maxR2 - rr) * (maxR2 - rr) * factor;
if (& m > tempM) m = tempM + (tempM - m);
z *= m;
      DE *= m;
}
        z -= offset;
}
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #10 on: July 28, 2017, 09:25:48 AM »

@ CozyG.

You have got me inspired!! smiley ( and sidetracked from what I should be doing roll eyes)

I have limited maths and coding knowledge but I am going to have a look at MinR2 as a simple cuboid (i had to google that term as it is over 40 years ago that I did maths at school.) 

I will make a 3D.frag,  and post it.  I will also convert the code I posted above into a .frag so it is less confusing.

Keep up the good work .!! A Beer Cup A Beer Cup A Beer Cup

More and more layers of infinite possibility for the simple Mandelbox.

BTW feel free to code up any formulas in c++ for MandelbulberV2  grin coz it takes me a long time and I only do the simple things ( I still haven't coded darkbeams  MB3D's ABoxVaryShape because it looked to complicated when I first looked at it. But I  am getting better at it, and have learnt a lot in the last two years since I started doing this sort of thing, thanks mainly to all the helpful sharing people here at fractal forums.
Logged
CozyG
Forums Freshman
**
Posts: 13


« Reply #11 on: July 28, 2017, 07:08:15 PM »

Yes! I see the pics now, very cool. I might have to add a "CozyG" folder to the Examples wink (if that's ok with you)

 grin
Thanks, I'd be honored to get a version included in the examples!
And glad my image links are finally working.
Logged
CozyG
Forums Freshman
**
Posts: 13


« Reply #12 on: July 28, 2017, 10:38:21 PM »

This is very cool, thanks for posting,  It is much easier to see what is happening with your 2D images
This could turn into a very big formula with lots of options. grin
Glad you're liking my experiments! I have more experience with visualization in 2D than I do in 3D, so that's where I started.

Quote
The MinR2 and MaxR2 shapes could be setup  with more controls. ie the square shape able to be stretched to a rectangle, offset and then the shape rotated about  ( 0, 0)

More control of the shapes would be good!

Stretching: I like the idea of stretching the square to a rectangle, and similar stretches of the other regular polygons to non-regular polygons. But the algorithm I'm using for intersection with polygons uses a polar parameterization that only works for regular polygons. For non-regular polygons I want to move to a much more general line-polygon intersection algorithm. Hopefully for Fragmentarium I can find an existing GLSL implementation and adapt. Anyone have suggestions?

Offset: For the version that I most recently posted, the min and max shapes share the same offset as the inversion shape (InvCenter). However in an earlier version the min and max shapes each had their own offsets. But I stripped that out before posting because it was misbehaving. I'll try to fix, though if I continue to have problems I may just post the broken version and see if someone can spot what I'm doing wrong.

Rotation: In my previous work with shape inversion in JWildfire I gave each shape a parameter for rotation about its center, and it was indeed very useful. I'll add shape rotations for the next version of 2D Mandelbox shape inversion, should be able to get that out later today.

Quote
When I have some spare time I will code up the 3D version for MandelbulberV2.
...
I have limited maths and coding knowledge but I am going to have a look at MinR2 as a simple cuboid (i had to google that term as it is over 40 years ago that I did maths at school.)  
I will make a 3D.frag, and post it

Yay! It would be great to see a 3D version! For general polyhedra I would hope that there is existing 3D line-polyhedra intersection code that could be adapted, similar to what I want to do for general 2D line-polygon instersection. Though more specific algorithms for cuboid etc. will probably be more efficient than such a general intersection algorithm. Hmm, for the platonic solids I wonder if there is a spherical coordinate parameterization for 3D intersection of a platonic surface with a ray extending out from its center, similar to the polar coordinate parameterization I'm using for 2D intersection of a regular polygon with a ray extending from its center?


Quote
There is also options with the scaling that happens up to  MaxR2. i.e.
...code...
 I will also convert the code I posted above into a .frag so it is less confusing.
...
BTW feel free to code up any formulas in c++ for MandelbulberV2

Yes if it was recoded as a .frag it would probably be easier for me to see what it does. Sometimes I can only understand what various formula are really doing by tweaking them and seeing what happens.
I'd be interested in trying to write some C++ formulas in Mandelbulber. I'm assuming that means I'd need to be able to compile Mandelbulber from source? That might be the tricky part for me, its been many years since I've compiled a C/C++ program. Well other than when "make" just works smiley

Thanks for all the encouragement!
« Last Edit: July 28, 2017, 10:44:54 PM by CozyG » Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #13 on: July 29, 2017, 01:48:56 AM »

I tried a cuboid limits for MinR2 and it seems to works well. 

the below is in OpenCL which is very similar to a frag, except for float3 vrs vec3, and fabs() vrs abs().

I will play with it some more then  code it into a .frag,




Code:
z = fabs(z + limit) - fabs(z - limit) - z;

float m = scale;

float rr = dot(z,z);



temp3 = fabs(z);

if (mode13 == 1) temp3 *= temp3; // this is more mathematically correct?

// limit is a vec3 of the three xyz box limits

if (temp3.x < limit.x && temp3.y < limit.y && temp3.z < limit.z)
{
// find which limit is hit first
R2.x =  limit.x /temp3.x;
R2.y =  limit.y /temp3.y;
R2.z =  limit.z /temp3.z;
float First = min(R2.x, min(R2.y, R2.z));

MinR2 = rr * First; // the limit for the point
m *= native_divide(MaxR2,MinR2);

}
else if (rr < MaxR2) m *= native_divide(MaxR2,rr);

z = Matrix33MulFloat3(consts->fractal.mandelbox.mainRot, z);


z = z * m + c3 + cJ;
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #14 on: July 29, 2017, 10:53:09 AM »

@ CozyG
I  posted a 3D frag of the simplest cuboid minR2 version  and it is identical to my Mandelbulber V1.21 OpenCL version (except rotated 90 degrees.)   Have not tested it much.  I am sidetracked on to  trying out some other things.

Like,    when the minR2 conditional limits are a cuboid that triggers the standard   MaxR2/ MinR2     e.g if   p3 is in the limits of the cuboid, then multiply by  MaxR2(spherical) /  MinR2(spherical).

But this can distort too much in the vicinity of the cuboid vertices.

What maybe worth trying in 2D , is   having the   MinR2    conditional limit  being spherical,    and vec3 p    multiplied by      MaxR2 (spherical)/MinR2 (elliptical),        and vice versa.

In respect to  having the transform placed inside  an offset and the reverse offset  ,   so far my basic testing  has generated  cuts in the fractal sad.

I will do some more playing around with this code, but I think that the maths is probably going to get beyond my ability.



This image is a standard -1.5 Mbox MaxR2 = 1,  but with the MinR2 sphere of 0.25 replaced with a cuboid shape of (0.2, 0.4, 04).









* aboxminR2cuboid ght1a.jpg (202.86 KB, 600x607 - viewed 695 times.)
Logged
Pages: [1] 2   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.206 seconds with 25 queries. (Pretty URLs adds 0.009s, 2q)