POV-Ray : Newsgroups : povray.general : moving things around Server Time
18 Apr 2024 17:33:22 EDT (-0400)
  moving things around (Message 1 to 7 of 7)  
From: Richard S
Subject: moving things around
Date: 24 May 2017 05:55:01
Message: <web.59255789c3ecc112d9835a10@news.povray.org>
Hi All

First I want to move the variable mover form 50 to 0 in between clock values of
0 and 5.
Then as the clock values increase from 5 to 10 I want mover to go from 0 to 50.
Then as the clock values increase from 10 to 15 I want mover to go from 50 to
100.
Then as the clock values increase from 15 to 20 I want mover to go from 100 to
50.

I have found the section
3.2.1.2 Internal Animation Loop

 For new scenes, we recommend you do not change the Initial_Clock or Final_Clock
from their default 0.0 to 1.0 values. If you want the clock to vary over a
different range than the default 0.0 to 1.0, we recommend you handle this inside
your scene file as follows...
#declare Start    = 25.0;
#declare End      = 75.0;
#declare My_Clock = Start+(End-Start)*clock;
Then use My_Clock in the scene description. This keeps the critical values 25.0
and 75.0 in your .pov file.
I rename most of these so as not to interfere with pov internal values.



//----start code segment----
#switch(MyClock)
  #range(0,5)//centre to full left
    #local MinClock= 0;
    #local MaxClock= 5;
    #local MinMove = 50;
    #local MaxMove = 0;
  #break
  #range(5,10)//full left to center
    #local MinClock= 5;
    #local MaxClock= 10;
    #local MinMove = 0;
    #local MaxMove = 50;
  #break
  #range(10,15)//center to right
    #local MinClock= 10;
    #local MaxClock= 15;
    #local MinMove = 50;
    #local MaxMove = 100;
  #break
  #range(15,20)//right to center
    #local MinClock= 15;
    #local MaxClock= 20;
    #local MinMove = 100;
    #local MaxMove = 50;
  #break
  #else
    #error concat("MyClock=",str(MyClock,0,0),".\n")
#end

#local Mover=
(MinMove+(MaxMove-MinMove))*(MyClock/(MinClock+(MinClock-MaxClock)));;
//----end code segment----

I would like to leave the switch statement alone as this is the controlling
element and will allow for further development later. I trying to develop a
single equation to calc the output.

Any help would be appreciated and great fully received. Thank you.


Post a reply to this message

From: Bald Eagle
Subject: Re: moving things around
Date: 24 May 2017 07:55:00
Message: <web.592573c852c7950dc437ac910@news.povray.org>
"Richard S" <nomail@nomail> wrote:

> Any help would be appreciated and great fully received. Thank you.

AT the moment, I won't be able to work this out - what you have is a bit ...
busy.

I would diagram it out, with a standard clock value from 0-1.

As you have it, I see you are having MyClock go from 0 to 75, not 0 to 100,
since 25 + (75-25)*1 = 25 + 50 = 75.

I'd split the segments of the clock range of 0-1 into sub-clocks of 0-1 with a
switch-range-break block with ranges of 0-0.1, 0.1-0.2, etc.

then work out an equation for that segment to control your movement.

Once you get it WORKING, then you can "simplify" it and make the code shorter,
but, counterintuitively, the "long" way is often the quickest way.


Post a reply to this message

From: Bald Eagle
Subject: Re: moving things around
Date: 24 May 2017 13:05:00
Message: <web.5925bc4c52c7950dc437ac910@news.povray.org>
Just to get you started, I made a graph of what I think you want.
I believe I mistook your quote of the docs for what you were actually doing.

See if this gets you started / on the right track:


**************************************************************************

#version 3.7;
global_settings { assumed_gamma 1.0}


#include "colors.inc"
#include "math.inc"


camera {
 location <200, 50, -400>
 up y
 right x*image_width/image_height
 look_at <200, 50, 0>
}

// Create an infinite sphere around scene and allow any pigment on it
sky_sphere{ pigment { gradient <0,1,0>
                      color_map { [0.00 rgb <0.6,0.7,1.0>]
                                  [0.25 rgb <0.0,0.1,0.8>/2]
                                  [0.75 rgb <0.0,0.1,0.8>/2]
                                  [1.00 rgb <0.6,0.7,1.0>]
                                }
                      scale 2
                    } // end of pigment
          } //end of skysphere -------------------------------------


light_source { <0, 150, -150>, 1 }

//#declare Start    = 25.0;
//#declare End      = 75.0;
//#declare My_Clock = Start+(End-Start)*clock;

//#declare My_Clock = clock*20;

#declare Line = 1;

#for (X, 0, 400, 100)
cylinder {<X, 0, 0>, <  X, 100, 0> Line pigment {Green}}
#end

#for (Y, 0, 100, 50)
cylinder {<0, Y, 0>, <400,   Y, 0> Line pigment {Red}}
#end

#for (Clock, 0, 20, 0.25)
 #declare My_Clock = Clock*20;

 //----start code segment----
 #switch(Clock)
   #range(0,5)//centre to full left
    #declare Height = 50-(Clock*10);
    sphere {<My_Clock, Height, 0> Line pigment {Black}}
     #local MinClock= 0;
     #local MaxClock= 5;
     #local MinMove = 50;
     #local MaxMove = 0;
   #break
   #range(5,10)//full left to center
   #declare Height = ((Clock-5)*10);
    sphere {<My_Clock, Height, 0> Line pigment {Black}}
     #local MinClock= 5;
     #local MaxClock= 10;
     #local MinMove = 0;
     #local MaxMove = 50;
   #break
   #range(10,15)//center to right
   #declare Height = ((Clock-5)*10);
   sphere {<My_Clock, Height, 0> Line pigment {Black}}
     #local MinClock= 10;
     #local MaxClock= 15;
     #local MinMove = 50;
     #local MaxMove = 100;
   #break
   #range(15,20)//right to center
   #declare Height = 100-((Clock-15)*10);
   sphere {<My_Clock, Height, 0> Line pigment {Black}}
     #local MinClock= 15;
     #local MaxClock= 20;
     #local MinMove = 100;
     #local MaxMove = 50;
   #break
   #else
     //#error concat("MyClock=",str(My_Clock,0,0),".\n")
 #end

#end

#local Mover=
(MinMove+(MaxMove-MinMove))*(My_Clock/(MinClock+(MinClock-MaxClock)));;
//----end code segment----


Post a reply to this message

From: Bald Eagle
Subject: Re: moving things around
Date: 24 May 2017 13:35:03
Message: <web.5925c40f52c7950dc437ac910@news.povray.org>
For a non-linear plot in a single equation, use

y=abs ( cos ( ((x-5)/20)*4*pi))

Then you can convert the cos wave to a triangular form by adding harmonics of
the cos, like they do in a Fourier synthesis.

(add 1/3*(cos(3*N)) + 1/7*(cos(7*N)) + 9, 11, 13, 15.....)

https://en.wikipedia.org/wiki/Triangle_wave


Post a reply to this message

From: dick balaska
Subject: Re: moving things around
Date: 24 May 2017 15:16:19
Message: <5925dc03$1@news.povray.org>
Am 2017-05-24 05:51, also sprach Richard S:
> Hi All
>   I’m trying to move an object between 0 and 100 in different ways.
> First I want to move the variable mover form 50 to 0 in between clock values of
> 0 and 5.
> Then as the clock values increase from 5 to 10 I want mover to go from 0 to 50.
> Then as the clock values increase from 10 to 15 I want mover to go from 50 to
> 100.
> Then as the clock values increase from 15 to 20 I want mover to go from 100 to
> 50.
> 
> I have found the section
> 3.2.1.2 Internal Animation Loop
> And the bit…
>   For new scenes, we recommend you do not change the Initial_Clock or Final_Clock
> from their default 0.0 to 1.0 values. If you want the clock to vary over a
> different range than the default 0.0 to 1.0, we recommend you handle this inside
> your scene file as follows...
> #declare Start    = 25.0;
> #declare End      = 75.0;
> #declare My_Clock = Start+(End-Start)*clock;
> Then use My_Clock in the scene description. This keeps the critical values 25.0
> and 75.0 in your .pov file.
> I rename most of these so as not to interfere with pov internal values.
> 
> Here is what I have so far…
> 
> //----start code segment----
> #switch(MyClock)
>    #range(0,5)//centre to full left
>      #local MinClock= 0;
>      #local MaxClock= 5;
>      #local MinMove = 50;
>      #local MaxMove = 0;
>    #break
>    #range(5,10)//full left to center
>      #local MinClock= 5;
>      #local MaxClock= 10;
>      #local MinMove = 0;
>      #local MaxMove = 50;
>    #break
>    #range(10,15)//center to right
>      #local MinClock= 10;
>      #local MaxClock= 15;
>      #local MinMove = 50;
>      #local MaxMove = 100;
>    #break
>    #range(15,20)//right to center
>      #local MinClock= 15;
>      #local MaxClock= 20;
>      #local MinMove = 100;
>      #local MaxMove = 50;
>    #break
>    #else
>      #error concat("MyClock=",str(MyClock,0,0),".\n")
> #end
> 
> #local Mover=
> (MinMove+(MaxMove-MinMove))*(MyClock/(MinClock+(MinClock-MaxClock)));;
> //----end code segment----
> 
#local Mover=
((MyClock-MinClock)/(MaxClock-MinClock)) * (MaxMove-MinMove) + MinMove;

clock becomes 0-1, times range, plus minimum.

-- 
dik


Post a reply to this message

From: Bald Eagle
Subject: Re: moving things around
Date: 24 May 2017 15:50:00
Message: <web.5925e2ce52c7950dc437ac910@news.povray.org>
Interestingly, I was looking up mathematical symbols, and for linear algebra,
the 1-norm of the unit circle is a square (I'd call it a diamond)

But if you took the 1-norm of that cos function....

https://en.wikipedia.org/wiki/Norm_(mathematics)

(Sorry - the Wikipedia definition is a bit obtuse and no real helpful examples
that I can see.)


Post a reply to this message

From: Richard S
Subject: Re: moving things around
Date: 30 May 2017 01:15:00
Message: <web.592cff3652c7950d5b33a3c00@news.povray.org>
Thank you all for your contributions, whilst a solution was not found the
discussion did lead me to look elsewhere in the help file and come up with this
idea which now works just fine.
What I have done is to modify the clock var, which I will have to return back to
my standard later, for the negative movement I have to make a negative going


3.2.1.2 Internal Animation Loop
and
2.3.9.2 Clock Dependant Variables And Multi-Stage Animations
When I do an animation I normally use a 25FPS rate and the clock runs at 1
integer per second whereas here I have had to modify the clock used as the
control to 0 to 1 for the duration of the movement. The clock will have to be
modified to account for this but I think this should be easy to do later on.

//==================Start code======================
#switch(MyClock)
  #range(0,1)//centre to full left
    #debug concat("First Bit = 50 to 0.\n")
    #local MinClock= 0;
    #local MaxClock= 1;
    #local MyClock=MyClock-0;
    #local MinMove = 50;
    #local MaxMove = 0;
  #break
  #range(1,2)//full left to center
    #debug concat("Second Bit = 0 to 50.\n")
    #local MinClock= 1;
    #local MaxClock= 2;
    #local MyClock=MyClock-1;
    #local MinMove = 0;
    #local MaxMove = 50;
  #break
  #range(2,3)//center to right// doe werk
    #debug concat("Third Bit = 50 to 100.\n")
    #local MinClock= 2;
    #local MaxClock= 3;
    #local MyClock=MyClock-2;
    #local MinMove = 50;
    #local MaxMove = 100;
  #break
  #range(3,4)//right to center// doe werk
    #debug concat("Fourth Bit = 100 to 50.\n")
    #local MinClock= 3;
    #local MaxClock= 4;
    #local MyClock=MyClock-3;
    #local MinMove = 100;
    #local MaxMove = 50;
  #break
  #else
    #error concat("MyClock=",str(MyClock,0,0),".\n")
#end

#if(MaxMove<MinMove)
  #local NewClock=1-MyClock;
#else
  #local NewClock=MyClock;
#end

#local
Ans=(min(MaxMove,MinMove)+(NewClock*(max(MaxMove,MinMove)-min(MaxMove,MinMove))));
//==================End code======================


Thank you all for your contributions, whether they were just plain wrong or not,
as the thinking behind them can often lead me and other to look in a different
direction, one I had not previously thought of.

hideous crime. With a natural sentence of wasting time and effort until I see
the light.

Thank you all for your help, and posting my intellectual bail.

Thank you all again.


Post a reply to this message

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