Logo by Cyclops - 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, 02:06:27 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: Mirror  (Read 1836 times)
Description: Using a mirror for altering the Mandelbrot set iterations
0 Members and 2 Guests are viewing this topic.
Aexion
Conqueror
*******
Posts: 116


The Fractal Hermit


WWW
« on: March 04, 2015, 02:14:07 PM »

Hello,

Here is a very simple idea that perhaps gives interesting results for many fractals, in both 2D and 3D.
On the Mandelbrot Set, suppose that you consider every iteration as a photon path that goes from the previous iteration to the next.
Now suppose that you put a mirror between two consecutive iterations. The mirror will make a reflection and the value will end in another place.
This simple approach changes the iteration values and the overall shape of the fractal.
For those who are using the abs based fractals (The Burning ship and the others), the abs function actually acts like a mirror, reflecting the orbit.
But it's centered on the origin, its infinite and can only be oriented in right angles. Other angles, positions and sizes can create interesting patterns.

My approach is very simple:
Since a 2D mirror is just a line, I define the starting and ending points of this line segment
Also, every iteration is considered a line segment that start from the previous iteration value.
The program tests if both line segments intersects,
If there's an intersection point, the new iteration value is calculated from the reflection angle and the length of the iteration line segment from the intersection point.
This procedure is repeated until the bailout count is reached. This changes the iteration position but no the length, since it only a reflection

The program is very simple (int C) because I only want to show the theory. It saves the resulting image in a ppm format that you can read in any graphics program.
On it you can set the mirror position and the angle, then it will calculate a Mandelbrot set using the above procedure.
Some of the abs based Mandelbrots can be seen if you set the mirror in a right angle.

Now the question is, how it looks if you add more than one mirror (Mandelbrot optics?) or if you move it into 3D.
I tried other mirror types (circles) and refractions but without much luck, but any idea is as always welcomed.

Later I will post an animation of rotating mirrors, but I suppose that someone can build a shader on where you can interactively add mirrors and positions them (perhaps.. no idea)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define PI 3.14159265358979

bool intersection(
 double mp0_x, double mp0_y, double mp1_x, double mp1_y,//mirror segment
 double ip0_x, double ip0_y, double ip1_x, double ip1_y, //iteration segment
 double *i_x, double *i_y //intersection point
 )
{
const double s1_x = mp1_x - mp0_x;    
const double s1_y = mp1_y - mp0_y;
const double s2_x = ip1_x - ip0_x;    
const double s2_y = ip1_y - ip0_y;
const double denom= (-s2_x * s1_y + s1_x * s2_y);
const double s = (-s1_y * (mp0_x - ip0_x) + s1_x * (mp0_y - ip0_y)) / denom;
const double t = ( s2_x * (mp0_y - ip0_y) - s2_y * (mp0_x - ip0_x)) / denom;
if (s >= 0 && s < 1 && t >= 0 && t < 1)
{
//intersection        
*i_x = mp0_x + (t * s1_x);
*i_y = mp0_y + (t * s1_y);
return true;
}
return false; // no intersection
}


//Intructions:
//Put the mirror in any point of the mandelbrot set and set the angle and the diameter.
//It will reflect the iteration values if the iteration line segment intersects the mirror.
//When the calculation is complete,the program will save the result in a graphics file
//called "Mirror.ppm"
int main(int argc, char* argv[])
{
//Simple PPM file output, use your favorite graphics program for visualizing it.
FILE *outputfile;
printf("Mirror in the Mandebrot Set\n");
printf("Intructions:\n");
printf("Position the mirror in any point of the Mandelbrot set and set both the\n");
printf("rotation angle and the mirror length. It will reflect the current iteration\n");
printf("value if the line segment between two consecutive iterations intersects\n");
printf("the mirror.\n");
printf("When the calculation is complete,the program will save the result in a\n");
printf("graphics file called \"Mirror.ppm\"\n");

outputfile=fopen("Mirror.ppm","wb");

//Very simple ppm file header
fprintf(outputfile,"P6 1024 1024 255 ");
printf("Calculating..\n");
unsigned char color;

//Mirror Parameters

double mposx=-1.0; //Mirror Position X
double mposy=0.0; //Mirror Position Y
double mangle=90; //Mirror Angle in degrees
double mlength=50000; //length of the mirror, use very large values for an infinite reflecting line

double x,y;
double mx[2],my[2]; //starting and ending segments of the mirror
double tx[2],ty[2]; //starting and ending points of the iteration
double ipointx,ipointy; //intersection point

//mirror normal
double nx,ny;

//iteration normal
double anglex;
double angley;

mangle*=(PI/180.0);//convert from degrees to radians
mlength*=0.5;//calculate the mirror radius
const float rightangle=(PI/180.0)*90;
//calculate the mirror starting and ending point
mx[0]=mposx+sin(mangle+rightangle)*mlength;
my[0]=mposy+cos(mangle+rightangle)*mlength;
mx[1]=mposx+sin(mangle-rightangle)*mlength;
my[1]=mposy+cos(mangle-rightangle)*mlength;

//mirror normal
nx=sin(mangle);
ny=cos(mangle);

int Counter;
for(int jc=0;jc<1024;jc++)
for(int ic=0;ic<1024;ic++)
{
const double ik=(float(ic-512)/512.0)*2-0.75;
const double jk=(float(jc-512)/512.0)*2;
x=0;
y=0;

//iteration loop
for(Counter=0;Counter<100;Counter++){
//get the first iteration segment
tx[0]=x;
ty[0]=y;
//calculate the mandelbrot set
const float xp=x*x-y*y+ik;
const float yp=2*x*y+jk;
//get the second iteration segment
tx[1]=xp;
ty[1]=yp;

//check if the resulting iteration segment intersects the mirror and stores the result if it intersect
if(intersection(mx[0],my[0],mx[1],my[1],tx[0],ty[0],tx[1],ty[1],&ipointx,&ipointy)){

//calculate the distance between the intersection point and the mandelbrot iteration
const double ndistance=sqrt((ipointx-tx[1])*(ipointx-tx[1])+(ipointy-ty[1])*(ipointy-ty[1]));

//calculates the dot product between the intersection point and the the first iteration segment
anglex=ipointx-tx[0];
angley=ipointy-ty[0];
const double langle=1.0/sqrt(anglex*anglex+angley*angley);
anglex*=langle;
angley*=langle;
const double dot = anglex*nx+angley*ny;

//calculates the actual reflected point
const double resx=anglex-2*nx*dot;
const double resy=angley-2*ny*dot;

//use the resulting angle and the distance between the intersection point and the last iteration value to
//calculate the reflected iteration point
x=ipointx+resx*ndistance;
y=ipointy+resy*ndistance;


} else {
//if there's no intersection, the iteration continues with the mandelbrot values
x=xp;
y=yp;
}
if(sqrt(x*x+y*y)>10)break;
}
//use the iteration count as a grayscale gradient
if(Counter<100) color=(unsigned char)Counter; else color=0;
//write to the output file
fputc (color,outputfile);
fputc (color,outputfile);
fputc (color,outputfile);

}
fclose(outputfile);
printf("Calculation finished..\n\n");
return 0;
}



Hope you like it.

Aexion

ps. Try it in other fractals.. smiley
pps. Here's an animation of a rotating mirror centered at (-1,0i):


* Mirror.jpg (56.89 KB, 512x512 - viewed 180 times.)
« Last Edit: March 04, 2015, 03:21:38 PM by Aexion » Logged

Fractals all the way..
Incendia for 3D Fractals
Aural for Musical Fractals
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #1 on: March 04, 2015, 08:19:33 PM »

that is cool, a nice method to deform an object, as far as i can see it fits perfectly to a hybrid constellation (to be used with any formula)

@darkbeam you think you can do a formula that is just performing this transformation, in 3d with a plane obv wink
Logged

---

divide and conquer - iterate and rule - chaos is No random!
youhn
Fractal Molossus
**
Posts: 696


Shapes only exists in our heads.


« Reply #2 on: March 04, 2015, 09:19:58 PM »

Oh yeah, that moving one is very cool !!  the wave the wave

Have to read theory again to comprehend, and watch the animated stuff again.

If you use a line in 2D defined by 2 points, would a plane defined by 3 point give similar results in 3D ...? I think placing mirrors is already done for the KIFS fractals (probably both in Mandelbulber and MB3D). I love that animation by the way.

I tried to compile on Linux, but got this error:

Code:
% gcc -o mirrorbrot mirrorbrot.c
mirrorbrot.c:7:1: error: unknown type name 'bool'
mirrorbrot.c: In function 'intersection':
mirrorbrot.c:25:10: error: 'true' undeclared (first use in this function)
mirrorbrot.c:25:10: note: each undeclared identifier is reported only once for each function it appears in
mirrorbrot.c:27:9: error: 'false' undeclared (first use in this function)
mirrorbrot.c: In function 'main':
mirrorbrot.c:89:2: error: 'for' loop initial declarations are only allowed in C99 mode
mirrorbrot.c:89:2: note: use option -std=c99 or -std=gnu99 to compile your code
mirrorbrot.c:90:3: error: 'for' loop initial declarations are only allowed in C99 mode
mirrorbrot.c:92:27: error: expected ')' before 'ic'
mirrorbrot.c:92:34: error: expected ')' before '/' token
mirrorbrot.c:93:27: error: expected ')' before 'jc'
mirrorbrot.c:93:34: error: expected ')' before '/' token

I've tried to force C99 mode:

Code:
% gcc -std=c99 -o mirrorbrot mirrorbrot.c
mirrorbrot.c:7:1: error: unknown type name 'bool'
mirrorbrot.c: In function 'intersection':
mirrorbrot.c:25:10: error: 'true' undeclared (first use in this function)
mirrorbrot.c:25:10: note: each undeclared identifier is reported only once for each function it appears in
mirrorbrot.c:27:9: error: 'false' undeclared (first use in this function)
mirrorbrot.c: In function 'main':
mirrorbrot.c:92:27: error: expected ')' before 'ic'
mirrorbrot.c:92:34: error: expected ')' before '/' token
mirrorbrot.c:93:27: error: expected ')' before 'jc'
mirrorbrot.c:93:34: error: expected ')' before '/' token

I would like to explore the relation between the mandelbrot/burningship/buffalo fractals. Of course with reference to the work of Stardust4ever:

http://stardust4ever.deviantart.com/art/Mandelbrot-ABS-Variations-Complete-Set-of-Formulas-487039852
http://stardust4ever.deviantart.com/art/Cubic-Mandelbrot-ABS-Variations-Incomplete-487039945
« Last Edit: March 04, 2015, 09:22:00 PM by youhn, Reason: keep getting those fucking tags wrong about every time. And then forums trying to fix and makes an even bigger fucking mesh. Oh, did I mention the preview is not working for me anymore ... ?! » Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #3 on: March 04, 2015, 09:24:45 PM »

question: the tricorn pops out when placing the mirror line on a standard mandelbrot iteration? nice!
Logged

---

divide and conquer - iterate and rule - chaos is No random!
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #4 on: March 04, 2015, 09:28:36 PM »

that is cool, a nice method to deform an object, as far as i can see it fits perfectly to a hybrid constellation (to be used with any formula)

@darkbeam you think you can do a formula that is just performing this transformation, in 3d with a plane obv wink

Lol smiley this has a strong rensemblance to my rotatedabs
But will investigate later shocked
Logged

No sweat, guardian of wisdom!
quaz0r
Fractal Molossus
**
Posts: 652



« Reply #5 on: March 05, 2015, 08:07:42 AM »

Quote from: youhn
I tried to compile on Linux, but got this error

fixed the code to compile with gcc.  dont forget to add -lm.

* mirror.c.txt (5.66 KB - downloaded 99 times.)
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #6 on: March 05, 2015, 09:09:55 AM »

Maybe next there will be warping the fractal with reflection from a parabolic mirror, more parameters to tweek. Two or more mirrors can reflect infinitely and a parabolic mirror can be focused on infinity, so mirror stuff is fractal related grin,
Logged
Aexion
Conqueror
*******
Posts: 116


The Fractal Hermit


WWW
« Reply #7 on: March 05, 2015, 11:38:20 AM »

question: the tricorn pops out when placing the mirror line on a standard mandelbrot iteration? nice!
Yes, in fact, other abs fractal types are combination of the tricorn (one of them is visible at the starting and ending segment of the animation)..
When you zoom you get alternation of triconr's and mandelbrot minibrots.
Why? no idea.. 

If you use a line in 2D defined by 2 points, would a plane defined by 3 point give similar results in 3D ...? I think placing mirrors is already done for the KIFS fractals (probably both in Mandelbulber and MB3D). I love that animation by the way.
Thanks!
The Abs fractals just take care of the positive section, but by placing a mirror, you're doing something different, mostly because not restricted to a right angle ( abs(x) or abs(y) ) or its combination, but to an arbitrary position an angle, considering the fact that you can also use an smaller mirrors, multiple mirrors, non linear mirrors and many other optical phenomena (refraction, caustics and so on.. perhaps.. ).
In 3D the plane equation can be used, but it also can be defined by any surface, such an square, a triangle, a disk..


Maybe next there will be warping the fractal with reflection from a parabolic mirror, more parameters to tweek. Two or more mirrors can reflect infinitely and a parabolic mirror can be focused on infinity, so mirror stuff is fractal related grin,

Yes, it is.. a good example is the Wada Basin Fractal:
http://paulbourke.net/fractals/wada/

Logged

Fractals all the way..
Incendia for 3D Fractals
Aural for Musical Fractals
youhn
Fractal Molossus
**
Posts: 696


Shapes only exists in our heads.


« Reply #8 on: March 05, 2015, 07:00:05 PM »

Thanks for the code quaz0r, it does compile now!

And Aexion for explaining subtle diffs between abs, mirrors and others. I would expect smaller mirrors (segment instead of line, surface instead of plane?) to produce very messy results. I would stay away from those. Placing mirrors towards eachother, with just slllightly changing the flatness or angle could be nice. And computational hard?
Logged
knighty
Fractal Iambus
***
Posts: 819


« Reply #9 on: March 05, 2015, 07:28:16 PM »

Cool finding. Even cooler, there are no discontinuities.
Logged
xenodreambuie
Conqueror
*******
Posts: 124



WWW
« Reply #10 on: March 13, 2015, 11:37:34 PM »

This is interesting. It seems the offset mirror has the effect of multiplying by an extra z2 for the secondary brots.

There is another crucial difference from the abs versions. Here the mirror is applied after adding c (or Mandelbrot coordinates), while abs is applied within the functions. This seems to work fine for the Mandelbrots using DE, but not for Julia sets. I've tried the standard derivative, and the derivative including the +c and mirror. I also tried Julia with the mirror applied before adding c. The Julias always seem to be schizophrenic about the mirror, or totally absent on the far side of it. If anyone finds a nice way to use a mirror in a Julia with DE, I'd like to see it.
Logged

Regards, Garth
http://xenodream.com
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Fractured Mirror and Fractured Mirror II Images Showcase (Rate My Fractal) Pauldelbrot 0 1321 Last post February 14, 2009, 12:43:32 AM
by Pauldelbrot
mirror me! Mandelbulber Gallery taurus 0 1037 Last post June 07, 2011, 11:12:04 AM
by taurus
background with mirror ball large Mandelbulb3D Gallery gene.steeves90 0 727 Last post March 01, 2016, 01:15:39 AM
by gene.steeves90
'mirror cube' Fractals Applied or in Nature Chillheimer 4 1239 Last post June 08, 2016, 10:40:08 PM
by Max Sinister
Pip World, mirror test Exotic Projection / Rendering of Fractals gurroa 0 1616 Last post May 12, 2017, 10:35:23 PM
by gurroa

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