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

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

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

QuackingPlums
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?
tp3
Reply | Threaded
Open this post in threaded view
|

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

tp3
> 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.

_______________________________________________
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: Retain aspect ratio when using scale() or resize()?

Peter Falke
In reply to this post by QuackingPlums
No, says math: either aspect ratio and a 1-dim boundary, or two-dim boundary.

2015-02-24 15:57 GMT+01:00 QuackingPlums <[hidden email]>:
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



--
[hidden email]

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!

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

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

QuackingPlums
In reply to this post by tp3
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?

Reply | Threaded
Open this post in threaded view
|

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

MichaelAtOz
Administrator
Yes,

for a dxf there is

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

Admin - email* me if you need anything,
or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

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!
Reply | Threaded
Open this post in threaded view
|

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

kintel
Administrator
In reply to this post by QuackingPlums
On Feb 25, 2015, at 05:59 AM, QuackingPlums <[hidden email]> 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


_______________________________________________
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: Retain aspect ratio when using scale() or resize()?

tp3
> Von: "Marius Kintel" <[hidden email]>
> > 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.

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