###### Descriptions and Examples for the POV-Ray Raytracerby Friedrich A. Lohmüller     3D Animations with POV-Ray         Some basics and examples on animations.
Italiano
Français
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.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

# The Folding of a Cube NetHow to animate the folding of geometric objects.

How to fold of a cube?
A cube consists of 6 squares folded against its neighbor square by 90°.
So we start by declaring a 'Square' object.
(First declare the according textures as you like it!)
 ```// -------------------- dimensions #declare D = 0.00001; #declare S = 1; #declare Rl = 0.02;// "edge" radius #declare Rp = 0.04;//"point" radius // ------------------------- square // Quadrat, quadrato, carré #declare Square = union{ // the corners union{ sphere{ <0,0,0>, Rp } sphere{ , Rp } sphere{ , Rp } sphere{ <0,0,S>, Rp } texture{ Corner_Texture } } // the edges union{ cylinder{ <0,0,0>,, Rl } cylinder{ ,, Rl } cylinder{ <0,0,S>,, Rl } cylinder{ <0,0,0>,<0,0,S>, Rl } texture{ Edge_Texture } } // the face box{ <0,-D,0>,<1,D,1> texture{ Face_Texture }} } // end of union ------------------```

###### A square for folding of a CubeA net of a cube

Building a chain of squares:
For folding a cube net (like here above right)
we have to make a chain of the squares A,B,C and D by nested unions.
We need to remember that rotation by 'rotate' always turns around the axes!
So we first have to apply the rotation and then the translation as shown in the image here right with the first two squares A and B.
Note: 'rotation around an axis' and 'translation' commonly are not commutative or not interchangeable, that means: We cannot change the sequence arbitrary!

Here how to animate the folding:
To achieve a smooth starting and ending movement we use the following macro:
 ```#macro Cos_010( X ) //----- (0.5-0.5*cos(2*pi*X)) #end //-------------------- #declare Fold_Angle = -90*Cos_010(clock); //--------------------------------- ```

The assembling of the cube components:
 ```union{ // A + B + C object{ Square } // C ------ union{ // A + B object{ Square } // B ------ object{ Square // A ------ rotate translate<0,0,S> } //-------------- rotate translate<0,0,S> } // end A + B rotate translate<0,0,S> } // end A + B + C object{ Square } // D ------ object{ Square // E ------ translate<-S,0,0> rotate<0,0,Fold_Angle> } //------------------ object{ Square // F ------ rotate<0,0,-Fold_Angle> translate } //------------------ ```

###### Folding a cube Scene descriptions for POV-Ray: "Folding_a_Cube_2.ini" and "Folding_a_Cube_2.pov"
For other examples for folding a regular polyhedron see:
Elementary Geometry for Raytracing or: 3D-Animations - Geometry
top