Hilbert Curve, Koch Snowflake  1-20  21

Next
 From:  bemfarmer
6441.1 
After a lot of study, here is a Hilbert Curve generating script, using recursion.
Two related references:

http://fundza.com/algorithmic/space_filling/hilbert/basics/index.html
http://www.donrelyea.com/hilbert_algorithmic_art_menu.htm

Amazingly, the JavaScript recursion worked. I had to pass the factory as a variable, which I have not seen done before.
It takes about 2 minutes to generate the 8th curve. Did not try 9 or more. May try to transfer some code to .htm file, for speed, to see if it will work.

The Hilbert Curve is used a great deal in various computer and software situations. It is a map from a 1 dimension line, to 2 dimensions.

- Brian

The Koch Snowflake is next. The recursion seems very similar, from a template standpoint.
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
6441.2 
Very funny!

---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.3 In reply to 6441.2 
Looks like a heat sink, with huge surface area. 3D print?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.4 
Here is a draft of a Koch Snowflake fractal. Level 7 takes some time to draw. It is not tested for higher levels.

Note that MoI uses x and y coordinates. The original code used the screen starting from the upper left corner as (0,0), so now the "apex"
of the level 0 triangle is at the bottom. Absolute value is applied to negative levels.

I thought of making a version where the user selects 3d triangle(s). Then a cplane is applied, and the fractal generated.
Also may try moving code to .htm file.

- Brian
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  futagoza (STEFAN)
6441.5 In reply to 6441.3 
deleted

EDITED: 18 Jan 2014 by STEFAN

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
6441.6 
KochSnowflake

Seems very heavy in calculates!

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.7 
cool cube Stephen.

There are so many calculations with the recursion. There is probably a better way with mirrors and rotations?

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  futagoza (STEFAN)
6441.8 In reply to 6441.7 
Hi Brian,

i would think so, but i'm no programmer like you…

Best regards
Stefan

EDITED: 19 Jan 2014 by STEFAN

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.9 
I did some practicing in writing faster scripts, with mixed results.

Hi Michael,
These are perhaps not very important questions, but for whatever value they may have, I'll ask them. :-)

I'm having a problem, or problems, with a new Hilbert Curve script which uses some script in htm file to speed up performance.
I understand that "heavy" script in the htm file "hangs up" MoI, until it completes.

The script works very fast the first time.
The script uses recursion.
Level 8 takes over 3 minutes to work, and Done cleanup takes over 3 minutes to complete, so the level is limited to 7 which takes 3 seconds initially.
A small question is: Why does level 8 work so slow? Limits on: Javascript stack?, memory leak?, history?

The script also (needed?) to use ObjectList, var objList, as a global variable, due to the recursion.

The main question is: Why does the performance of the script deteriorate, especially at level 7, when the still open script has selection changed back and
forth, for example, between polylines and curves?
For Example:
Activate the script. Level 4 shows up instantly, as a polyline. Select level 7, which takes 3 seconds to show up.
Select curve. The curve takes about 15 seconds to show up.
Select polyline. The polyline takes about 60 seconds to show up.

Another question is how to "erase" or "zero out" global objList? Or maybe that is not the problem.

Thank you,

- Brian

Ps: Another way to show points is to separate polyline and run MarkCurveStart.

Edit, deleted faulty script. Will re-do later. :-)

EDITED: 28 Jan 2014 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6441.10 In reply to 6441.9 
Hi Brian, unfortunately it's difficult to answer your question with accuracy without a substantial amount of analysis work done to figure it out.

But it's not that unusual for algorithms with a high complexity level to blow up at a certain stage when the number of calculations becomes very high though.

Do you know what is the overall complexity of the algorithm you're using? http://en.wikipedia.org/wiki/Time_complexity


> Another question is how to "erase" or "zero out" global objList?

You could just create a brand new one and assign it to the global variable, that would then give you a cleared out one.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.11 In reply to 6441.10 
Thank you Michael.

I just realized that switching between Polylines and Curves does not require point recalculation, which will help a lot.
So I will re-do the script again, and move on to other projects. It is unlikely that someone would be switching between levels much.

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.12 
Edit, January 29, 2014. Deleted script due to poor programming. Calculate was done inside a loop, one point at a time,
instead of outside the loop, with all the points in a group...
Not a total waste, it was good for learning.

- Brian

EDITED: 29 Jan 2014 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
6441.13 In reply to 6441.12 
Cool! :)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Max Smirnov (SMIRNOV)
6441.14 In reply to 6441.9 
Hi Brian!

>>The script also (needed?) to use ObjectList, var objList, as a global variable, due to the recursion.
Yes. It will give a noticeable performance boost.

Check this version.

P.S. Ops.. I'm late :)

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.15 In reply to 6441.14 
A quick report on Max's superior version, all times approximate:

Level 8 takes < 2 seconds. Switching curve type < 2 seconds.
Level 9 takes ~ 6 seconds. Switching curve type ~ 6 seconds.
Level 10 takes ~28 seconds. Switching curve type ~ 28 seconds. Done < 1 second.
Level 11, after some length of time, MoI seemed to time out(?), "ejected" the script,(?) or some such, and MoI will function again.

Did not observe a degradation of these times, when doing multiple switching between levels, or between curve type.

These levels have a ridiculously high number of bends.

So using calculate and objectList in the point creation recursion, (one point at a time), seems to be a poor programming practice.
Doing the calculate outside the recursion does so on all the points in one big group.

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.16 
Here is a 3D HilbertCurve script.

It uses Max's fast htm type code.

The recursion is based upon the Thomas Diewald port of processing code. Note that he used array prototype.
http://mrdoob.github.io/three.js/examples/#webgl_lines_colors
The threejs code was removed, and MoI points and polyline/curve factory added.
The basic level 0 pattern of the 3D Hilbert shape consists of 8 points and 7 line segments, around a cube.

This is one of the 3 possible starting patterns. One cube becomes 8 sub_cubes...etc.
The maximum level is set to 4, since level 5 takes several seconds to appear.

- Brian

Fillet of corners, and sweeps are possible.

Dec2,2017, Changed comma at end of line 62 to a semicolon. Now works with MoI4beta_11_28_17.

EDITED: 2 Dec by BEMFARMER

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Tommy (THOMASHELZLE)
6441.17 In reply to 6441.16 
Cool!

I recently created an interesting structure from your 2D Hilbert Script:
http://www.screendream.de
It's a loft between 5 different Levels...

Thank you very much for all those inspiring scripts you create!!!

Cheers,

Tom
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.18 In reply to 6441.17 
Thank you Thomas.
Your Loft is amazing. Looks like an exotic wood burl, statue, Rorschach, etc.
Does your Loft involve any other processing?

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Tommy (THOMASHELZLE)
6441.19 In reply to 6441.18 
;-)

No, it's pretty much a loft from Levels 1 > 2 > 3 > 4 > 5 > 4 > 3 > 2 > 1 with G3 filleted corners to get the round, organic shape.
It took more than an hour for MoI to build the loft and I can only save it if I set the display meshing to 180°, so that enough memory is remaining to save the mesh as obj for Thea Render.

I think we reached the limits for 32 Bit Software :-)

Cheers,

Tom
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6441.20 
Note, the coordinates for the Koch snowflake01 script, are not the corners of an equilateral triangle, so it is not symmetric.
(If the triangle is pointed up, a different pattern occurs.).

Using coordinates of a 3 sided MoI polygon, mirrored to point down, will yield a symmetric snowflake.
For example, (7.5, 2.0096189...) (0, 15) (15,15), where 2.0096189 is 15 minus sqrt(3)*15 / 2.
- Brian


EDITED: 25 Mar 2014 by BEMFARMER


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
Show messages:  1-20  21