POV-Ray : Newsgroups : povray.animations : center of rotation Server Time
23 Nov 2024 06:29:54 EST (-0500)
  center of rotation (Message 1 to 3 of 3)  
From: bnrj rudra
Subject: center of rotation
Date: 21 Jan 2012 08:45:02
Message: <web.4f1ac14a6363859f9971f8480@news.povray.org>
Dear friends,
I am a complete newbie trying to use povray to show a rotation. My code is :
#version 3.6; // 3.7
global_settings{assumed_gamma 1.0}
#default{ finish{ ambient 0.1 diffuse 0.9 }}
//------------------------------------------
#include "colors.inc"
#include "textures.inc"
//------------------------------------------
// camera ----------------------------------
camera{ location  <0.0 , 1.0 ,-3.0>
        look_at   <0.0 , 1.0 , 0.0>
        right x*image_width/image_height
        angle 75 }
// sun -------------------------------------
light_source{<1500,3000,-2500> color White}
// sky -------------------------------------
plane{ <0,1,0>,1 hollow
       texture{
         pigment{ bozo turbulence 0.92
           color_map{
                 [0.00 rgb<0.05,0.15,0.45>]
                 [0.50 rgb<0.05,0.15,0.45>]
                 [0.70 rgb<1,1,1>        ]
                 [0.85 rgb<0.2,0.2,0.2>  ]
                 [1.00 rgb<0.5,0.5,0.5>  ]
                       } //
           scale<1,1,1.5>*2.5
           translate<0,0,0>
           } // end of pigment
         finish {ambient 1 diffuse 0}
        } // end of texture
       scale 10000}
// fog on the ground -----------------------
fog { fog_type   2
      distance   50
      color      rgb<1,1,1>*0.8
      fog_offset 0.1
      fog_alt    1.5
      turbulence 1.8
    } //

// ground ----------------------------------
plane{ <0,1,0>, 0
       texture{
          pigment{ color rgb<0.22,0.45,0>}
          normal { bumps 0.75 scale 0.015 }
          finish { phong 0.1 }
       } // end of texture
     } // end of plane

//------------------------------------------
// objects in scene ------------------------
sphere{ <-.5,0,0>, 0.5
        texture{
          pigment{ color rgbt<0.9,0.55,0,.8>}
          finish { phong 1  }
        } // end of texture
        translate<0.85,1.1,0>
      } // end of sphere
sphere{ <-1.5,0,0>, 0.5
        texture{
          pigment{ color rgbt<0.9,0.55,0,.5>}
          finish { phong 1 }
        } // end of texture
        translate<0.85,1.1,0>
      } // end of sphere
sphere{ <-2.5,0,0>, 0.5
        texture{
          pigment{ color rgbt<0.9,0.55,0,.8>}
          finish { phong 1 }
        } // end of texture
        translate<0.85,1.1,0>
      } // end of sphere
sphere{ <.5,0,0>, 0.5
        texture{
          pigment{ color rgbt<0.9,0.55,0,.5>}
          finish { phong 1 }
        } // end of texture
        translate<0.85,1.1,0>
      } // end of sphere
#declare Pendula = //-------------------------------------------------------
Pendula

union{ // outer union
cylinder { <0.35,-.50,0>,<0.35,.4,0>,0.04
           texture { pigment { color rgb<0.90,0.05,0.15>}
                    //normal { bumps 0.5 scale <0.005,0.25,0.005>}
                     finish  { phong 0.5}
                   } // end of texture
           scale <1,1,1> rotate<0,0,0> translate<0,-1,0>
         } // end of cylinder
 union{ // inner union   -------------------------------------------------------
  cone { <0.35,0.0,0>,0,<0.35,-0.5,0>,0.105
         texture { pigment{color rgb<0.90,0.05,0.15>}
                   finish { phong 0 }
               } // end of texture
       scale <1,1,1> rotate<0,0,0> translate<0,1.55,0>
     } // end of cone ----------------------------------------------------------
  scale <1,1,1> rotate<0,0,0> translate<0,-2,0>
  }// end of inner union
}  // end of outer union
 //
----------------------------------------------------------------------------------

#declare Amplitude = 40 ;// in degrees  -  in Grad

object { Pendula

         rotate< 0, 0, Amplitude*sin( clock*2*pi) >

         translate<0,2.15,0>
        }
#declare Amplitude = 40 ;// in degrees  -  in Grad

object { Pendula

         rotate< 0, 0, Amplitude*sin( clock*2*pi) >

         translate<1.1,2.15,0>
        }
#declare Amplitude = 40 ;// in degrees  -  in Grad

object { Pendula

         rotate< 0, 0, Amplitude*sin( clock*2*pi) >

         translate<-1.,2.15,0>
        }
#declare Amplitude = 40 ;// in degrees  -  in Grad

object { Pendula

         rotate< 0, 0, Amplitude*sin( clock*2*pi) >

         translate<-2,2.15,0>
        }
//------------------------------------- end

This may not be good code, as I am peeking up pieces from various tutorials.
The problem is the rotation. How I can define the rotation origin? Its behaving
like being fixed at the top point.


Post a reply to this message

From: Stephen
Subject: Re: center of rotation
Date: 21 Jan 2012 09:20:01
Message: <4f1ac991@news.povray.org>
On 21/01/2012 1:44 PM, bnrj.rudra wrote:
>   How I can define the rotation origin? Its behaving
> like being fixed at the top point.

The centre of rotation as always about the origin. So you need to 
translate your object to the origin, rotate it then translate it back.
In the help see:
2.2.7.1.3 Rotate

Or you could use the Rotate_Around_Trans macro
3.7.18 transforms.inc



-- 
Regards
     Stephen


Post a reply to this message

From: Alain
Subject: Re: center of rotation
Date: 21 Jan 2012 17:25:06
Message: <4f1b3b42$1@news.povray.org>

> Dear friends,
> I am a complete newbie trying to use povray to show a rotation. My code is :
...
>
> This may not be good code, as I am peeking up pieces from various tutorials.
> The problem is the rotation. How I can define the rotation origin? Its behaving
> like being fixed at the top point.
>
>

All rotations and scalings are always done relative to the origin, or 
absolute location <0,0,0>.
Any rotated object not situated at the origin will orbit around the 
origin as it rotates.
Any scaled object not at the origin will move as it is scaled.

The best way of doing your rotations, and scalings, is to create the 
object to be rotated with it's point of rotation situated at the origin, 
rotate it THEN translate it to it's final location.




Alain


Post a reply to this message

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