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: Support us via Flattr FLATTR Link
 
*
Welcome, Guest. Please login or register. May 22, 2022, 08:59:47 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 3   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: Iterative Sinus-Curve and the extension of line-curves  (Read 4298 times)
0 Members and 1 Guest are viewing this topic.
SamTiba
Safarist
******
Posts: 83


« on: March 19, 2017, 08:56:32 PM »

Think of the koch-curve, the levi c curve, the dragon curve and many others, they all start with one segment - a simple line - and iterative extend itself to a stunning fractal. They are also known as the first examples of fractals. The self-similarity and the simple definition made them popular.

The base definition of every of these curves consists of two information:
Each point of our second step - when we apply the transformation for one time - has an amplitude and a phase.
After that we have several segments where we are able to repeat our transformation, you can describe this as an addition of the modified amplitude under an angle.

Is there a possible extension to curves?
I want to find out with you together and made the first step:

Think of the Sinus-fractal.
For each point of one period we have an amplitude and the angle defined by the tangent (cosine). For the seperation I chose to half the segments every time (because the sine passes zero there).
Now for the next step we add two smaller sines to the normal sine under the specific angle of that point.

For the first three steps it looks like this:


You can already see interesting parts, after 100 iterations with 40000 points it will look like this:


Zoom in on the point near [Pi,0]:


I am sorry for the bad quality, I just came up with this idea and found the results stunning and wanted to share it with you. I will share more information and images when I get them. Feel free to build it by yourself and enhance the features. I would also like to hear what you think of it (maybe it already exists ..).


* sine-fractal_step123.jpg (20.26 KB, 603x344 - viewed 381 times.)

* sinus-fractal.jpg (26.4 KB, 619x363 - viewed 422 times.)

* sinus-fractal_zoom_on_pi.jpg (90.09 KB, 738x393 - viewed 423 times.)
« Last Edit: March 22, 2017, 10:52:32 PM by SamTiba, Reason: error in db » Logged

Some of my images: Pinterest
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #1 on: March 19, 2017, 08:59:22 PM »

 A Beer Cup lovely idea
Logged

No sweat, guardian of wisdom!
SamTiba
Safarist
******
Posts: 83


« Reply #2 on: March 19, 2017, 09:04:01 PM »

As a whole it is kinda ugly, but I guess it gets interesting when you zoom in.
I always thought of the sine as the definition of smoothness because of it's connection to the circle, never thought the outcome would be such a strange thing.
Logged

Some of my images: Pinterest
SamTiba
Safarist
******
Posts: 83


« Reply #3 on: March 19, 2017, 09:42:11 PM »

This method seems to work out pretty good, here are two more examples.
I have the underlying function and the next two steps visualized in the final curve.
First one is cosine - 1 (to start end and at zero) and the second one is x^3 - x in [-1,1].


* Cosine-Fractal_step123njpg.jpg (109.61 KB, 1067x558 - viewed 405 times.)

* Parabol-Fractal1jpg.jpg (100.01 KB, 1166x728 - viewed 422 times.)
Logged

Some of my images: Pinterest
kram1032
Fractal Senior
******
Posts: 1863


« Reply #4 on: March 19, 2017, 11:16:03 PM »

How exactly are you generating these? I just tried something evidently else, giving different results: Basically, assuming I did it right, displacing the original function by (potentially rescaled) copies of itself shifted along its normal. The results are quite wild depending on how you choose to rescale your function at each step.
The only problem I have is that it requires me to take derivatives of more and more complex expressions which eventually (much sooner than I'd hope for) takes a prohibitively long time to do, because I need to normalize the normal at each step, giving me a more and more nested square root at each step. Perhaps some high quality numeric differentiation could help with that...

This is in sage math (so essentially python plus symbolic calculation stuff)
Logged
SamTiba
Safarist
******
Posts: 83


« Reply #5 on: March 19, 2017, 11:45:30 PM »

Nah mate, I guess you do not really need to normalize the tangent.
I transform the tangent to an angle and add it via the rotationmatrix multiplied with the value-vector [0,Val] (so its [-sin(phi)*Val,cos(phi)*Val]).
I work with arrays, it may disable high resolution at high scales but works well for the beginning.

If you want to have a closer look I can send you my code and explain it further (written in Matlab but quite easy and understandable).
Logged

Some of my images: Pinterest
SamTiba
Safarist
******
Posts: 83


« Reply #6 on: March 20, 2017, 12:15:11 AM »

with 'it' I meant the next rescaled step.
I rescale with using a modulo on my array-access and a rescale-factor for my amplitude.
(I'm somehow not able to edit comments properly so you get it in a new comment)

Since every periodic function starts and ends at the same point (and mostly at zero aswell) they suit well for this method since we get smooth transitions.
In attachement a Curve made with sin(x) + cos(2*x) - cos(3*x).
It looks quite chaotic but I like the non-symmetry.


* Periodic-Curve_jpg.jpg (106.62 KB, 794x408 - viewed 410 times.)
Logged

Some of my images: Pinterest
kram1032
Fractal Senior
******
Posts: 1863


« Reply #7 on: March 20, 2017, 12:23:07 AM »

Wait, so you are shifting the function tangentially? - As said, I shifted along the normal.
If you convert the tangent of your function to an angle, you kind of already implicitly used a normalization. Plugging the angle back into cosine and sine will give you precisely the same components as if you had just normalized the tangent. I'm not sure but I think a square root is probably faster than an atan2 + cosine + sine.
Logged
SamTiba
Safarist
******
Posts: 83


« Reply #8 on: March 20, 2017, 02:30:27 AM »

I'm more used to using rotation coordinates due to my mechanic courses so it seemed more natural for me that way.
I guess I somehow shifted tangentially but since I swapped my value to the y-part I overall shifted along the normal.

I double-checked my code and it seems like the tan-function is causing trouble, thats why we get all those spirals near to points where the tan-function is not continous.
In fact these false results where more stunning then the real ones.

Never thought computational mistakes can be so interesting.


* sinus-fractal_real_jpg.jpg (88.15 KB, 1251x696 - viewed 375 times.)
Logged

Some of my images: Pinterest
kram1032
Fractal Senior
******
Posts: 1863


« Reply #9 on: March 20, 2017, 08:58:02 AM »

Never thought computational mistakes can be so interesting.
Heh. That's... actually kind of a staple of these fora.
People try out new stuff all the time, then figure out they did something completely wrong somewhere, correct it and BAM the result is (comparatively) dull and boring.
It still looks interesting though. And it's ALSO something different from what I got. So what are you doing now, exactly? Can you give some (pseudo-)code?
Logged
SamTiba
Safarist
******
Posts: 83


« Reply #10 on: March 20, 2017, 11:41:27 AM »

the code is really easy, i give you the interesting part of mine (made in matlab) :

syms x
pos = [x;sin(x)];
tangent = diff(pos,x)/norm(diff(pos,x),2);

% itertaion depth
for in = 2:n
    fac = 2^(in-1);
    pos = pos + [0,-1;1,0]*sin(fac*x)/fac*tangent;
    tangent = tangent + diff([x;sin(fac*x)/fac])/norm(diff([x;sin(fac*x)/fac]),2);
end


The last picture I posted was made using arrays, I just enhanced my symbolic-code and it takes long computing when you get to iteration-depth of 50 or up (compared to arrays) but it looks totally different again (and this time more interesting).
Seems like im still not to the bottom of this.


* sinus-fractal_realreal_jpg.jpg (82.33 KB, 1920x986 - viewed 400 times.)
Logged

Some of my images: Pinterest
SamTiba
Safarist
******
Posts: 83


« Reply #11 on: March 20, 2017, 12:11:14 PM »

I hope this is it. Results are stunning and smooth aswell.
As said before things can get strange when we use more complex periodic functions.
In attachement the curves for cos(x) - 1 and sin(x) + cos(2*x) - cos(3*x)


* Cosine-Fractal_real_jpg.jpg (87.35 KB, 1920x986 - viewed 406 times.)

* Periodic-Curve_real_jpg.jpg (113.92 KB, 1920x986 - viewed 389 times.)
Logged

Some of my images: Pinterest
SamTiba
Safarist
******
Posts: 83


« Reply #12 on: March 20, 2017, 12:40:40 PM »

It works for surfaces aswell and looks great. Only problem is, that every function has to be continous (and best would be differentiable) at the edges elsewhise the surface will look very distorted.
Maybe you can avoid this with shifting the surface on a sphere (riemann sphere would work out good for every function?) so that we need fewer points to be edges.
Attached a quick render I did with the function sin(x)*sin(y).


* Sinxy-Surface_Scaleddown.jpg (230.97 KB, 995x548 - viewed 404 times.)
Logged

Some of my images: Pinterest
kram1032
Fractal Senior
******
Posts: 1863


« Reply #13 on: March 20, 2017, 11:37:38 PM »

Ok I think I now get almost what you do:

Though I think you may have made an error in the normalization of the tangent? You gotta normalize the entire tangent, not just what ever piece you add at each iteration. Your tangent, and therefore your normal, probably tends to be too long (though since it's directed it may also occasionally end up being too short). You keep adding together vectors which have length 1, their sum not necessarily (or even likely) having length off 1 again.
My own really silly error lay with getting the direction of the normal wrong.
I totally need a high quality numeric differentiator though. This symbolic take just won't do. I can't even get five iterations deep in a reasonable time frame, at least not with sagemath and symbolic computations.

Nice surfaces though.
Logged
SamTiba
Safarist
******
Posts: 83


« Reply #14 on: March 21, 2017, 12:01:30 AM »

You were totally right, I forgot that. I get the same curves then you afterwards, but another norming really slows down the computation.

For my surface I created the tangent in x- and y-direction and created the normal with the cross-product and normed it afterwards so I got the shifting right there.
Since you can multiply functions in orthogonal directions to get a 'mixture' of them you can really use this behaviour to create functions for surfaces, since they keep the same value at the boundary.

In attachement a render of sin(x) * (sin(y) + cos(2*y) - cos(3*y)) and I searched for some smooth rendering options in Matlab so I got it more 3D-looking this time.
Note that the left image is a view from the top on the surface itself.


* SinPeriodic-Surface.jpg (200.45 KB, 1920x986 - viewed 399 times.)
Logged

Some of my images: Pinterest
Pages: [1] 2 3   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Greetings my iterative friends Meet & Greet lucidquest 4 1962 Last post May 22, 2009, 07:48:39 AM
by Nahee_Enterprises
Investigation of iterative patterns Images Showcase (Rate My Fractal) Dinkydau 4 923 Last post June 01, 2013, 05:38:05 PM
by Dinkydau
Iterative Patterns Mandelbrot zoom Movies Showcase (Rate My Movie) Dinkydau 1 841 Last post August 13, 2013, 09:41:01 PM
by Kalles Fraktaler
Iterative patterns Images Showcase (Rate My Fractal) Dinkydau 2 867 Last post August 14, 2013, 12:35:03 AM
by Dinkydau
Power 2 Sinus Mandelbulb Gestaltlupe Gallery trafassel 0 665 Last post February 08, 2016, 08:59:13 PM
by trafassel

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