Logo by S Nelson - 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. April 18, 2024, 11:40:48 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: Mandelbox DE formula  (Read 6346 times)
Description: I'm having troubles with it
0 Members and 1 Guest are viewing this topic.
khyperia
Guest
« on: March 30, 2012, 09:19:05 PM »

This formula, a modified one from http://blog.hvidtfeldts.net/index.php/2011/11/distance-estimated-3d-fractals-vi-the-mandelbox/, isn't working. Well, for scales above 1, it is, but for negative scales it isn't. Personally, I think negative scale mandelboxes are better, so I really want to get this working. I've basically narrowed the problem down to this core forumla. (Language is C#, 100% my own program (excluding the copy-pasta'd formulae), example render http://khyperia.tumblr.com/post/20060287683/moar-renders)
Code:
public static float DistanceEstimator(Vector3 z)
        {
            Vector3 c = z;
            float dr = 1.0f;
            for (int n = 0; n < Settings.maxIterations; n++)
            {
                if (z.X > 1)
                    z.X = 2 - z.X;
                else if (z.X < -1)
                    z.X = -2 - z.X;
                if (z.Y > 1)
                    z.Y = 2 - z.Y;
                else if (z.Y < -1)
                    z.Y = -2 - z.Y;
                if (z.Z > 1)
                    z.Z = 2 - z.Z;
                else if (z.Z < -1)
                    z.Z = -2 - z.Z;

                float r2 = z.LengthSquared();

                if (r2 < 1)
                {
                    if (r2 < 0.25f) // 0.5 squared
                    {
                        z *= 4;
                        dr *= 4;
                    }
                    else
                    {
                        z /= r2;
                        dr /= r2;
                    }
                }

                z = Settings.scale * z + c;
                dr = dr * Settings.scale + 1.0f;
            }
            return z.Length() / Math.Abs(dr);
        }

Can anyone spot an error that would screw negative scales up?
Logged
bib
Global Moderator
Fractal Senior
******
Posts: 2070


At the borders...


100008697663777 @bib993
WWW
« Reply #1 on: March 30, 2012, 09:51:01 PM »

the copy-pasta'd formulae

That must be Darkbeam's formula for sure cheesy (the spaghetti coder)
Logged

Between order and disorder reigns a delicious moment. (Paul Valéry)
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #2 on: March 31, 2012, 01:09:02 AM »

Hi,

For negative values, you'd need the abs(scale) for the running derivative:
Code:
dr = dr * Math.abs(Settings.scale) + 1.0f;
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #3 on: March 31, 2012, 10:09:23 AM »

That must be Darkbeam's formula for sure cheesy (the spaghetti coder)
Oh well, somebody tries to imitate me ... Curse him! :evil:
Logged

No sweat, guardian of wisdom!
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #4 on: April 01, 2012, 02:41:04 PM »

That must be Darkbeam's formula for sure cheesy (the spaghetti coder)

Darkbeam's code....spaghetti huh?

You have seen my UF code ? cheesy
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #5 on: April 04, 2012, 01:48:32 PM »

It is well done! Mine is the worst possible trust me! dancing banana dancing chilli dancing banana
Logged

No sweat, guardian of wisdom!
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
A Mandelbox distance estimate formula 3D Fractal Generation « 1 2 3 » JosLeys 32 82357 Last post September 07, 2011, 02:38:02 PM
by knighty
Understanding the Mandelbox formula (for 2D) Programming jwm-art 6 8714 Last post November 23, 2010, 05:48:17 AM
by Tglad
Beginner's problems with the Mandelbox formula Programming smooo 5 6582 Last post February 08, 2011, 04:43:13 PM
by smooo
The tetrahedral Mandelbox, formula and some parameters (new) Theories & Research DarkBeam 5 1381 Last post April 17, 2013, 02:33:14 PM
by Alef
Is there a formula for M3d simular to mandelbulber's mandelbox vary scale 4d? Mandelbulb 3d wolfwing1 3 4843 Last post August 03, 2011, 09:36:34 AM
by taurus

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.122 seconds with 24 queries. (Pretty URLs adds 0.006s, 2q)