POV-Ray : Newsgroups : povray.text.tutorials : spiral : Re: spiral Server Time
8 Oct 2024 04:15:58 EDT (-0400)
  Re: spiral  
From: sahraoui
Date: 1 Apr 2007 11:55:01
Message: <web.460fd56dcef26043845cedef0@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> Wasn't it sahraoui who wrote:
> >Hi Mike
> >
> >Thanks a lot for the file.
> >Actually i was trying that same loop
> >but got entangled inside and got the code
> >to run forever until I saw your message. thanks again.
> >The parametric stuff did not work for some reason.
> >
> >Now here is the thing. What you sent me make the spiral follow
> >the sinus line indeed but BUT every "circle" of the spiral
> >is NOT perpendicular to the line of the sinus but it
> >is always perpendicular to the horizontal.
> >In other words your code produce a helix who axis is
> >always parallel to the horizontal
> >but what would be perfect is a helix whose axis
> >is parallel to the sinus fonction that follows, andn that I beleive
> >is not a piece of cake...but may be not for you Oh gentleman of Leisure
>
> The basic strategy would be to tilt each "circle" by an amount that
> varied with the cosine. The tricky bit would be to calculate the correct
> value for the amount of tilt ("B" in the following code) from the other
> values.
>
> #declare R1=1.5;
> #declare F1=1.2;
> #declare R2=0.15;
> #declare N=100;
> #declare H=10;
>
> #declare F2=0.2;
> #declare A=0.5;
> #declare B=-0.2;
>
> sphere_sweep {
>   b_spline
>   100,
>   #declare Y=0;
>   #while (Y<N)
>     #declare X=R1*sin(F1*Y)+A*sin(F2*Y);
>     <X, Y*H/N-H/2 + B*X*cos(F2*Y) , R1*cos(F1*Y)>,R2
>     #declare Y=Y+1;
>   #end
>   pigment {rgb 1}
> }
>
> >embedding that into a larger sheet of beads would be quite a challenge too.
>
> In what way?
>


Here what I am trying to do;
What follow are not very optimized. Some parameters
were there but they are superfluous now...




#declare Ball =
 sphere{<0,0,0>,0.15
   texture{
     pigment{color rgb<1,0.65,0.0>}
     finish {diffuse 0.9 phong 1}

    }// end of texture
 // texture component
// defines an object's surface bumpiness

 }// end of sphere



#declare rods =
cylinder{<0,0,0>,<0,2,0>,0.1
//cylinder {
 // -0.01*x,  0.02*x,  1
   open
texture{
    pigment{color rgb<1,0,0>}
   normal { bumps 0.5 scale <0.005,0.25,0.005>}
   finish {diffuse 0.9 phong 1}
    }


}



#declare E = 5;
#declare Z = -E;    // start value Z
#declare EndZ = E;  // end value Z
#declare Step = 0.2;// step value
//------- loop start Z:
#while ( Z < EndZ + Step)

  #declare X = -E; // start value X
  #declare EndX = E; // end value X
  //------ loop start X:
  #while ( X < EndX + Step)

  object{ Ball
  translate<X,0.1*X*sin(2*Z)
              +0.1*Z*cos(2*X),Z>}
object{ rods
translate<X,0.1*X*sin(2*Z)
              +0.1*Z*cos(2*X),Z>}

  #declare X = X+Step;//next X value
  #end // --------------- loop end X

#declare Z = Z+Step;//next Z value
#end // --------------- loop end Z


#declare Ball =
 sphere{<0,2,0>,0.15
   texture{
     pigment{color rgb<1,0.65,0.0>}
     finish {diffuse 0.9 phong 1}
    }// end of texture
 }// end of sphere

#declare E = 5;
#declare Z = -E;    // start value Z
#declare EndZ = E;  // end value Z
#declare Step = 0.2;// step value
//------- loop start Z:
#while ( Z < EndZ + Step)

  #declare X = -E; // start value X
  #declare EndX = E; // end value X
  //------ loop start X:
  #while ( X < EndX + Step)

  object{ Ball
  translate<X,0.1*X*sin(2*Z)
              +0.1*Z*cos(2*X),Z>}

  #declare X = X+Step;//next X value
  #end // --------------- loop end X

#declare Z = Z+Step;//next Z value
#end // --------------- loop end Z


//THis is the water sheet in blue made of cylinders

#declare rods =
cylinder{<0,2.05,0>,<0,2.5,0>,0.11
//cylinder {
 // -0.01*x,  0.02*x,  1
   //open
texture{
    pigment{color rgb<0,0.3,1>}
   normal { bumps 0.5 scale <0.005,0.25,0.005>}
   finish {diffuse 0.9 phong 1}
    }
// texture component
// defines an object's surface bumpiness


}

//this loop will make the water sheet

#declare E = 5;
#declare Z = -E;    // start value Z
#declare EndZ = E;  // end value Z
#declare Step = 0.2;// step value
//------- loop start Z:
#while ( Z < EndZ + Step)

  #declare X = -E; // start value X
  #declare EndX = E; // end value X
  //------ loop start X:
  #while ( X < EndX + Step)

object{ rods
translate<X,0.1*X*sin(2*Z)
              +0.1*Z*cos(2*X),Z>}

  #declare X = X+Step;//next X value
  #end // --------------- loop end X

#declare Z = Z+Step;//next Z value
#end // --------------- loop end Z

//This is the next monolayer

#declare Ball =
 sphere{<0,2.55,0>,0.15
   texture{
     pigment{color rgb<1,0.65,0.0>}
     finish {diffuse 0.9 phong 1}
    }// end of texture
 }// end of sphere

#declare E = 5;
#declare Z = -E;    // start value Z
#declare EndZ = E;  // end value Z
#declare Step = 0.2;// step value
//------- loop start Z:
#while ( Z < EndZ + Step)

  #declare X = -E; // start value X
  #declare EndX = E; // end value X
  //------ loop start X:
  #while ( X < EndX + Step)

  object{ Ball
  translate<X,0.1*X*sin(2*Z)
              +0.1*Z*cos(2*X),Z>}

  #declare X = X+Step;//next X value
  #end // --------------- loop end X

#declare Z = Z+Step;//next Z value
#end // --------------- loop end Z

//this will make the aliphatic layers

#declare rods =
cylinder{<0,2.7,0>,<0,4.7,0>,0.11
//cylinder {
 // -0.01*x,  0.02*x,  1
   //open
texture{
    pigment{color rgb<1,0,0>}
   normal { bumps 0.5 scale <0.005,0.025,0.005>}
   finish {diffuse 0.99 phong 1}
    }
// texture component
// defines an object's surface bumpiness


}



#declare E = 5;
#declare Z = -E;    // start value Z
#declare EndZ = E;  // end value Z
#declare Step = 0.2;// step value
//------- loop start Z:
#while ( Z < EndZ + Step)


  #declare X = -E; // start value X
  #declare EndX = E; // end value X
  //------ loop start X:
  #while ( X < EndX + Step)

object{ rods
translate<X,0.1*X*sin(2*Z)
              +0.1*Z*cos(2*X),Z>}

  #declare X = X+Step;//next X value
  #end // --------------- loop end X

#declare Z = Z+Step;//next Z value
#end // --------------- loop end Z

//This is the next monolayer with links between some spheres

//THis IS THE SPIRALs

//spiral

#declare Amplitude = 0.160 ;
#declare Minimal_Length   = 0.80 ;
#declare Middle_Length    = Amplitude + Minimal_Length ;  //superfluous
parameter



#declare Sp_Length = Middle_Length+Amplitude*sin((clock+Time_test)*2*pi);
#declare Spiral  =  //--------------------------------- the spiral
union{
 #local N_per_Rev = 125;   // Number of Elements per revolutions
 #local N_of_Rev  = 8.00;  // Total number of revolutions

 #local H_per_Ref = Middle_Length / N_of_Rev;
 #local Nr = 0;                          // start loop
 #while (Nr< N_per_Rev*N_of_Rev)
   sphere{ <0,4.8,0>,0.025
           translate<0.05, 0, -Nr*H_per_Ref/N_per_Rev>
           //rotate<0,0,  Nr * 360/N_per_Rev>
          rotate<0,0,Nr*360/N_per_Rev>
           texture{ Chrome_Metal
                    finish {ambient 0.15 diffuse 0.85 phong 1}}
         }
 #local Nr = Nr + 1;    // next Nr
 #end // --------------------------------- end of loop


} // end of union  -------------------------------- end of spiral


//--------------------------------------------------------------------- end





#declare Ball =
 sphere{<0,4.8,0>,0.15
   texture{
     pigment{color rgb<1,0.65,0.0>}
     finish {diffuse 0.9 phong 1}
    }// end of texture
 }// end of sphere

#declare links =
cylinder{<0,4.8,0>,<0.,4.8,0.2>,0.05


texture{
    pigment{color rgb<1,1,0>}
   normal { bumps 0.5 scale <0.005,0.25,0.005>}
   finish {diffuse 0.9 phong 1}
    }
// texture component
// defines an object's surface bumpiness


}


#declare E = 5;
#declare Z = -E;    // start value Z
#declare EndZ = E;  // end value Z
#declare Step = 0.2;// step value
//------- loop start Z:
#while ( Z < EndZ + Step)

  #declare X = -E; // start value X
  #declare EndX = E; // end value X
  //------ loop start X:
  #while ( X < EndX + Step)

  object{ Ball
  translate<X,0.1*X*sin(2*Z)
              +0.1*Z*cos(2*X),Z>}
              object{Spiral
              translate<X,0.1*X*sin(2*Z)
              +0.1*Z*cos(2*X),Z>}

  #declare X = X+Step;//next X value
  #end // --------------- loop end X

#declare Z = Z+Step;//next Z value
#end // --------------- loop end Z

//This is the network of spring
//first we construct a helix


#declare E = 5;
#declare Z = -E;    // start value Z
#declare EndZ = E;  // end value Z
#declare Step = 0.5;// step value

#while ( Z < EndZ + Step)

  #declare X = -E; // start value X
  #declare EndX = E; // end value X

  #while ( X < EndX + Step)



  #declare X = X+Step;//next X value
  #end // --------------- loop end X

#declare Z = Z+Step;//next Z value
#end // --------------- loop end Z


and the last sheet should have random spring attached to the beads.
Meaning that if you span the sheet you find five consecutive spring
connecting
the beads and sometimes you find less or more..like this:

#declare Rnd_1 = seed (1153);

#declare Ball =
  sphere{<0,0,0>,0.25
    texture{
      pigment{color rgb<1,0.8,0>}
      finish {diffuse 0.9 phong 1}
    }// end of texture
  }// end of sphere

//------------------------------------
//----------------
#declare links =
cylinder{<0,0,0>,<0.59,0,0.0>,0.051

texture{
    pigment{color rgb<1,1,0>}
   //normal { bumps 0.5 scale <0.005,0.25,0.005>}
   finish {diffuse 0.19 phong 1}
    }



}

//end of rods

//spiral

#declare Amplitude = 0.160 ;
#declare Minimal_Length   = 0.80 ;
#declare Middle_Length    = Amplitude + Minimal_Length ;




#declare Sp_Length = Middle_Length+Amplitude*sin((clock+Time_test)*2*pi);
#declare Spiral  =  //--------------------------------- the spiral
union{
 #local N_per_Rev = 125;   // Number of Elements per revolutions
 #local N_of_Rev  = 8.00;  // Total number of revolutions

 #local H_per_Ref = Middle_Length / N_of_Rev;
 #local Nr = 0;                          // start loop
 #while (Nr< N_per_Rev*N_of_Rev)
   sphere{ <0,0,0>,0.025
           translate<0.05, 0, -Nr*H_per_Ref/N_per_Rev>//


          rotate<0,0,Nr*360/N_per_Rev>
           texture{ Chrome_Metal
                    finish {ambient 0.15 diffuse 0.85 phong 1}}
         }
 #local Nr = Nr + 1;    // next Nr
 #end // --------------------------------- end of loop


} // end of union  -------------------------------- end of spiral



//--------------------------------------------------------------------- end



#declare X=-5;

#declare EndX = 5;  //   end value X
#declare Step = 0.85;// step value

#while ( X < EndX + Step)//loop start
  object{ Ball translate <X,0,0>}

#declare X = X + Step; // next X
#end // ------------------- loop end
#declare Z = -5;  // start value Z
#declare EndZ = 5;  //   end value Z
#declare Step = 0.85;// step value

#while ( Z < EndZ*2 + Step)

  #declare X = -5;  // start value X
  #declare EndX = 5;//   end value X

  #while ( X < EndX*2 + Step)


   object{ Ball translate <X,0,Z>}

object{Spiral translate<X,0,Z*5*rand(Rnd_1)>}

  #declare X = X + Step;//next X
  #end // ----------- loop end X

#declare Z = Z + Step; //next Z
#end // ------------ loop end Z
> --
> Mike Williams
> Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.