POV-Ray : Newsgroups : povray.newusers : Smooth circular rotation using spline Server Time
28 Mar 2024 13:42:12 EDT (-0400)
  Smooth circular rotation using spline (Message 1 to 7 of 7)  
From: SecondCup
Subject: Smooth circular rotation using spline
Date: 24 Oct 2016 21:00:05
Message: <web.580eac39d7bd2f98f0b3ab370@news.povray.org>
Hi all,

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. See the code below for the camera path. Is
there an easier way to make the path a smooth circle than just to keep adding in
points on the curve? It gets
tricky splitting the rotation time up into the correct proportions as you add in
more points.

Any suggestions are welcome!

#declare CameraSpline =
    spline {
       smooth_spline

         0.1, <0, 4000,-5000>
        0.15, <2000,4000,-4500>
        0.2, <4500,4000,-2000>
        0.25, <5000, 4000, 0>
        0.275, <4500, 4000, 2000>
        0.3, <2000, 4000, 4500>
        0.325 <0, 4000, 5000>
        0.35, <-2000, 4000, 4500>
        0.38, <-4500, 4000, 2000>
        0.41, <-5000, 4000, 0>
        0.42, <-4500, 4000, -2000>
        0.47, <-2000, 4000, -4500>
        0.50, <0, 4000, -5000>
        0.53, <2000, 4000, -4500>
        0.56, <4500, 4000, -2000>
        0.57, <5000, 4000, 0>
        0.59, <4500, 4000, 2000>
        0.61, <2000, 4000, 4500>
        0.64, <0, 4000, 5000>
        0.66, <-2000, 4000, 4500>
        0.74, <-4500, 4000, 2000>
        0.81, <-5000, 4000, 0>
        0.87, <-4500, 4000, -2000>
        0.91, <-2000, 4000, -4500>
        0.95, <0, 4000, -5000>
        1, <2000, 4000, -4500>
        1.1, <4500, 4000, -2000>

       }


#declare ctr = 0;
#while (ctr < 1)
  sphere {
   CameraSpline(ctr),150
    pigment { rgb <1-ctr,ctr,0> }
  }
  #declare ctr = ctr + 0.001;
#end


Post a reply to this message

From: clipka
Subject: Re: Smooth circular rotation using spline
Date: 24 Oct 2016 21:25:13
Message: <580eb479$1@news.povray.org>
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.


Post a reply to this message

From: SecondCup
Subject: Re: Smooth circular rotation using spline
Date: 24 Oct 2016 22:35:01
Message: <web.580ec41d34f9ab4bf0b3ab370@news.povray.org>
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


Post a reply to this message

From: omniverse
Subject: Re: Smooth circular rotation using spline
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

From: Alain
Subject: Re: Smooth circular rotation using spline
Date: 25 Oct 2016 11:56:21
Message: <580f80a5$1@news.povray.org>

> Hi all,
>
> 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. See the code below for the camera path. Is
> there an easier way to make the path a smooth circle than just to keep adding in
> points on the curve? It gets
> tricky splitting the rotation time up into the correct proportions as you add in
> more points.
>
> Any suggestions are welcome!
>

Don't use a spline.
As your camera is orbiting around the origin, you can simply place it at 
the start position and rotate it using rotate y*Angle.
Now, the only trick is to controll the speed of the camera. For that, 
it's possible to use a spline where you set the angular location 
according to your time frame.
It's also possible to use some function for that task, like sin(Time)+1
The +1 is there to keep the camera moving forward, otherwise, it will 
ossilate.

Sample camera:
camera{
  location <0, 4000,-5000>
  look_at <0, 2000, 0>
  rotate y*(clock*360 + sin(clock))
}


Post a reply to this message

From: Bald Eagle
Subject: Re: Smooth circular rotation using spline
Date: 25 Oct 2016 12:25:01
Message: <web.580f868134f9ab4bb488d9aa0@news.povray.org>
"SecondCup" <nomail@nomail> wrote:

"I want the camera to be slow in some parts sections of the
rotation while fast in other parts."

I suppose the thing to do is to define / explain / show the parts of the
rotation where you want that to occur, and how fast or slow you want it to go,
and if you want smooth or abrupt transitions.

Maybe a comment or two about WHY you want to slow down / speed up the camera to
highlight or skip over some feature(s) would be helpful in assisting define a
better camera path for you.

I commented out your cube and added the following to show the properties of your
current path in a more linear manner.

// graph out in a straight line
#declare ctr = 0;
#while (ctr < 1)
  sphere {
   <(ctr*10000)-5000, CameraSpline(ctr).y*1000, 0> // 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


Post a reply to this message

From: SecondCup
Subject: Re: Smooth circular rotation using spline
Date: 25 Oct 2016 15:15:01
Message: <web.580fade434f9ab4bbe6b2e390@news.povray.org>
I suppose the thing to do is to define / explain / show the parts of the
> rotation where you want that to occur, and how fast or slow you want it to go,
> and if you want smooth or abrupt transitions.
Maybe a comment or two about WHY you want to slow down / speed up the camera to
> highlight or skip over some feature(s) would be helpful in assisting define a
> better camera path for you.

I'm creating an underground video of an orebody where I dip underground swing
around and look at the details of the orebody. Some parts of it are more
detailed/important than others so I would like the camera to slow down when
these important parts come into view.


Post a reply to this message

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