discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

$fn, $fa and $fs

LV
Lucas Vinicius Hartmann
Mon, Jul 18, 2016 2:48 PM

I know the idea behind each of them, but how do they interact? Suppose I
specify all three of them and then draw a cylinder of radius r, how does
OpenSCAD decide how many sides to make it with?

In other words, it is almost always impossible to have exactly $fn sides,
$fs long and covering $fa degrees each... How is this conflict solved?

I know the idea behind each of them, but how do they interact? Suppose I specify all three of them and then draw a cylinder of radius r, how does OpenSCAD decide how many sides to make it with? In other words, it is almost always impossible to have exactly $fn sides, $fs long and covering $fa degrees each... How is this conflict solved?
RP
Ronaldo Persiano
Mon, Jul 18, 2016 3:38 PM

$fn, $fa, $fs are special variables reported in the manual page
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#.24fa.2C_.24fs_and_.24fn
where an algorithm shows how a final value is chosen.

2016-07-18 11:48 GMT-03:00 Lucas Vinicius Hartmann <lucas.hartmann@gmail.com

:

I know the idea behind each of them, but how do they interact? Suppose I
specify all three of them and then draw a cylinder of radius r, how does
OpenSCAD decide how many sides to make it with?

In other words, it is almost always impossible to have exactly $fn sides,
$fs long and covering $fa degrees each... How is this conflict solved?


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

$fn, $fa, $fs are special variables reported in the manual page https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#.24fa.2C_.24fs_and_.24fn where an algorithm shows how a final value is chosen. 2016-07-18 11:48 GMT-03:00 Lucas Vinicius Hartmann <lucas.hartmann@gmail.com >: > I know the idea behind each of them, but how do they interact? Suppose I > specify all three of them and then draw a cylinder of radius r, how does > OpenSCAD decide how many sides to make it with? > > In other words, it is almost always impossible to have exactly $fn sides, > $fs long and covering $fa degrees each... How is this conflict solved? > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
LV
Lucas Vinicius Hartmann
Mon, Jul 18, 2016 4:20 PM

In english that code reads:

If $fn is defined then $fn fragments.
otherwise the least number of fragments to satisfy EITHER $fn OR $fa.

That's what I wanted, thanks. :-)

--
Lucas Vinicius Hartmann

Dizem que se você rodar o CD do Windows ao contrário ele mostra uma
mensagem demoníaca... Mas isso nem é o pior, se você rodar ele normal ele
instala o Windows!

2016-07-18 12:38 GMT-03:00 Ronaldo Persiano rcmpersiano@gmail.com:

$fn, $fa, $fs are special variables reported in the manual page
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#.24fa.2C_.24fs_and_.24fn
where an algorithm shows how a final value is chosen.

2016-07-18 11:48 GMT-03:00 Lucas Vinicius Hartmann <
lucas.hartmann@gmail.com>:

I know the idea behind each of them, but how do they interact? Suppose I
specify all three of them and then draw a cylinder of radius r, how does
OpenSCAD decide how many sides to make it with?

In other words, it is almost always impossible to have exactly $fn sides,
$fs long and covering $fa degrees each... How is this conflict solved?


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

In english that code reads: If $fn is defined then $fn fragments. otherwise the *least number of fragments to satisfy EITHER $fn OR $fa*. That's what I wanted, thanks. :-) -- Lucas Vinicius Hartmann Dizem que se você rodar o CD do Windows ao contrário ele mostra uma mensagem demoníaca... Mas isso nem é o pior, se você rodar ele normal ele instala o Windows! 2016-07-18 12:38 GMT-03:00 Ronaldo Persiano <rcmpersiano@gmail.com>: > $fn, $fa, $fs are special variables reported in the manual page > https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#.24fa.2C_.24fs_and_.24fn > where an algorithm shows how a final value is chosen. > > 2016-07-18 11:48 GMT-03:00 Lucas Vinicius Hartmann < > lucas.hartmann@gmail.com>: > >> I know the idea behind each of them, but how do they interact? Suppose I >> specify all three of them and then draw a cylinder of radius r, how does >> OpenSCAD decide how many sides to make it with? >> >> In other words, it is almost always impossible to have exactly $fn sides, >> $fs long and covering $fa degrees each... How is this conflict solved? >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
M
MichaelAtOz
Mon, Jul 18, 2016 10:45 PM

(int)
ceil(                          // round it up.
fmax(
fmin(                    // Use the min of the following two
segments
360.0 / fa          // 360/angle= number of segments
, r2M_PI / fs)  // 2pi*r = circumference/fs= number of segments
, 5)                      // this means 5 is the minimum if above is
<5
)


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/fn-fa-and-fs-tp17932p17936.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

> (int) > ceil( // round it up. > fmax( > fmin( // Use the min of the following two > segments > 360.0 / fa // 360/angle= number of segments > , r*2*M_PI / fs) // 2pi*r = circumference/fs= number of segments > , 5) // this means 5 is the minimum if above is > <5 > ) ----- Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/fn-fa-and-fs-tp17932p17936.html Sent from the OpenSCAD mailing list archive at Nabble.com.
LV
Lucas Vinicius Hartmann
Tue, Jul 19, 2016 4:36 PM

Other words, given that both conditions yield more than 5 fragments:

  • Fragments will never be less than $fa degrees, no matter how large the
    circle.

  • Fragments will never be shorter that $fs, no matter how small the circle.

I guess if would be interesting if that function could be exposed to the
openscad language, so we would be able to override it should we feel the
need to.

Em 18 de jul de 2016 19:46, "MichaelAtOz" oz.at.michael@gmail.com
escreveu:

(int)
ceil(                          // round it up.
fmax(
fmin(                    // Use the min of the following two
segments
360.0 / fa          // 360/angle= number of segments
, r2M_PI / fs)  // 2pi*r = circumference/fs= number of

segments

   , 5)                      // this means 5 is the minimum if above

is

<5
)


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it!
http://www.ourfairdeal.org/  time is running out!

View this message in context:
http://forum.openscad.org/fn-fa-and-fs-tp17932p17936.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Other words, given that both conditions yield more than 5 fragments: - Fragments will never be less than $fa degrees, no matter how large the circle. - Fragments will never be shorter that $fs, no matter how small the circle. I guess if would be interesting if that function could be exposed to the openscad language, so we would be able to override it should we feel the need to. Em 18 de jul de 2016 19:46, "MichaelAtOz" <oz.at.michael@gmail.com> escreveu: > > > (int) > > ceil( // round it up. > > fmax( > > fmin( // Use the min of the following two > > segments > > 360.0 / fa // 360/angle= number of segments > > , r*2*M_PI / fs) // 2pi*r = circumference/fs= number of > segments > > , 5) // this means 5 is the minimum if above > is > > <5 > > ) > > > > > > ----- > Admin - PM me if you need anything, or if I've done something stupid... > > Unless specifically shown otherwise above, my contribution is in the > Public Domain; to the extent possible under law, I have waived all > copyright and related or neighbouring rights to this work. Obviously > inclusion of works of previous authors is not included in the above. > > The TPP is no simple “trade agreement.” Fight it! > http://www.ourfairdeal.org/ time is running out! > -- > View this message in context: > http://forum.openscad.org/fn-fa-and-fs-tp17932p17936.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
M
MichaelAtOz
Wed, Jul 20, 2016 5:15 AM

lhartmann wrote

I guess if would be interesting if that function could be exposed to the
openscad language, so we would be able to override it should we feel the
need to.

You just set $fn to however you want to calculate it. You can read $fa $fs
variables (& $fn) just like normal variables.


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/fn-fa-and-fs-tp17932p17946.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

lhartmann wrote > I guess if would be interesting if that function could be exposed to the > openscad language, so we would be able to override it should we feel the > need to. You just set $fn to however you want to calculate it. You can read $fa $fs variables (& $fn) just like normal variables. ----- Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/fn-fa-and-fs-tp17932p17946.html Sent from the OpenSCAD mailing list archive at Nabble.com.
LV
Lucas Vinicius Hartmann
Wed, Jul 20, 2016 11:29 AM

That works, but you have to do it for every single circle because you can
not read radius.

Or I can create new modules, mycircle, mycylinder, mysphere, and do the
math any way I want. Yeah, this will work.

Thanks.

Em 20 de jul de 2016 02:16, "MichaelAtOz" oz.at.michael@gmail.com
escreveu:

lhartmann wrote

I guess if would be interesting if that function could be exposed to the
openscad language, so we would be able to override it should we feel the
need to.

You just set $fn to however you want to calculate it. You can read $fa $fs
variables (& $fn) just like normal variables.


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it!
http://www.ourfairdeal.org/  time is running out!

View this message in context:
http://forum.openscad.org/fn-fa-and-fs-tp17932p17946.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

That works, but you have to do it for every single circle because you can not read radius. Or I can create new modules, mycircle, mycylinder, mysphere, and do the math any way I want. Yeah, this will work. Thanks. Em 20 de jul de 2016 02:16, "MichaelAtOz" <oz.at.michael@gmail.com> escreveu: > lhartmann wrote > > I guess if would be interesting if that function could be exposed to the > > openscad language, so we would be able to override it should we feel the > > need to. > > You just set $fn to however you want to calculate it. You can read $fa $fs > variables (& $fn) just like normal variables. > > > > ----- > Admin - PM me if you need anything, or if I've done something stupid... > > Unless specifically shown otherwise above, my contribution is in the > Public Domain; to the extent possible under law, I have waived all > copyright and related or neighbouring rights to this work. Obviously > inclusion of works of previous authors is not included in the above. > > The TPP is no simple “trade agreement.” Fight it! > http://www.ourfairdeal.org/ time is running out! > -- > View this message in context: > http://forum.openscad.org/fn-fa-and-fs-tp17932p17946.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >