Simple question: is there a variable for number of steps in animation

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple question: is there a variable for number of steps in animation

bassklampfe
$t runs from 0 to 1 in increments of 1/number-of-steps (or
1/($numberofsteps-1) ? )
But I need a value, which runs 0,1,2,3,4,… number-of-steps ( or
$numberofsteps-1, dont care much about it)

$t*$numberofsteps would do the job, but I haven't found something like
$numberofsteps anywhere.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Simple question: is there a variable for number of steps in animation

kdtop
If the variable t goes from 0 - 1, and you want 0 ... n, could use the formula?

X = n * t?

Kevin

On Sat, Jan 30, 2021 at 3:33 AM bassklampfe <[hidden email]> wrote:
$t runs from 0 to 1 in increments of 1/number-of-steps (or
1/($numberofsteps-1) ? )
But I need a value, which runs 0,1,2,3,4,… number-of-steps ( or
$numberofsteps-1, dont care much about it)

$t*$numberofsteps would do the job, but I haven't found something like
$numberofsteps anywhere.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Simple question: is there a variable for number of steps in animation

bassklampfe
Please read the subject. N is number of steps in *animation*. You can
enter it in OpenSCAD-Gui, but there seems to be no way to get in into
the script. (Except from copying it manually from Gui to script)


Am 30.01.21 um 19:55 schrieb Kevin Toppenberg:
> If the variable t goes from 0 - 1, and you want 0 ... n, could use the
> formula?
>
> X = n * t?
>
> Kevin
>


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Simple question: is there a variable for number of steps in animation

tp3
No, that value does not exist in the script.

It might help if you explain *why* you need that value.

Consider this animation
https://files.openscad.org/advent-calendar-2020/06.scad

For the animation it does not really matter how many
steps there are. The only difference it makes is how
many frames are generated.

ciao,
  Torsten.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: Simple question: is there a variable for number of steps in animation

bassklampfe
Am 30.01.21 um 20:12 schrieb Torsten Paul:
> It might help if you explain *why* you need that value.

Because I want to move an object by a given distance /per frame/.

Yes, if the animation gets longer (steps increased), the object shall
move a longer distance.

If I think over it, $fps would also be helpful, then I could move the
object be a /constant speed/, independent of entered values in GUI

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Simple question: is there a variable for number of steps in animation

doug.moen
bassklampfe said:
> I need a value, which runs 0,1,2,3,4,… number-of-steps.
> $fps would also be helpful, then I could move the
> object be a /constant speed/, independent of entered values in GUI.

In 3 of the procedural 3D graphics programs I have installed, there is a $time variable that gives the duration in seconds from the beginning of the animation. You can trivially use it to move an object at a constant speed, independent of variations in the frame rate during animation. In my limited experience, OpenSCAD is unique in *not* providing this variable.

Bassklampfe, it sounds like your problem would be solved if there were a $time variable of the kind I described.

On Sat, Jan 30, 2021, at 2:18 PM, [hidden email] wrote:

> Am 30.01.21 um 20:12 schrieb Torsten Paul:
> > It might help if you explain *why* you need that value.
>
> Because I want to move an object by a given distance /per frame/.
>
> Yes, if the animation gets longer (steps increased), the object shall
> move a longer distance.
>
> If I think over it, $fps would also be helpful, then I could move the
> object be a /constant speed/, independent of entered values in GUI
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Simple question: is there a variable for number of steps in animation

bassklampfe
Am 31.01.21 um 15:21 schrieb Doug Moen:
 > In 3 of the procedural 3D graphics programs I have installed, there
is a $time variable that gives the duration in seconds from the
beginning of the animation. You can trivially use it to move an object
at a constant speed, independent of variations in the frame rate during
animation. In my limited experience, OpenSCAD is unique in *not*
providing this variable.
 >
 > Bassklampfe, it sounds like your problem would be solved if there
were a $time variable of the kind I described.
 >

There are two different requirements from my sides, which can be solved
by different solutions

Requirement 1: Given distance (or rotation) by frame.
This could be solved by a $frame variable by itself of by a $numframes
variable using $t*$numframes

Requirement 2: Given speed/second independent of frames per second.
$time would help me, but without $numframes I do not know, how long the
animation will last.

Concrete example: Animate a car, which will speed up for the first 2
seconds of an animation, then drive (e.g. in a circle) with a given
speed, as long as the animation lasts, but will speed down for the last
2 seconds, so it is stopped again at the end.

making $numframes /and/ $fps (which are both entered in GUI) available
in the scad script would give me all information to do the required
calculations. $totaltime could be calculated by $numframes/$fps, $time
could be calculated by $t*$totaltime





_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org