JosLeys
|
|
« 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
|
|
« Reply #1 on: July 27, 2016, 01:16:24 AM » |
|
Jos, I have been waiting for someone more knowledgeable to answer this 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?? , but I am not an expert (yet)
|
|
|
Logged
|
|
|
|
JosLeys
|
|
« 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
|
|
« 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. [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 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
|
|
« 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
|
|
« 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 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
|
|
« 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?
|
|
|
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
|
|
« 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:
|
|
|
Logged
|
|
|
|
mclarekin
|
|
« 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 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. /** * 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
|
|
« 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
|
|
« 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
|
|
« Reply #13 on: August 04, 2016, 06:30:40 AM » |
|
Jos, it keeps getting better , this time I tried using three unconditional inversions
|
|
|
Logged
|
|
|
|
|