Descriptions and Examples for the POV-Ray Raytracer by Friedrich A. Lohmüller
logo
    3D Animations with POV-Ray
        Some basics and examples on animations.
Italiano Italiano
Français français
Deutsch Deutsch
Home
- 3D Animations Gallery
- POV-Ray Tutorial

  3D Animation Tutorial
   Index of Content
  0. Basic Knowledge
     1. Basic Example
     2. Example 2
     3. Images to Animated Gif
     4. From Images to Video
     5. Basic Terms
     6. Animation Commands  
  I. Cyclic Animations
     1. Rotating Objects
     1.2. Planets in Orbit
     1.3. Clock Animation
     2. Rotating Camera
     2.1. Straight Moving Camera
     3. Western Wheel
         Problem
     3.1. Rolling Wheels
     4. Gears
     4.1. Roller Chain
     4.2. Bike Chain
     5. Swinging Pendulum
  > 5.1: Newton's Cradle
     5.2: Rock the Rocker
     6. Spiral Pendulum
     7. Coupling Rods
     7.1. Connecting Rods
     8. Psychedelic + Op-Art
     9. Counters + Countdowns
    10. Folding of a Cube
  II. Non-linear Movements
     1.0 Speed Up/Slow Down 1
     1.1 Speed Up/Slow Down 2
     2. Fall + Bounce
     3. Acceleration by
          physical Formulas
     4. Speed Controll by
          Spline Functions
  III. Animation Paths
      with Spline Curves
     1. Spline Curves
     2. Closed Splines
     3. Animation Paths
                                                       
   

Newton's Cradle

Oscillations in sine rythm.

Newton's Pendulum
The Framework
For the rounded tube corners we can use the marco "Segment_of_Torus(...)" from my include file "shapes3.inc".
The frame parts are here designed as a macro:
//------------------
#ifndef ( Shapes_Lo_Inc_Temp )
#include "shapes_lo.inc"
#end

Newtons_Cradle_Frame
The framework of a Newton's Cradle
//---------------------------------------------------------------
#macro Newtons_Cradle_Frame ( R_min, // minor radius
                              R_maj, // major radius
                              Frame_H, // height in y
                              Frame_W, // width in x
                              Frame_L //  length in z
                            ) //-------------------------
#if (R_maj <= R_min) #local R_maj= R_min+D; #end
//-----------------------------------------------------
#local F_H = Frame_H -2*R_min ; // inner height in y
#local F_W = (Frame_W -2*R_min)/2 ; // inner width in x
#local F_L = (Frame_L -2*R_min)/2 ; // inner length in z


#local F_Quart = // -----------------------------
object{ Segment_of_Torus( R_maj,R_min, 90) } //
// ----------------------------------------------
union{
// tubes in x
 cylinder{<-(F_W-R_maj),0,0>,<(F_W-R_maj),0,0>,R_min translate<0,0,-F_L>}
 cylinder{<-(F_W-R_maj),0,0>,<(F_W-R_maj),0,0>,R_min translate<0,0, F_L>}
// tubes in z
 cylinder{<0,0,-(F_L-R_maj)>,<0,0,(F_L-R_maj)>,R_min translate< F_W,F_H,0>}
 cylinder{<0,0,-(F_L-R_maj)>,<0,0,(F_L-R_maj)>,R_min translate<-F_W,F_H,0>}
// tubes vertical
 cylinder{<0,R_maj,0>,<0,F_H-R_maj,0>,R_min translate< F_W,0, F_L>}
 cylinder{<0,R_maj,0>,<0,F_H-R_maj,0>,R_min translate< F_W,0,-F_L>}
 cylinder{<0,R_maj,0>,<0,F_H-R_maj,0>,R_min translate<-F_W,0, F_L>}
 cylinder{<0,R_maj,0>,<0,F_H-R_maj,0>,R_min translate<-F_W,0,-F_L>}

// round tube corners:
// low
 object{ F_Quart rotate<-90, 0, 0> translate< F_W-R_maj,R_maj,-F_L>}
 object{ F_Quart rotate<-90, 0, 0> translate< F_W-R_maj,R_maj, F_L>}
 object{ F_Quart rotate<-90,180,0> translate<-F_W+R_maj,R_maj,-F_L>}
 object{ F_Quart rotate<-90,180,0> translate<-F_W+R_maj,R_maj, F_L>}
// high
 object{ F_Quart rotate< 90, 90,0> translate< F_W,F_H-1*R_maj,-F_L+R_maj>}
 object{ F_Quart rotate< 90,-90,0> translate< F_W,F_H-1*R_maj, F_L-R_maj>}
 object{ F_Quart rotate< 90, 90,0> translate<-F_W,F_H-1*R_maj,-F_L+R_maj>}
 object{ F_Quart rotate< 90,-90,0> translate<-F_W,F_H-1*R_maj, F_L-R_maj>}
translate<0,R_min,0>
} // end of union ---------------------------------------------------------
#end // ------------------------------------------------------ end of macro


A Single Swinging Pendulum:
The penduli are declared also as objects by a macro:
// -------------------------------------
#macro Newtons_Cradle_Ball( Ball_R, // radius sphere
                            Wire_R, // radius wire
                            Ball_H, // depth sphere
                            Frame_X // Frame_width
                          ) //-------------------------
union{
 sphere{<0,0,0>, Ball_R translate<0,-Ball_H-Ball_R,0>}
 cylinder{<-Frame_X/2,0,0>,<-Ball_R/5,-Ball_H,0>,Wire_R}
 cylinder{< Frame_X/2,0,0>,< Ball_R/5,-Ball_H,0>,Wire_R}
 sphere{<0,0,0>,Ball_R/5 translate<0,-Ball_H,0>}
} // end of union --------------------------------
#end // ----------------------------- end of macro

Newton's Cradle Ball
A single ball pendulum
of a Newton's Cradle

Frame and penduli swinging in sine rythm:
// ----------- dimensions:
#declare Frame_R_min  = 0.03;
#declare Frame_R_maj  = 0.15;
#declare Frame_Height = 1.40;
#declare Frame_Width  = 1.20;
#declare Frame_Length = 1.90;

#declare Ball_R = 0.15;
#declare Ball_H = 1.00;
#declare Wire_R = 0.015;

Newton's Cradle Animation
Animation Newton's Cradle
Scene description for POV-Ray:
"Newtons_Cradle_3.ini" and
"Newtons_Cradle_3.pov"
//------------------------------ Animations Settings:
// clock 0~1 set by animation ini file!
#declare Time = 0.00+clock;
#declare Amp = 50; //  Amplitude

#declare Ball_1_Rotate = Amp*sin(2*pi*Time)* (Time<=0.5) ;
#declare Ball_2_Rotate = Amp*sin(2*pi*Time)* (Time<=0.5) ;
#declare Ball_3_Rotate = Amp*sin(2*pi*Time)*1;// (Time>0.5) ;
#declare Ball_4_Rotate = Amp*sin(2*pi*Time)* (Time>0.5) ;
#declare Ball_5_Rotate = Amp*sin(2*pi*Time)* (Time>0.5) ;


//------------------------------------------------------------
#declare Ball = // ----------------------- single ball element
 object{ Newtons_Cradle_Ball( Ball_R, // Ball_R,
                              Wire_R, // Filament_R,
                              Ball_H, // Ball_H,
                              Frame_Width-2*Frame_R_min //in x
                            ) //-------------------------
         texture{ Polished_Chrome }
       }  // end of object -----------------------------------
//------------------------------------------------------------
// all together: ---------------------------------------------
union{
 object{Newtons_Cradle_Frame ( Frame_R_min,  // R_minor,
                               Frame_R_maj,  // R_major,
                               Frame_Height, // height in y
                               Frame_Width,  //  width in x
                               Frame_Length  // length in z
                             ) //------------------------------
         texture{ Polished_Chrome }
       }  // end of object -----------------------------------
 union{// all balls together and upward
  object{ Ball rotate<Ball_1_Rotate,0,0> translate<0,0,-4*Ball_R>}
  object{ Ball rotate<Ball_2_Rotate,0,0> translate<0,0,-2*Ball_R>}
  object{ Ball rotate<Ball_3_Rotate,0,0> translate<0,0, 0*Ball_R>}
  object{ Ball rotate<Ball_4_Rotate,0,0> translate<0,0, 2*Ball_R>}
  object{ Ball rotate<Ball_5_Rotate,0,0> translate<0,0, 4*Ball_R>}
 translate<0,Frame_Height-Frame_R_min,0> } // end balls
 //---------------------------------------------------------
} // ----------------------------- end of union
In this animation are 3 balls in motion.
It's your turn to find out how to bring 1, 2 or 4 balls in game! Have fun!
 
Bigger animations of a Newton's Cradle
you'll find in my Gallery of 3D Animations - Oszillations
.

top

© Friedrich A. Lohmüller, 2013
www.f-lohmueller.de