POV-Ray : Newsgroups : povray.newusers : Smooth circular rotation using spline : Re: Smooth circular rotation using spline Server Time
18 Apr 2024 13:49:09 EDT (-0400)
  Re: Smooth circular rotation using spline  
From: omniverse
Date: 25 Oct 2016 06:50:00
Message: <web.580f36ec34f9ab4b9c5d6c810@news.povray.org>
"SecondCup" <nomail@nomail> wrote:
> clipka <ano### [at] anonymousorg> wrote:
> > Am 25.10.2016 um 02:56 schrieb SecondCup:
> >
> > > I'm trying to make my camera rotate around an object in a perfectly smooth
> > > circular manner. The reason I'm having
> > > trouble is that I want the camera to be slow in some parts sections of the
> > > rotation while fast in other parts. I'm no math whizz so I an using the spline
> > > identifiers rather than some complicated trigonometry code. Cubic_spline seems
> > > to work closest (smoothest) to what I want it to do.
> > >
> > > Ive used a total of 12 points per rotation so far and the camera still
> > > appears to 'wobble' in
> > > and out toward the centre object.
> >
> > That's absolutely inevitable if you're using splines, as they cannot
> > exactly represent circular arcs (those types supported by POV-Ray at any
> > rate; you'd need the things called Rational B-Splines).
> >
> > My recommendation would be not to use a 3D spline at all, but use a
> > 1-dimensional spline to map time to angle, and use straightforward
> > trigonometry (or `vrotate`, or even just a `rotate` transformation) to
> > compute a position from the angle.
>
> Thanks Clipka,
>
> I'll have a crack at it. The tricky part will be mapping the angle to the time

Not being a math whizz either I had to give this a try by going with only
rotation. After realizing your spline vectors were making 2 turns around the y
axis I just entered the quarter rotation timings, although I don't know if you
intended the stopped portions, and this was the animatable result:

light_source
{
 -z*9999,
 1
 rotate <10,10,0>
}

#local CaMove=yes; // use with clock or say no to see path itself

// time/motion with y as revolution amount
#declare CameraSpline =
    spline {
       linear_spline//natural_spline
        //0, <0,-0.25,0>
  0.1, <0,0,0>
  0.25, <0,0.25,0>
  0.325, <0,0.5,0>
  0.41, <0,0.75,0>
  0.5, <0,1,0>
  0.57, <0,1.25,0>
  0.64, <0,1.5,0>
  0.81, <0,1.75,0>
  0.95, <0,2,0>
  //1, <0,2.25,0>
    }

#if (CaMove=no)
camera
{
 location <0,5000,-10000>
 look_at <0,0,0>
}

#declare ctr = 0;
#while (ctr < 1)
  sphere {
   -z*5000
   +y*ctr*1000 // only for visualization of 2 revolutions
   , 150
    pigment { rgb <1-ctr,ctr,0> }
    rotate <0,-360*CameraSpline(ctr).y,0> // use y from spline vector
  }
  #declare ctr = ctr + 0.005;
#end

#else
camera
{
 location <0,4000,-5000>
 look_at 0
    rotate <0,-360*CameraSpline(clock).y,0> // use y from spline vector
}
#end

box
{
 -1000,1000
 pigment
 {
  radial
  color_map
  {
   [0 red 1] [1 green 1]
  }
  rotate 45*y
 }
 finish
 {
  emission 0.25
 }
}


Post a reply to this message

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