discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Re-assigning values to "variables"

R
runsun
Fri, Oct 9, 2015 10:56 PM

Sometimes the red dot doesn't mean that's exactly where you make a mistake.
So check the lines following the red cursor as well. Very often it's a
mismatch of { } or [ ].

Secondly, to get a "round-trip" time fraction, you can try :

// Linear stepping

interval = 0.2;
range = concat( [ for(i=[0:interval:1]) i]
, [ for(i=[1-interval:-interval:0]) i]
);
echo( range );

// ECHO: [0, 0.2, 0.4, 0.6, 0.8, 1, 0.8, 0.6, 0.4, 0.2, 5.55112e-17]

// In some situations, a stepping following a sin wave might be preferred
for smoother u-turn :

interval = 0.1;
for(t = [0:interval:1])
echo( str(t, " ==> ", sin( t180) ));
/

ECHO: "0 ==> 0"
ECHO: "0.1 ==> 0.309017"
ECHO: "0.2 ==> 0.587785"
ECHO: "0.3 ==> 0.809017"
ECHO: "0.4 ==> 0.951057"
ECHO: "0.5 ==> 1"
ECHO: "0.6 ==> 0.951057"
ECHO: "0.7 ==> 0.809017"
ECHO: "0.8 ==> 0.587785"
ECHO: "0.9 ==> 0.309017"
ECHO: "1 ==> 4.96052e-16"
*/


$  Runsun Pan, PhD

$ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git );

$ tips: hash( 1 , 2 ), sweep , var , lerp , animGif

--
View this message in context: http://forum.openscad.org/Re-assigning-values-to-variables-tp14099p14100.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Sometimes the red dot doesn't mean that's exactly where you make a mistake. So check the lines following the red cursor as well. Very often it's a mismatch of { } or [ ]. Secondly, to get a "round-trip" time fraction, you can try : // Linear stepping > interval = 0.2; > range = concat( [ for(i=[0:interval:1]) i] > , [ for(i=[1-interval:-interval:0]) i] > ); > echo( range ); > > // ECHO: [0, 0.2, 0.4, 0.6, 0.8, 1, 0.8, 0.6, 0.4, 0.2, 5.55112e-17] // In some situations, a stepping following a sin wave might be preferred for smoother u-turn : > interval = 0.1; > for(t = [0:interval:1]) > echo( str(t, " ==> ", sin( t*180) )); > /* > ECHO: "0 ==> 0" > ECHO: "0.1 ==> 0.309017" > ECHO: "0.2 ==> 0.587785" > ECHO: "0.3 ==> 0.809017" > ECHO: "0.4 ==> 0.951057" > ECHO: "0.5 ==> 1" > ECHO: "0.6 ==> 0.951057" > ECHO: "0.7 ==> 0.809017" > ECHO: "0.8 ==> 0.587785" > ECHO: "0.9 ==> 0.309017" > ECHO: "1 ==> 4.96052e-16" > */ ----- $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git ); $ tips: hash( 1 , 2 ), sweep , var , lerp , animGif -- View this message in context: http://forum.openscad.org/Re-assigning-values-to-variables-tp14099p14100.html Sent from the OpenSCAD mailing list archive at Nabble.com.