Logo by KRAFTWERK - 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: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. March 28, 2024, 12:25:35 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]   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: Sphere inversion transformation in M3D  (Read 7791 times)
0 Members and 1 Guest are viewing this topic.
JosLeys
Strange Attractor
***
Posts: 258


WWW
« on: July 25, 2016, 02:01:53 PM »

I know all about sphere inversions, but do not understand how it is implemented in M3D, and am really interested in how it is done.

I presume M3d follows a ray to a screen pixel accoring to a calculated DE coming out of the chosen formulas.
Inverting the point on the ray in a sphere just puts this point elsewhere in space, and I don't see how this affects the shape of the fractal object, so that probably is not it..

Can anyone shed some light on this?

Thanks,

Jos

Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #1 on: July 27, 2016, 01:16:24 AM »

Jos, I have been waiting for someone more knowledgeable to answer this sad

My answer is based on Mandelbulber code and assuming I am reading your question properly,

My understanding is that sphere inversion is a transform used in some fractals and hence affects the shape of the fractal object.  The formula code creates the fractal point, the ray marching comes afterwards, to find an estimation of the point. The speed and accuracy of finding these points by ray marching is based on the specific distance estimation algorithm used.


I think?? grin, but I am not an expert (yet) Azn

Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #2 on: July 28, 2016, 08:36:41 AM »

@mclarekin: thank you for your answer, but it does not help me much in implementing the transformation for fractal objects...
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #3 on: July 28, 2016, 10:09:16 AM »

The quote below  is the implementation in M3D


My understanding is you divide x, y, & z by radius squared (Rho in Darkbeams formula).  If you iterate this on its own i will just keep mapping back on to itself. To use it if you must make the function conditional and/or do some other maths before the next iteration.  I have used it in a few formulas but have yet to fully explore the possibilities.


Quote
[OPTIONS]
.Version = 8
.DEscale = 0.2
.DEoption = 1
.Double X center = 0
.Double Y center = 0
.Double Z center = 0
.DRecipro Radius = 1
.DReci2 Rad2 = -1
.Integer FoldMode (1 or 2) = 1
Code:
558BEC5657538B750889C38B7E30DD01DC47E0DD02DC47E8DD03DC47F0D9C0D8
C8D9C2D8C8DEC1D9C3D8C8DEC1DC4FD8837FC400740BD9E8D8D9DFE080E44177
47DC57D0DFE080E4417725D9E8DEF1DCC9DCCADCCBDDD8DC67F0DD1BDC67E8DD
1ADC67E0DD1989D85B5F5E5DC2080090837FC4027407DDD8DD47C8EBD2D9E0DC
47D0DC47D0EBC490DDD8DDD8DDD8DDD8EBD4
[END]

Description:

Sphere inversion in 3D with radius and center.
Fold mode; enable this to get conditional inversions.
MODE 1; inversion INSIDE a sphere. Choose Rad2<Radius
to "cancel" the inversion inside a smaller sphere
MODE 2; same as mode 1, but the "cancel" is a non
conformal transformation.
Formula by Luca GN 2011

x', y', z' => Translate + scaling (by radius) of x, y, z with given params.
Then, defined Rho = (x'*x'+y'*y'+z'*z'),
( folding mode section)
x'' = x'/Rho
y'' = y'/Rho
z'' = z'/Rho
For your convenience, x'',y'',z'' are translated back.
Basic formula and explanations can be read here;
http://en.wikipedia.org/wiki/Inversive_geometry

"Folding modes" & optimizations

Folding mode criteria ;
if rho < Radius & rho > Rad2, do the transform
if rho < Radius & rho < Rad2, do the transform but
in mode 1, let rho = Rad2 (conformal - undo the inversion inside a sphere)
in mode 2, let rho = 2 Rad2 - rho (non conformal "reversal" inversion)
if rho > Rad2, don't do anything

------
new version 19 may 2012
Rewritten to fix some bugs, so now works better.
It's incompatible with older program versions and params btw sorry... But works in the same way-[/quote]
Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #4 on: July 28, 2016, 12:41:35 PM »

Yes I read this info about the transformation.
It basically performs a sphere inversion of the point <x,y,z> in a sphere at <center> with radius 'Recipro radius'.

As you say, this should be done only once.
If it is done with the point beind marched on the ray, followed by an iteration of some fractal formula, then this gets us a distance estimate, not from the point on the ray, but from the transformed point.
So I still do not see how the 'sphere inversed' fractal object is obtained.

Anyway, thanks for your answer...
Logged
hobold
Fractal Bachius
*
Posts: 573


« Reply #5 on: July 29, 2016, 09:50:02 AM »

If it is done with the point beind marched on the ray, followed by an iteration of some fractal formula, then this gets us a distance estimate, not from the point on the ray, but from the transformed point.
So I still do not see how the 'sphere inversed' fractal object is obtained.
Forget the fractal and the distance estimate for a moment. Just consider the current ray - a straight line in world coordinates. Now imagine all points on that ray transformed. The transformed ray is a circular arc in world coordinates (let's ignore how exactly that arc is parameterized).

Now things get a little more difficult to visualize. Consider that there is not only a single ray, but a whole bundle of rays, one per pixel. Originally the straight rays all start from the camera position and intersect the image plane, where they cover a rectangular area (our window to the world, so to speak). If all those rays are transformed, they all turn to circular arcs, but they still start from the (transformed) camera position. So now we have a bundle of curved rays in world coordinates.

Finally, remember the fractal shape that we disregarded at first. It is still untransformed and looks like it ever did in world coordinates. But the curved rays intersect it in very different positions than straight rays intersected it before the transformation. So we get a very different image now.

Effectively, we are seeing the fractal shape as if it were inversely transformed, as if straight rays were hitting a fractal that was inverted with respect to some sphere.
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #6 on: July 29, 2016, 11:04:53 AM »

Thanks Hobold, I  can visualise your description.


 I was thinking of sphere inversion as a transform used in making a fractal, like this:

      double r1 = z.x * z.x + (z.y - shift) * (z.y - shift) + z.z * z.z;
      // inversions by length^2
      z.x = z.x / r1;
      z.y = (z.y - shift) / r1;
      z.z = z.z / r1;

I think it is time for me to learn a lot more about this grin

BTW I have still to get back to learning more about the  Riemann type fractals. So much harder to visualise than simple offsets,  scaling and rotations.
Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #7 on: July 29, 2016, 11:50:11 AM »

@hobold
Yes I see what you mean. The point P on the ray becomes the point P' on the little circle that is the ray, transformed by the sphere inversion.
So the calculated DE is now the distance to the fractal object from P'.
But does this not play havoc with the DE values? Do these need to be corrected somehow?


* Knipsel.JPG (35.3 KB, 787x677 - viewed 174 times.)
Logged
hobold
Fractal Bachius
*
Posts: 573


« Reply #8 on: July 29, 2016, 04:00:04 PM »

But does this not play havoc with the DE values? Do these need to be corrected somehow?
I skipped mentioning that part earlier. This depends on how the circular arc of a transformed ray is parameterized. Along the original straight ray, imagine a point moving along at constant speed V. When that ray is transformed into a circular arc, then in most cases, and along most of the arc, the transformed moving point will move at a speed slower than the original V. (That is because an infinitely long ray is mapped to a circle of finite circumference.)

Thus the distance estimates calculated from the original fractal formula are safe most of the time. When you move the current point forward along the ray, the transformation will cause the point to advance more slowly on the arc than it would on a straight ray. So bending the shape by bending the rays is somewhat inefficient, but most of the time the resulting imagery will still be correct.
Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #9 on: August 03, 2016, 01:32:39 PM »

I made a stupid mistake when I tried to implement the sphere inversion in my Ultrafractal code for 3D fractal objects, and could not get it to work, hence all my questions.
(thanks for all the replies)
I now located the error, as you can see in the image:


* KaleidoIFS_005ctest.jpg (185.74 KB, 800x600 - viewed 172 times.)
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #10 on: August 03, 2016, 02:05:23 PM »

Thanks Jos for this post, it made me go looking  for an Unconditional Sphere Inversion in Mandelbulber and could not find one shocked

Here is my current version , (but i have not got the conditional modes in the middle working).  My last two images  posted in gallery were testing this cool transform.

Code:
/**
 * spherical invert
 * from M3D
 */
void TransformSphereInvIteration(CVector3 &z, const cFractal *fractal, sExtendedAux &aux)
{
  double r2 = z.Dot(z);

  z += fractal->mandelbox.offset;
  z *=fractal->transformCommon.scale; // beta
  aux.DE = aux.DE * fabs(fractal->transformCommon.scale) + 1.0;// beta

  double mode = r2;

  /*if (fractal->transformCommon.functionEnabledFalse)// Mode 1
  {
    if (r2 > fractal->mandelbox.mR2) mode = 1.0f;
    if (r2 < fractal->mandelbox.fR2 && r2 > fractal->mandelbox.mR2)
      mode = fractal->mandelbox.mR2;
    if (r2 < fractal->mandelbox.fR2 && r2 < fractal->mandelbox.mR2)
      mode = fractal->mandelbox.mR2;
  }
  if (fractal->transformCommon.functionEnabledxFalse)//Mode 2
  {
    if (r2 > fractal->mandelbox.mR2) mode = 1.0f;
    if (r2 < fractal->mandelbox.fR2 && r2 > fractal->mandelbox.mR2)
      mode = fractal->mandelbox.mR2;
    if (r2 < fractal->mandelbox.fR2 && r2 < fractal->mandelbox.mR2)
      mode =  2.0 * fractal->mandelbox.mR2 - r2;*/
  }
  mode = 1 / mode;
  z *=  mode;
  aux.DE *= mode;

  z -= fractal->mandelbox.offset + fractal->transformCommon.additionConstant000;
}
Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #11 on: August 03, 2016, 02:23:51 PM »

@mclarekin: not sure I understand your code.
A sphere inversion of a point <x,y,z> in a sphere of radius R, centered at P :

d=(x-P.x)^2+(y-P.y)^2+(z*P.z)^2
x'=P.x+R^2*(x-P.x)/d
y'=P.y+R^2*(y-P.y)/d
z'=P.z+R^2*(z-P.z)/d
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #12 on: August 03, 2016, 02:55:54 PM »

Yeah, the Mandelbulber stuff looks confusing. It is Darkbeams M3D version

calculate  dot(z,z)
Translate
scale by radius
do inversion (two mode options)
translate back

except I replaced "scale by radius", with a parameter called scale
commented out the mode options, because i must have lost the logic
and added a vect3parameters to the translate back,

This additional parameters provide more possibilities when used as a pre-transform

So
d=(x-P.x)^2+(y-P.y)^2+(z*P.z)^2
x'=P.x+R^2*(x-P.x)/d
y'=P.y+R^2*(y-P.y)/d
z'=P.z+R^2*(z-P.z)/d

would be something like this using P

d = P.x^2 + P.y^2 + P.z^2
P  = P + offset vect3 // (default 0,0,0))
P = P * scale // (default = 1)
DE = DE * abs(scale) + 1.0;
P= P / d;
P = P - offset vect3  + offsetAdjust vect3; //default 0,0,0
DE =DE / d
« Last Edit: August 03, 2016, 03:51:24 PM by mclarekin, Reason: fix careless mistake » Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #13 on: August 04, 2016, 06:30:40 AM »

Jos, it keeps getting better grin, this time I tried using three unconditional inversions


* sphereInv qas2 94.jpg (200.16 KB, 800x800 - viewed 208 times.)
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Sphere Inversion Fractals 3D Fractal Generation fractalrebel 5 6586 Last post November 21, 2009, 06:13:16 AM
by fractalrebel
examples from mobius and/or sphere inversion Mandelbulb3D Gallery ericr 0 2597 Last post April 21, 2012, 12:21:03 PM
by ericr
Inversion Ellipse Fold Transformation (new) Theories & Research thomas314 8 728 Last post May 08, 2012, 04:14:09 PM
by element90
Transformation of a sphere to make 3D julia? Possible to do? The 3D Mandelbulb KRAFTWERK 5 13222 Last post April 11, 2015, 02:54:22 AM
by 1990winfractal
Sphere inversion experiment Images Showcase (Rate My Fractal) JosLeys 0 3905 Last post August 27, 2016, 09:42:18 AM
by JosLeys

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.16 seconds with 27 queries. (Pretty URLs adds 0.008s, 2q)