 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
This involves probably some very easy algebra.
I want a cylinder to spin 360 degrees when the clock is between 0 and
0.6667. I want another object to spin when the clock is between 0.3333
and 0.6667. Finally I want the camera to rotate 90 degrees when the
clock is between 0.6667 and 1.
How do I set this up? Thanks.
Michael
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2/17/2019 5:36 AM, Mike Horvath wrote:
> This involves probably some very easy algebra.
>
> I want a cylinder to spin 360 degrees when the clock is between 0 and
> 0.6667. I want another object to spin when the clock is between 0.3333
> and 0.6667. Finally I want the camera to rotate 90 degrees when the
> clock is between 0.6667 and 1.
>
> How do I set this up? Thanks.
>
>
> Michael
PS - I was thinking of maybe a macro that takes a start time and an end
time, and outputs a value between 0 and 1?
Michael
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> wrote:
> On 2/17/2019 5:36 AM, Mike Horvath wrote:
> > This involves probably some very easy algebra.
> >
> > I want a cylinder to spin 360 degrees when the clock is between 0 and
> > 0.6667. I want another object to spin when the clock is between 0.3333
> > and 0.6667. Finally I want the camera to rotate 90 degrees when the
> > clock is between 0.6667 and 1.
> >
> > How do I set this up? Thanks.
> >
> >
> > Michael
>
>
> PS - I was thinking of maybe a macro that takes a start time and an end
> time, and outputs a value between 0 and 1?
#macro MacroName(StartTime, EndTime)
#local R = (clock - StartTime)/(EndTime - StartTime);
#local S = min(max(0, R), 1);
S
#end // macro MacroName
object {
YourCylinder
rotate MacroName(0/3, 2/3)*360*y
}
object {
YourOtherObject
rotate MacroName(1/3, 2/3)*SomeAngle*y
}
camera {
YourCamera
rotate MacroName(2/3, 3/3)*90*y
}
--
Tor Olav
http://subcube.com
https://github.com/t-o-k/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 19-02-17 à 05:36, Mike Horvath a écrit :
> This involves probably some very easy algebra.
>
> I want a cylinder to spin 360 degrees when the clock is between 0 and
> 0.6667. I want another object to spin when the clock is between 0.3333
> and 0.6667. Finally I want the camera to rotate 90 degrees when the
> clock is between 0.6667 and 1.
>
> How do I set this up? Thanks.
>
>
> Michael
Assuming that the clock goes from 0 to 1 :
To be added to the object of interest.
First case :
#if(clock <= 2/3) rotate x*360*3/2 #end
// *360 for a full rotation
// *3/2 adjust to the desired clock interval
Second case :
#if(clock > 1/3 & clock < 2/3) rotate y*(clock - 1/3)*720*3/2 #end
// *720 two full rotation, just because...
Third case :
#if(clock > 2/3) rotate z*(clock - 2/3)*90*3 #end
That should do it.
Alain
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2/17/2019 7:27 AM, Tor Olav Kristensen wrote:
> #macro MacroName(StartTime, EndTime)
>
> #local R = (clock - StartTime)/(EndTime - StartTime);
> #local S = min(max(0, R), 1);
>
> S
>
> #end // macro MacroName
Thank you! That's perfect.
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> wrote:
> On 2/17/2019 7:27 AM, Tor Olav Kristensen wrote:
> > #macro MacroName(StartTime, EndTime)
> >
> > #local R = (clock - StartTime)/(EndTime - StartTime);
> > #local S = min(max(0, R), 1);
> >
> > S
> >
> > #end // macro MacroName
>
>
> Thank you! That's perfect.
>
>
> Mike
I hesitate to try to improve on a TOK solution, but in my animations, a very
early line will be
#declare MyTime = clock;
then I use MyTime wherever I would use clock. This lets me #declare MyTime =
0.6667, for example to go to a position in the animation to test a particular
stage without running the whole animations. You would pass MyTime to the #macro.
This may be obvious, but it is an improvement.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2/18/2019 12:38 PM, JimT wrote:
> Mike Horvath <mik### [at] gmail com> wrote:
>> On 2/17/2019 7:27 AM, Tor Olav Kristensen wrote:
>>> #macro MacroName(StartTime, EndTime)
>>>
>>> #local R = (clock - StartTime)/(EndTime - StartTime);
>>> #local S = min(max(0, R), 1);
>>>
>>> S
>>>
>>> #end // macro MacroName
>>
>>
>> Thank you! That's perfect.
>>
>>
>> Mike
>
> I hesitate to try to improve on a TOK solution, but in my animations, a very
> early line will be
>
> #declare MyTime = clock;
>
> then I use MyTime wherever I would use clock. This lets me #declare MyTime =
> 0.6667, for example to go to a position in the animation to test a particular
> stage without running the whole animations. You would pass MyTime to the #macro.
> This may be obvious, but it is an improvement.
>
>
I'll keep that in mind, thanks! What I usually do is set the clock value
using the +K switch if I need to. I get confused by all the INI settings
sometimes too.
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2/17/2019 7:27 AM, Tor Olav Kristensen wrote:
> #macro MacroName(StartTime, EndTime)
>
> #local R = (clock - StartTime)/(EndTime - StartTime);
> #local S = min(max(0, R), 1);
>
> S
>
> #end // macro MacroName
What do you think would be a good way to gradually speed up and then
slow down the motions using this macro? I'm thinking it would require a
sine wave (or some other bell curve), but am not sure how to apply it.
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 19.02.2019 um 06:18 schrieb Mike Horvath:
> On 2/17/2019 7:27 AM, Tor Olav Kristensen wrote:
>> #macro MacroName(StartTime, EndTime)
>>
>> #local R = (clock - StartTime)/(EndTime - StartTime);
>> #local S = min(max(0, R), 1);
>>
>> S
>>
>> #end // macro MacroName
>
> What do you think would be a good way to gradually speed up and then
> slow down the motions using this macro? I'm thinking it would require a
> sine wave (or some other bell curve), but am not sure how to apply it.
A spline might help with this.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> wrote:
> On 2/17/2019 7:27 AM, Tor Olav Kristensen wrote:
> > #macro MacroName(StartTime, EndTime)
> >
> > #local R = (clock - StartTime)/(EndTime - StartTime);
> > #local S = min(max(0, R), 1);
> >
> > S
> >
> > #end // macro MacroName
>
> What do you think would be a good way to gradually speed up and then
> slow down the motions using this macro? I'm thinking it would require a
> sine wave (or some other bell curve), but am not sure how to apply it.
insert
#declare S = sin(S*Tau);
or
#declare S = abs(sin(S*Tau));
before the line
S
However you're running it.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
clipka <ano### [at] anonymous org> wrote:
> Am 19.02.2019 um 06:18 schrieb Mike Horvath:
> > On 2/17/2019 7:27 AM, Tor Olav Kristensen wrote:
> >> #macro MacroName(StartTime, EndTime)
> >>
> >> Â Â Â Â #local R = (clock - StartTime)/(EndTime - StartTime);
> >> Â Â Â Â #local S = min(max(0, R), 1);
> >>
> >> Â Â Â Â S
> >>
> >> #end // macro MacroName
> >
> > What do you think would be a good way to gradually speed up and then
> > slow down the motions using this macro? I'm thinking it would require a
> > sine wave (or some other bell curve), but am not sure how to apply it.
>
> A spline might help with this.
Using a spline would de-linearise the time variable, which isn't the idea. The
simplest way is to just use a cubic:
#macro Spline_Param(StartTime,EndTime)
//
#local LinParam = (clock - StartTime)/(EndTime - StartTime);
#local LinParam = min(max(0,LinParam),1);
//
#local SplineParam = 2*LinParam*LinParam*(3/2 - LinParam);
//
SplineParam
//
#end // Spline_Param
but this doesn't have any adjustment. If you are interested in a constant
acceleration, followed by constant speed, followed by constant deceleration,
respond and I'll do it.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> wrote:
> On 2/17/2019 7:27 AM, Tor Olav Kristensen wrote:
> > #macro MacroName(StartTime, EndTime)
> >
> > #local R = (clock - StartTime)/(EndTime - StartTime);
> > #local S = min(max(0, R), 1);
> >
> > S
> >
> > #end // macro MacroName
>
> What do you think would be a good way to gradually speed up and then
> slow down the motions using this macro? I'm thinking it would require a
> sine wave (or some other bell curve), but am not sure how to apply it.
If you want to use a simple trigonometric function then I recommend using a
cosine wave, like this:
#macro MacroName(StartTime, EndTime)
#local R = (clock - StartTime)/(EndTime - StartTime);
#local S = min(max(0, R), 1)*pi;
#local T = (1 - cos(S))/2;
T
#end // macro MacroName
Now S will vary between 0 and +pi. cos(S) will vary between +1 and -1. And T
will vary between 0 and +1.
https://upload.wikimedia.org/wikipedia/commons/d/d2/Sine_and_Cosine.svg
--
Tor Olav
http://subcube.com
https://github.com/t-o-k/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2/19/2019 9:42 AM, Tor Olav Kristensen wrote:
> Now S will vary between 0 and +pi. cos(S) will vary between +1 and -1. And T
> will vary between 0 and +1.
>
> https://upload.wikimedia.org/wikipedia/commons/d/d2/Sine_and_Cosine.svg
>
Thank you again. That is what I needed.
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> wrote:
> On 2/19/2019 9:42 AM, Tor Olav Kristensen wrote:
> > Now S will vary between 0 and +pi. cos(S) will vary between +1 and -1. And T
> > will vary between 0 and +1.
> >
> > https://upload.wikimedia.org/wikipedia/commons/d/d2/Sine_and_Cosine.svg
> >
>
>
> Thank you again. That is what I needed.
>
>
> Mike
TOK's cosine formulation is actually extremely close to constant acceleration
for half the period followed by constant deceleration.
The following (tested in Matlab, not POVRay, but I think I've transliterated it)
allows for linear interpolation for AccFrac = 0, something very close to the
cosine for AccFrac = 0.5 (constant acceleration for half the period followed by
constant deceleration for the other half) or an acceleration followed by a
coast, followed by a deceleration for 0 < AccFrac < 0.5
#macro AccDec(StartTime,EndTime,AccFrac)
//
// AccFrac should be between 0 and 0.5. It will be clipped.
//
#local KFrac = min(max(0,AccFrac),0.5);
//
#local RelTime = (clock - StartTime)/(EndTime - StartTime);
#local RelTime = min(max(0,RelTime),1);
//
#if(KFrac = 0)
#local SP = RelTime;
#elseif(RelTime < KFrac)
#local SP = RelTime*RelTime/(2*KFrac*(1-KFrac));
#elseif(RelTime < 1 - KFrac)
#local SP = RelTime/(1-KFrac) - KFrac/(2*(1-KFrac));
#else
#local SP = 1 - (1 - RelTime)*(1 - RelTime)/(2*KFrac*(1-KFrac));
#end
SP
//
#end
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I will keep this in mind. Constant acceleration was what I was trying to
achieve.
Mike
On 2/20/2019 6:04 AM, JimT wrote:
> #macro AccDec(StartTime,EndTime,AccFrac)
> //
> // AccFrac should be between 0 and 0.5. It will be clipped.
> //
> #local KFrac = min(max(0,AccFrac),0.5);
> //
> #local RelTime = (clock - StartTime)/(EndTime - StartTime);
> #local RelTime = min(max(0,RelTime),1);
> //
> #if(KFrac = 0)
> #local SP = RelTime;
> #elseif(RelTime < KFrac)
> #local SP = RelTime*RelTime/(2*KFrac*(1-KFrac));
> #elseif(RelTime < 1 - KFrac)
> #local SP = RelTime/(1-KFrac) - KFrac/(2*(1-KFrac));
> #else
> #local SP = 1 - (1 - RelTime)*(1 - RelTime)/(2*KFrac*(1-KFrac));
> #end
> SP
> //
> #end
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |