POV-Ray : Newsgroups : povray.general : clock negative value ? Server Time
24 Dec 2024 08:56:43 EST (-0500)
  clock negative value ? (Message 1 to 3 of 3)  
From: rodv92
Subject: clock negative value ?
Date: 9 Oct 2014 15:30:01
Message: <web.5436e1b3439ec9575d50475e0@news.povray.org>
Hello group, have you ever tried to use clock negative values ?

I have seriously miscalculated a motion equation based on clock and the easiest
solution would involve setting clock negative value to have the motion describe
a deceleration motion if clock is negative in the form :

z = -(1/2)*(clock)^2 + zpos1*clock + zpos2

and if positive :

z = 1/2*(clock)^2 + zpos1*clock  + zpos2

That vould make the object decelerate, nearly stop for clock = 0 and then
accelerate again without me having to modify rhe rest of the scene which would
be quite a long task.

and it would be quite neat, too.


but is does not seem to work, alas.


Post a reply to this message

From: Le Forgeron
Subject: Re: clock negative value ?
Date: 9 Oct 2014 15:58:06
Message: <5436e8ce$1@news.povray.org>
On 09/10/2014 21:28, rodv92 wrote:
> Hello group, have you ever tried to use clock negative values ?
> 
> I have seriously miscalculated a motion equation based on clock and the easiest
> solution would involve setting clock negative value to have the motion describe
> a deceleration motion if clock is negative in the form :
> 
> z = -(1/2)*(clock)^2 + zpos1*clock + zpos2
> 
> and if positive :
> 
> z = 1/2*(clock)^2 + zpos1*clock  + zpos2
> 
> That vould make the object decelerate, nearly stop for clock = 0 and then
> accelerate again without me having to modify rhe rest of the scene which would
> be quite a long task.
> 
> and it would be quite neat, too.
> 
> 
> but is does not seem to work, alas.

I had no problem with :

povray -Ivor.pov +W640 +H480 +A0.01 +KI-2 +KF5 +KFI0 +KFF10

debug show clock from -2 to 5, in 11 frames.

What was your line like ?
-- 
IQ of crossposters with FU: 100 / (number of groups)
IQ of crossposters without FU: 100 / (1 + number of groups)
IQ of multiposters: 100 / ( (number of groups) * (number of groups))


Post a reply to this message

From: Anthony D  Baye
Subject: Re: clock negative value ?
Date: 17 Oct 2014 19:10:00
Message: <web.54419ff6e2c2c30f1538d4890@news.povray.org>
Le_Forgeron <jgr### [at] freefr> wrote:
> On 09/10/2014 21:28, rodv92 wrote:
> > Hello group, have you ever tried to use clock negative values ?
> >
> > I have seriously miscalculated a motion equation based on clock and the easiest
> > solution would involve setting clock negative value to have the motion describe
> > a deceleration motion if clock is negative in the form :
> >
> > z = -(1/2)*(clock)^2 + zpos1*clock + zpos2
> >
> > and if positive :
> >
> > z = 1/2*(clock)^2 + zpos1*clock  + zpos2
> >
> > That vould make the object decelerate, nearly stop for clock = 0 and then
> > accelerate again without me having to modify rhe rest of the scene which would
> > be quite a long task.
> >
> > and it would be quite neat, too.
> >
> >
> > but is does not seem to work, alas.
>
> I had no problem with :
>
> povray -Ivor.pov +W640 +H480 +A0.01 +KI-2 +KF5 +KFI0 +KFF10
>
> debug show clock from -2 to 5, in 11 frames.
>
> What was your line like ?
> --
> IQ of crossposters with FU: 100 / (number of groups)
> IQ of crossposters without FU: 100 / (1 + number of groups)
> IQ of multiposters: 100 / ( (number of groups) * (number of groups))


of course, you can simply just factor out a -1 and your calculation will be:

z = -(1/2)*(-clock)^2 - zpos1*clock + zpos2

but if it's motion equations you're looking for, you can try my animation
macros.  You can add them together to form complex chains of actions.

the initAnimation macro has to be called first to set up the environment.

regards,
A.D.B.

#include "math.inc"

#debug concat("!! anim.inc version 1.0b !!\n")
/******************************************************************************
* Name: initAnimation                                       Date: 9/14/2010    *
*                                                                              *
* Auth: Anthony D. Baye                                                        *
* Args: Time                                                                   *
* Desc: Takes the animation length as a ordered- triple in the form <h, m, s>. *
*    Re-computes duration in seconds and defines a global constant "_TICK_".   *
*    Also defines a flag for error-checking purposes.                          *
*       Ensures that the clock is running, before initializing animation       *
*    environment.                                                              *
 ******************************************************************************/
#macro initAnimation(Time)
     #if(clock_on)
          #local Seconds = Time.x*3600 + Time.y*60 + Time.z;
          #declare _TICK_ = (final_clock - initial_clock) / Seconds;

          #declare _ANIMATION_TIMER_ = true;
     #else
          #error "Error! clock not running.\n"
     #end
#end

/*************************************************
* Name: eClock                    Date: 9/14/2010 *
*                                                 *
* Auth: Anthony D. Baye                           *
* Args: Time                                      *
* Desc: Receives a time index as a vector         *
*     recomputes the time in seconds and returns  *
*     the corresponding number of ticks.          *
 *************************************************/
#macro eClock(Time)
//     #ifdef(_ANIMATION_TIMER_)
          #local Seconds = (Time.x*3600 + Time.y*60 + Time.z);
//          #debug concat("event_clock = " str(_TICK_*Seconds,0,6) "\n")
          (_TICK_*Seconds)

//     #else
//          #error "Animation timer not defined: Call initAnimation first.\n"
//     #end
#end


/*************************************************
* Name: Timer                     Date: 9/14/2010 *
*                                                 *
* Auth: Anthony D. Baye                           *
* Args: Type, Start, Finish, speed                *
* Desc: Computes an event timer for an effect.    *
*     Can be multiplied by a direction-vector.    *
*                                                 *
*     Type: type of motion; accelerating/steady   *
*     Start: Starting time index for event.       *
*     Finish: Ending time index for event.        *
*     speed: event speed in units per second.     *
*           If type=1 this is Delta-V             *
*           If type=2 this is the acceleration    *
*           If type=3 this is the speed           *
*           If type=4 this is the distance.       *
 *************************************************/
#macro Timer(Type, Start, Finish, Q)
     #ifdef(_ANIMATION_TIMER_)
          #local D = (Finish - Start);
          #local T = (D.x*3600 + D.y*60 + D.z);
          #if((clock > eClock(Start)) & (clock <= eClock(Finish)))
               // While the clock is within the proper range, calculate the
required value.
               #switch(Type)
               #case(1)  // Given Delta-V.
                    ((T*Q/2)*pow((clock-eClock(Start))/eClock(D),2))
                    #break
               #case(2)  // Given Acceleration.
                    (((Q*T*T)/2)*pow((clock-eClock(Start))/eClock(D),2))
                    #break
               #case(3)  // Constant velocity over time.
                    (T*Q*( ( clock - eClock(Start) ) / eClock(D) ) )
                    #break
               #case(4)  // Constant Distance over time.
                    ( Q*( ( clock - eClock(Start) ) / eClock(D) ) )
                    #break
               #end
          #else
               // Once the event is ended, return a value for the LAST frame of
the event.
               // this will prevent the object from snapping back to the origin.
               #if(clock > eClock(Finish))
                    #switch(Type)
                    #case(1)
                         ((Q/2)*T)  // This was the distance travelled while
changing velocities
                         #break
                    #case(2)
                         (0.5*Q*T*T)  // This is the distance travelled while
accelerating
                         #break
                    #case(3)
                         Q*T  // This is the distance travelled at Speed (Q)
                         #break
                    #case(4)
                         Q  // Distance travelled over period (D)
                         #break
                    #end
               #else
                    0
               #end
          #end

/*               #if((Type < 1) & (Type > 4))
                    #error "first parameter must be 1, 2, 3 or 4\n
                         1: accelerating motion based on ending velocity\n
                         2: accelerating motion based on acceleration\n
                         3: steady motion based on velocity\n"
                         4: steady motion based on distance travelled\n"
               #end*/
     #else
          #warning "Animation Timer not initialized.\n"
          #warning "call initAnimation(<H,M,S>) to initialize.\n"
          0
     #end
#end


Post a reply to this message

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