discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

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

B
bassklampfe
Sat, Jan 30, 2021 8:33 AM

$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/

$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/
KT
Kevin Toppenberg
Sat, Jan 30, 2021 6:55 PM

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 jjvb-openscad@bassklampfe.de
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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <jjvb-openscad@bassklampfe.de> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
JO
jjvb-openscad@bassklampfe.de
Sat, Jan 30, 2021 7:06 PM

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

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 >
TP
Torsten Paul
Sat, Jan 30, 2021 7:12 PM

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.

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.
JO
jjvb-openscad@bassklampfe.de
Sat, Jan 30, 2021 7:18 PM

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

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
DM
Doug Moen
Sun, Jan 31, 2021 2:21 PM

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, jjvb-openscad@bassklampfe.de 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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, jjvb-openscad@bassklampfe.de 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
JO
jjvb-openscad@bassklampfe.de
Sun, Jan 31, 2021 5:47 PM

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

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