resize unexpected behavior

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

resize unexpected behavior

Kevig
Hello,

today i stumbled on somthing i din't expect.

if i use:
resize([0,0,40],auto=true) cube([20,20,20],center=true);
the cube expands to 40,40,40 as expected and the center location stays at
0,0,0

if i move te starting cube and use
resize([0,0,40],auto=true)  translate([0,0,10])
cube([20,20,20],center=true);
the cube expands to 40,40,40 as expected but the center location moves to
0,0,20

if i move te starting cube and use
resize([0,0,40],auto=true)  translate([0,10,10])
cube([20,20,20],center=true);
the cube expands to 40,40,40 as expected but the center location moves to
0,20,20

so it scales (partially ) also the location.

this can be helpfull, if you want to keep one side on the same place, but
mostly it is usefull to keep the object at the same center location.
now i have to recalculate the right location for the object after i resize
it,
furthermore, the exact starting location is not always known, i.e. after
taking a slice from a hull model.

how can i fix/work around this?

rgrds
Henk








--
Sent from: http://forum.openscad.org/

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

Re: resize unexpected behavior

acwest
This is pretty much expected. It is resizing based on the origin of the children of the resize module. I find it is best to centre(or at least work relative to a consistent origin) anything inside the resize, then translate the resized result afterwards. 

On Sat, 23 May 2020, 09:49 Kevig, <[hidden email]> wrote:
Hello,

today i stumbled on somthing i din't expect.

if i use:
resize([0,0,40],auto=true) cube([20,20,20],center=true);
the cube expands to 40,40,40 as expected and the center location stays at
0,0,0

if i move te starting cube and use
resize([0,0,40],auto=true)  translate([0,0,10])
cube([20,20,20],center=true);
the cube expands to 40,40,40 as expected but the center location moves to
0,0,20

if i move te starting cube and use
resize([0,0,40],auto=true)  translate([0,10,10])
cube([20,20,20],center=true);
the cube expands to 40,40,40 as expected but the center location moves to
0,20,20

so it scales (partially ) also the location.

this can be helpfull, if you want to keep one side on the same place, but
mostly it is usefull to keep the object at the same center location.
now i have to recalculate the right location for the object after i resize
it,
furthermore, the exact starting location is not always known, i.e. after
taking a slice from a hull model.

how can i fix/work around this?

rgrds
Henk








--
Sent from: http://forum.openscad.org/

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

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

Re: resize unexpected behavior

Kevig
i understand what you are saying, in fact i used it in mostly in that way.
(purely by coincidence)
but now i cut a slice out of a complex model, and need to resize that.
(by using intersection a cube fro the complex object)
so now i have a x coordinate (from where the cube was) but no y or z
coordinate.
then i have to get it to 0,0,0 by trail and error, resize it, and move it
back to where it is supose to be.

I think if you resize a opbject it should resize to the center of that
object, or give it a option to do so (center=true)
perhaps a feature request?

rgrds
Henk



--
Sent from: http://forum.openscad.org/

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

Re: resize unexpected behavior

Ronaldo
I think if you resize a opbject it should resize to the center of that
object, or give it a option to do so (center=true)
perhaps a feature request?

When you have enough symmetries in an object, you may define a center of it. But where is the center of a fork? The baricenter?

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

Re: resize unexpected behavior

Kevig
@Ronaldo
Exactly my point.
supose you import a STL/3MF/OFF of a spoon, a fork an knife.
you want to enlarge the fork on the same location.
a way to do this is:
- place a box roughly over the fork part
- Intersection the fork with the box
- enlarge the created fork
- cut the box out the original

but with this behavior
- move the created fork around by trail and error until it is more or less
at the location it supose to be

and, while i am building a boat, more or less can be the difference between
sinking and floating.

NB
luckily there are no forks (or knifes or spoons) part of my boat ;)

rgrds
Henk





--
Sent from: http://forum.openscad.org/

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

Re: resize unexpected behavior

Ronaldo
@Kevig

I don't see anything special about the center of the bounding box of an object to give it such a merit. It may be what you need in this particular case. But will it be a natural choice acceptable in any case?

Imagine an object composed of a circle centered at the origin with a radius of 10 and another very very small circle centered at [0,100]. The bounding box center of that object will be around the point [0,50].  Do you think it is reasonable to resize it about that point?

The operator resize is a scale whose factors depends on the object dimensions; as such, it scales things about the origin.

Perhaps, if you describe the role played by the resize in your application, we can offer some suggestions.

Em dom., 24 de mai. de 2020 às 10:22, Kevig <[hidden email]> escreveu:
@Ronaldo
Exactly my point.
supose you import a STL/3MF/OFF of a spoon, a fork an knife.
you want to enlarge the fork on the same location.
a way to do this is:
- place a box roughly over the fork part
- Intersection the fork with the box
- enlarge the created fork
- cut the box out the original

but with this behavior
- move the created fork around by trail and error until it is more or less
at the location it supose to be

and, while i am building a boat, more or less can be the difference between
sinking and floating.

NB
luckily there are no forks (or knifes or spoons) part of my boat ;)

rgrds
Henk





--
Sent from: http://forum.openscad.org/

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

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