discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Retain aspect ratio when using scale() or resize()?

Q
QuackingPlums
Tue, Feb 24, 2015 2:57 PM

Is there an undocumented parameter to either of these transformation
functions that allows me to retain the aspect ratio of the child node?

Example: if I use surface() to create a texture map from a PNG, is there a
way to resize the output to fit within a specified boundary without
affecting the aspect ratio?

--
View this message in context: http://forum.openscad.org/Retain-aspect-ratio-when-using-scale-or-resize-tp11744.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Is there an undocumented parameter to either of these transformation functions that allows me to retain the aspect ratio of the child node? Example: if I use surface() to create a texture map from a PNG, is there a way to resize the output to fit within a specified boundary without affecting the aspect ratio? -- View this message in context: http://forum.openscad.org/Retain-aspect-ratio-when-using-scale-or-resize-tp11744.html Sent from the OpenSCAD mailing list archive at Nabble.com.
TP
Torsten Paul
Tue, Feb 24, 2015 3:37 PM

Is there an undocumented parameter to either of these transformation
functions that allows me to retain the aspect ratio of the child node?

No, but resize() has a documented parameter :-))

http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#resize

"If the 'auto' parameter is set to true, it will auto-scale any 0-dimensions to match."

That only catches the case where you know which of the dimension is
the leading one. So what's not working (as far as I know) is to say:

"fit into a cuboid of size xyz and scale such that it maximizes the volume inside"

Scale() can't have a separate parameter as it has factors as values, so
if it should retain aspect ratio, it simply needs the same value.

ciao,
Torsten.

> Is there an undocumented parameter to either of these transformation > functions that allows me to retain the aspect ratio of the child node? > No, but resize() has a documented parameter :-)) http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#resize "If the 'auto' parameter is set to true, it will auto-scale any 0-dimensions to match." That only catches the case where you know which of the dimension is the leading one. So what's not working (as far as I know) is to say: "fit into a cuboid of size xyz and scale such that it maximizes the volume inside" Scale() can't have a separate parameter as it has factors as values, so if it should retain aspect ratio, it simply needs the same value. ciao, Torsten.
PF
Peter Falke
Tue, Feb 24, 2015 4:02 PM

No, says math: either aspect ratio and a 1-dim boundary, or two-dim
boundary.

2015-02-24 15:57 GMT+01:00 QuackingPlums quackingplums@hotmail.com:

Is there an undocumented parameter to either of these transformation
functions that allows me to retain the aspect ratio of the child node?

Example: if I use surface() to create a texture map from a PNG, is there a
way to resize the output to fit within a specified boundary without
affecting the aspect ratio?

--
View this message in context:
http://forum.openscad.org/Retain-aspect-ratio-when-using-scale-or-resize-tp11744.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

--
stempeldergeschichte@googlemail.com karsten@rohrbach.de

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

No, says math: either aspect ratio and a 1-dim boundary, or two-dim boundary. 2015-02-24 15:57 GMT+01:00 QuackingPlums <quackingplums@hotmail.com>: > Is there an undocumented parameter to either of these transformation > functions that allows me to retain the aspect ratio of the child node? > > Example: if I use surface() to create a texture map from a PNG, is there a > way to resize the output to fit within a specified boundary without > affecting the aspect ratio? > > > > -- > View this message in context: > http://forum.openscad.org/Retain-aspect-ratio-when-using-scale-or-resize-tp11744.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 > -- stempeldergeschichte@googlemail.com <karsten@rohrbach.de> P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist: Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben. Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen. P.S. In case my e-mail is shorter than you enjoy: I am currently trying short replies instead of no replies at all. Please let me know, if you like to read more. Enjoy!
Q
QuackingPlums
Wed, Feb 25, 2015 10:59 AM

Thanks for your reply. The auto parameter works as long as the imported PNG
is in a known orientation as you say, but I was hoping I could do something
for a totally generic solution.

Am I correct that there are no functions that can return the dimensions of
an imported PNG file?

--
View this message in context: http://forum.openscad.org/Retain-aspect-ratio-when-using-scale-or-resize-tp11744p11759.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Thanks for your reply. The auto parameter works as long as the imported PNG is in a known orientation as you say, but I was hoping I could do something for a totally generic solution. Am I correct that there are no functions that can return the dimensions of an imported PNG file? -- View this message in context: http://forum.openscad.org/Retain-aspect-ratio-when-using-scale-or-resize-tp11744p11759.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Wed, Feb 25, 2015 1:34 PM

Yes,

for a dxf there is

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Getting_input


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. This work is published globally via the internet. :) 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/

View this message in context: http://forum.openscad.org/Retain-aspect-ratio-when-using-scale-or-resize-tp11744p11760.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Yes, for a dxf there is https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Getting_input ----- 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. This work is published globally via the internet. :) 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/ -- View this message in context: http://forum.openscad.org/Retain-aspect-ratio-when-using-scale-or-resize-tp11744p11760.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Wed, Feb 25, 2015 4:39 PM

On Feb 25, 2015, at 05:59 AM, QuackingPlums quackingplums@hotmail.com wrote:

Am I correct that there are no functions that can return the dimensions of
an imported PNG file?

It feels like resize() should be extended to have options for specifying a maximum bounding box and preserve aspect ratio.

-Marius

On Feb 25, 2015, at 05:59 AM, QuackingPlums <quackingplums@hotmail.com> wrote: > Am I correct that there are no functions that can return the dimensions of > an imported PNG file? > It feels like resize() should be extended to have options for specifying a maximum bounding box and preserve aspect ratio. -Marius
TP
Torsten Paul
Wed, Feb 25, 2015 5:44 PM

Von: "Marius Kintel" marius@kintel.net

Am I correct that there are no functions that can return the dimensions of
an imported PNG file?

It feels like resize() should be extended to have options for specifying a maximum bounding box and preserve aspect ratio.

And maybe also have some kind of position() thingy too to go along with that? I guess both together should cover most use-cases to fit unknown/extern model parts into some scad design (e.g. STL, DXF, text(), ...).

ciao,
Torsten.

> Von: "Marius Kintel" <marius@kintel.net> > > Am I correct that there are no functions that can return the dimensions of > > an imported PNG file? > > > It feels like resize() should be extended to have options for specifying a maximum bounding box and preserve aspect ratio. > And maybe also have some kind of position() thingy too to go along with that? I guess both together should cover most use-cases to fit unknown/extern model parts into some scad design (e.g. STL, DXF, text(), ...). ciao, Torsten.