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: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. April 26, 2024, 10:58:20 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: 3D – structures, a short algorithm  (Read 2314 times)
0 Members and 1 Guest are viewing this topic.
Graph
Alien
***
Posts: 22


« on: November 03, 2011, 06:35:14 PM »

To generate 3D-structures I have written a short algorihm. This I would like to discuss. The algorihm uses vectors, which are combined by the dot product (scalar multiplication). Since the scalar product is defined in any dimension, for example, the program also generates structures in 4D - space. The results are attractors of a sort of self-organization.

The sorce file „GraphTest.txt“ generates pixels (x, y). The plot of this points shows the image  „Graph3D.jpg“. The Java-program „Graph4D.jar“ (Graph.zip) creates 4D-structures, which are projected to a 2D picture.



public class Main {

    public static void main(String[] args) {

        /* Example Program Graph
         * Three - Node - Graph  1, 2, 3
         * Two Edges 1 -> 2, 1 -> 3
         * Output: Position (x,y) of Nodes 1,2,3 */


        //********************************************************//
        //  These parameters can be changed:                      //
                     double e = 5.0, s = 1.0;                     //
        //********************************************************//


       
        double radi, dr, x;

        //Initial conditions (x, y, z)
        //Node1
        double x1 = 0.01,  y1 = -0.02, z1 = 0.04;
        //Node2
        double x2 = -0.04, y2 = -0.05, z2 = 0.01;
        //Node3
        double x3 = 0.05,  y3 = -0.04, z3 = -0.01;
        //Edge12
        double rq12, r12, scalar12, dx12 = 1.0, dy12 = -1.0, dz12 = 1.0;
        //Edge13
        double rq13, r13, scalar13, dx13 = -1.0, dy13 = 1.0, dz13 = -1.0;

        double eist = 1.0;
       
        int  N = 150000;  //steps

     //-------------------------------------------------------------------------



     for(int i = 0; i < N; i++) {

     //Edge12-------------------------------------------------------------------
             rq12 = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1);

                r12 = Math.sqrt(rq12);
                scalar12 = dx12*(x2-x1)+dy12*(y2-y1)+dz12*(z2-z1);

                if(scalar12 < 0 && eist > e && r12 > s) {
                    radi = (rq12/(s*s)-1)*(1.0-(scalar12*scalar12)/rq12);
                    if(radi < 0.0)  radi= 0.0;

                    x = -scalar12/r12+Math.sqrt(radi);

               dx12 = dx12-x*(x1-x2)/r12;
                    dy12 = dy12-x*(y1-y2)/r12;
                    dz12 = dz12-x*(z1-z2)/r12;

                    dr = Math.sqrt(dx12*dx12+dy12*dy12+dz12*dz12);

                    dx12 = dx12/dr;
                    dy12 = dy12/dr;
                    dz12 = dz12/dr;
          }

    //Edge13------------------------------------------------------------------
                rq13 = (x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)+(z3-z1)*(z3-z1);

                r13 = Math.sqrt(rq13);
                scalar13 = dx13*(x3-x1)+dy13*(y3-y1)+dz13*(z3-z1);

                if(scalar13 < 0 && eist > e && r13 > s) {
                    radi = (rq13/(s*s)-1)*(1.0-(scalar13*scalar13)/rq13);
                    if(radi < 0.0)  radi = 0.0;

                    x = -scalar13/r13+Math.sqrt(radi);

               dx13 = dx13-x*(x1-x3)/r13;
                    dy13 = dy13-x*(y1-y3)/r13;
                    dz13 = dz13-x*(z1-z3)/r13;

                    dr = Math.sqrt(dx13*dx13+dy13*dy13+dz13*dz13);

                    dx13 = dx13/dr;
                    dy13 = dy13/dr;
                    dz13 = dz13/dr;
          }
       //-----------------------------------------------------------------------

         //Boundary value
          eist = r12+r13;

        //Superposition
          x1 = x1+dx12+dx13;
          y1 = y1+dy12+dy13;
          z1 = z1+dz12+dz13;

          x2 = x2-dx12;
          y2 = y2-dy12;
          z2 = z2-dz12;

          x3 = x3-dx13;
          y3 = y3-dy13;
          z3 = z3-dz13;

        //Position of node1, node2 and node3
          System.out.format("%10f %10f %10f %10f %10f %10f %n", x1, y1, x2, y2, x3, y3);
         
          /* Plot (x1, y1)
           *      (x2, y2)
           *      (x3, y3)
           */
       
        }
    }

}

* Graph.zip (28.48 KB - downloaded 125 times.)
Logged
knighty
Fractal Iambus
***
Posts: 819


« Reply #1 on: November 04, 2011, 06:09:04 PM »

Nice algo. It gives very nice chaotic 3D Lissajous like curves (surfaces?).
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #2 on: November 04, 2011, 11:36:40 PM »

A test render would be appreciated smiley
Logged

No sweat, guardian of wisdom!
Graph
Alien
***
Posts: 22


« Reply #3 on: November 05, 2011, 04:53:05 PM »

Obviously I've made a mistake. Therefore, a new trial with the uploads.

* GraphTest.txt (3.48 KB - downloaded 145 times.)

* Graph3D.jpg (179.19 KB, 500x504 - viewed 271 times.)
* Graph.zip (28.48 KB - downloaded 155 times.)
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
A not so short introduction Meet & Greet kshorting 2 1544 Last post August 05, 2007, 12:41:52 AM
by kshorting
Sand / Structures ... Fractals Applied or in Nature GFWorld 4 2033 Last post January 18, 2009, 07:59:38 PM
by Cyclops
3D-Structures by Self-organization Meet & Greet Graph 13 3279 Last post June 25, 2010, 10:40:43 AM
by kram1032
short little 3d render Movies Showcase (Rate My Movie) marius 0 939 Last post December 22, 2010, 09:12:58 AM
by marius
Underwater Structures Mandelbulb3D Gallery Kali 0 813 Last post March 13, 2011, 03:50:53 PM
by Kali

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