|
Italiano
Deutsch |
Untill now we applied sine function only in x direction. A very charming effect will appear if we use a sine modultion to the y position of each sphere depending from here distance of the center. The distance of a point from the origin in cartesian coordinates is calculated by calculating the square root of sum of the sqare of the X value plus the square of Z value - as Pythagoras found out somewhat before.
#declare Ball = sphere{<0,0,0>,0.25 texture{pigment{color rgb<1,0.65,0.0>} finish {ambient 0.1 diffuse 0.9 phong 1} }// end of texture }// end of sphere #declare Z = -5; // start value Z #declare EndZ = 5; // end value Z #declare Step = 0.5;// step value #while ( Z < EndZ + Step)//-------------- loop start Z #declare X = -5; // start value X #declare EndX = 5; // end value X #while ( X < EndX + Step)//------------ loop start X #declare R = sqrt(X*X + Z*Z); // calculation of the distance from the origin object{ Ball translate < X, sin(2*R), Z> } // modulated depending from R #declare X = X + Step; //next X value #end // --------------------------------- loop end X #declare Z = Z + Step; //next Z value #end // ------------------------------------ loop end Z
Mit
#declare R = sqrt( X * X + Z * Z);
#if (R < 5)
object{Ball translate< X, cos(2*R), Z>}
#end
If you limitate the distance from the y-axis on R < 5
and use cos(A) instead of the sine:
Reducing the radius and increasing the density of the spheres will increase the number of objects to calculate immense - in the following scenery there are about 20000 spheres in game and it needs about 14 MB RAM to caculate it. In addition the y-value of the spheres was modulated antiproportional to the distance R from the central y-axis.
#declare Ball = sphere{<0,0,0>,0.1 texture{pigment{color rgb<1,0.8,0>} finish {ambient 0.45 diffuse 0.55 phong 1}}} #declare E = 8; #declare Z = -E; // start value Z #declare EndZ = E; // end value Z #declare Step = 0.1;// step value #while ( Z < EndZ + Step)//-------------- loop start Z #declare X = -E; // start value X #declare EndX = E; // end value X #while ( X < EndX + Step)//------------ loop start X #declare R = sqrt( X * X + Z * Z); #if (R < E) object{Ball translate< X, 5/(R+1)*cos(2*R), Z>} #end #declare X = X + Step; // next X value #end // --------------------------------- loop end X #declare Z = Z + Step; // next Z value #end // ----------------------------------- loop end Z
loops and sine | About flying carpets |
© Friedrich A. Lohmüller, 2004 email: (legacy email redacted) homepage: |