Strange behaviour of linear_extrude()

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

Strange behaviour of linear_extrude()

lar3ry
OpenSCAD 2019.05

Am I misunderstanding linear_extrude()?

linear_extrude(height = 5,scale = .7)
  square (10);
linear_extrude(height = 5,scale = .7)
  translate([10,10,0])
    square(10);
linear_extrude(height = 5,scale = .7)
  translate([20,20,0])
    square(10);

translate ([35,35,0])
  linear_extrude(height = 5,center=true,scale = .7)
    square(10,center=true);

The first linear_extrude gives me a figure at x0/y0 that has vertical sides,
and the other sides are scaled, becoming smaller at the top.

The second and third ones give me something akin to a cube with the top
skewed by an amount dependent on the amount of the x and y translation.

Making the square centered, as in the last one seems to be the only one that
behaves the way I understand it.

My understanding, from looking at the docs, that the figures should all look
like a truncated pyramid.

LE.png <http://forum.openscad.org/file/t2121/LE.png>  





--
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: Strange behaviour of linear_extrude()

lar3ry
Oh, forgot to change one of the objects...
This third object is still strange. Changed to put the translate first.

linear_extrude(height = 5,scale = .7)
  square (10);
linear_extrude(height = 5,scale = .7)
  translate([10,10,0])
    square(10);
translate([20,20,0])
  linear_extrude(height = 5,scale = .7)
    square(10);

translate ([35,35,0])
linear_extrude(height = 5,center=true,scale = .7)
        square(10,center=true);



--
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: Strange behaviour of linear_extrude()

Chaoticenigma
Im gonna try smaller slices, and hulling them.together. the truncated pyramid is what i kept getting, so im gonna switch my approach

On Thu, Feb 13, 2020, 11:15 AM lar3ry <[hidden email]> wrote:
Oh, forgot to change one of the objects...
This third object is still strange. Changed to put the translate first.

linear_extrude(height = 5,scale = .7)
  square (10);
linear_extrude(height = 5,scale = .7)
  translate([10,10,0])
    square(10);
translate([20,20,0])
  linear_extrude(height = 5,scale = .7)
    square(10);

translate ([35,35,0])
linear_extrude(height = 5,center=true,scale = .7)
        square(10,center=true);



--
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: Strange behaviour of linear_extrude()

acwest
They are scaled based on distance from the origin, so if you want all
truncated pyramids, centre the square, and do the translations around
the linear_extrude, instead of inside it

On Thu, Feb 13, 2020 at 1:23 PM Jimmy W. <[hidden email]> wrote:

>
> Im gonna try smaller slices, and hulling them.together. the truncated pyramid is what i kept getting, so im gonna switch my approach
>
> On Thu, Feb 13, 2020, 11:15 AM lar3ry <[hidden email]> wrote:
>>
>> Oh, forgot to change one of the objects...
>> This third object is still strange. Changed to put the translate first.
>>
>> linear_extrude(height = 5,scale = .7)
>>   square (10);
>> linear_extrude(height = 5,scale = .7)
>>   translate([10,10,0])
>>     square(10);
>> translate([20,20,0])
>>   linear_extrude(height = 5,scale = .7)
>>     square(10);
>>
>> translate ([35,35,0])
>> linear_extrude(height = 5,center=true,scale = .7)
>>         square(10,center=true);
>>
>>
>>
>> --
>> 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

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

Re: Strange behaviour of linear_extrude()

lar3ry
acwest wrote
> They are scaled based on distance from the origin, so if you want all
> truncated pyramids, centre the square, and do the translations around
> the linear_extrude, instead of inside it

Are you saying that the problem is with scale() and not linear_extrude()?
If so, it seems to be confirmed by objects 5 and 6 in the following:

linear_extrude(height = 5,scale = .7)  // object 1
  square (10);

linear_extrude(height = 5,scale = .7)  // object 2
  translate([10,10,0])
    square(10);

translate([20,20,0])
  linear_extrude(height = 5,scale = .7)  // object 3
    square(10);

translate ([35,35,0])  // object 4
 linear_extrude(height = 5,center=true,scale = .7)
  square(10,center=true);

linear_extrude(10)  // object 5
  translate([40,40,0])
    square(10);

translate([50,50,0])   // object 6
  linear_extrude(10)
    square(10);

As long as there is no scale() involved, the result is as I expect.

I *know* I can get the result I want by centering the square, but I'm just
wondering why it scales the way it does, and if it's a bug or not. LE.png
<http://forum.openscad.org/file/t2121/LE.png>  




--
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: Strange behaviour of linear_extrude()

nophead
Scale simply scales all dimensions. So an object away from the origin, both gets smaller and closer to the origin. What would you expect it to do?

On Thu, 13 Feb 2020 at 21:26, lar3ry <[hidden email]> wrote:
acwest wrote
> They are scaled based on distance from the origin, so if you want all
> truncated pyramids, centre the square, and do the translations around
> the linear_extrude, instead of inside it

Are you saying that the problem is with scale() and not linear_extrude()?
If so, it seems to be confirmed by objects 5 and 6 in the following:

linear_extrude(height = 5,scale = .7)  // object 1
  square (10);

linear_extrude(height = 5,scale = .7)  // object 2
  translate([10,10,0])
    square(10);

translate([20,20,0])
  linear_extrude(height = 5,scale = .7)  // object 3
    square(10);

translate ([35,35,0])  // object 4
 linear_extrude(height = 5,center=true,scale = .7)
  square(10,center=true);

linear_extrude(10)  // object 5
  translate([40,40,0])
    square(10);

translate([50,50,0])   // object 6
  linear_extrude(10)
    square(10);

As long as there is no scale() involved, the result is as I expect.

I *know* I can get the result I want by centering the square, but I'm just
wondering why it scales the way it does, and if it's a bug or not. LE.png
<http://forum.openscad.org/file/t2121/LE.png




--
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: Strange behaviour of linear_extrude()

nophead
Or perhaps I should say it scales all coordinates by the same factor.

On Thu, 13 Feb 2020 at 21:28, nop head <[hidden email]> wrote:
Scale simply scales all dimensions. So an object away from the origin, both gets smaller and closer to the origin. What would you expect it to do?

On Thu, 13 Feb 2020 at 21:26, lar3ry <[hidden email]> wrote:
acwest wrote
> They are scaled based on distance from the origin, so if you want all
> truncated pyramids, centre the square, and do the translations around
> the linear_extrude, instead of inside it

Are you saying that the problem is with scale() and not linear_extrude()?
If so, it seems to be confirmed by objects 5 and 6 in the following:

linear_extrude(height = 5,scale = .7)  // object 1
  square (10);

linear_extrude(height = 5,scale = .7)  // object 2
  translate([10,10,0])
    square(10);

translate([20,20,0])
  linear_extrude(height = 5,scale = .7)  // object 3
    square(10);

translate ([35,35,0])  // object 4
 linear_extrude(height = 5,center=true,scale = .7)
  square(10,center=true);

linear_extrude(10)  // object 5
  translate([40,40,0])
    square(10);

translate([50,50,0])   // object 6
  linear_extrude(10)
    square(10);

As long as there is no scale() involved, the result is as I expect.

I *know* I can get the result I want by centering the square, but I'm just
wondering why it scales the way it does, and if it's a bug or not. LE.png
<http://forum.openscad.org/file/t2121/LE.png




--
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: Strange behaviour of linear_extrude()

acwest
In reply to this post by lar3ry
when it scales, it needs a 0 reference point to scale from. It uses
the origin for that, as it doesn't look inside the object it is
scaling to see where its centre is.

On Thu, Feb 13, 2020 at 4:25 PM lar3ry <[hidden email]> wrote:

>
> acwest wrote
> > They are scaled based on distance from the origin, so if you want all
> > truncated pyramids, centre the square, and do the translations around
> > the linear_extrude, instead of inside it
>
> Are you saying that the problem is with scale() and not linear_extrude()?
> If so, it seems to be confirmed by objects 5 and 6 in the following:
>
> linear_extrude(height = 5,scale = .7)  // object 1
>   square (10);
>
> linear_extrude(height = 5,scale = .7)  // object 2
>   translate([10,10,0])
>     square(10);
>
> translate([20,20,0])
>   linear_extrude(height = 5,scale = .7)  // object 3
>     square(10);
>
> translate ([35,35,0])  // object 4
>  linear_extrude(height = 5,center=true,scale = .7)
>   square(10,center=true);
>
> linear_extrude(10)  // object 5
>   translate([40,40,0])
>     square(10);
>
> translate([50,50,0])   // object 6
>   linear_extrude(10)
>     square(10);
>
> As long as there is no scale() involved, the result is as I expect.
>
> I *know* I can get the result I want by centering the square, but I'm just
> wondering why it scales the way it does, and if it's a bug or not. LE.png
> <http://forum.openscad.org/file/t2121/LE.png>
>
>
>
>
> --
> 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: Strange behaviour of linear_extrude()

lar3ry
In reply to this post by nophead
nophead wrote
> Scale simply scales all dimensions. So an object away from the origin,
> both
> gets smaller and closer to the origin. What would you expect it to do?

I certainly didn't expect it to scale toward the global origin. In the
manual, both examples of linear_extrude with a scale parameter do have a
'center=true' parameter, but I had no idea that the position of the thing
being extruded REQUIRED that, in order to scale toward the center of the
figure being extruded.

Anyway, now I know. Thank you and acwest.




--
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: Strange behaviour of linear_extrude()

acwest
There really aren't any good options other than the origin, you really don't want it guessing what to scale it towards. This is the only consistently predictable way of doing it that works with arbitrary shapes

On Thu, 13 Feb 2020, 17:05 lar3ry, <[hidden email]> wrote:
nophead wrote
> Scale simply scales all dimensions. So an object away from the origin,
> both
> gets smaller and closer to the origin. What would you expect it to do?

I certainly didn't expect it to scale toward the global origin. In the
manual, both examples of linear_extrude with a scale parameter do have a
'center=true' parameter, but I had no idea that the position of the thing
being extruded REQUIRED that, in order to scale toward the center of the
figure being extruded.

Anyway, now I know. Thank you and acwest.




--
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: Strange behaviour of linear_extrude()

nophead
In reply to this post by lar3ry
The scale transform has no origin. It is simply an operation which scales each vertex of the object by the constant scale factor. It has the effect of moving everything towards the origin when the scale is less than 1 simply because smaller numbers are nearer the origin as well as being nearer to each other.

Like rotate (which rotates around origin), you could do a translate before and after to change the origin.

On Thu, 13 Feb 2020 at 22:05, lar3ry <[hidden email]> wrote:
nophead wrote
> Scale simply scales all dimensions. So an object away from the origin,
> both
> gets smaller and closer to the origin. What would you expect it to do?

I certainly didn't expect it to scale toward the global origin. In the
manual, both examples of linear_extrude with a scale parameter do have a
'center=true' parameter, but I had no idea that the position of the thing
being extruded REQUIRED that, in order to scale toward the center of the
figure being extruded.

Anyway, now I know. Thank you and acwest.




--
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: Strange behaviour of linear_extrude()

adrianv
"The scale transform has no origin" ....  "Like rotate...you could do a
translate...to change the origin".

Hmmmm.  I think that like rotate, the scale transform does have an origin.
There is a distinguished point that doesn't change under the operation, just
like rotate.  And just like rotate, you can move it around by translating
before you scale, which changes the distinguished point that is fixed under
the transformation.  


nophead wrote

> The scale transform has no origin. It is simply an operation which scales
> each vertex of the object by the constant scale factor. It has the
> effect of moving everything towards the origin when the scale is less than
> 1 simply because smaller numbers are nearer the origin as well as being
> nearer to each other.
>
> Like rotate (which rotates around origin), you could do a translate before
> and after to change the origin.
>
> On Thu, 13 Feb 2020 at 22:05, lar3ry &lt;

> lar3ry@

> &gt; wrote:
>
>> nophead wrote
>> > Scale simply scales all dimensions. So an object away from the origin,
>> > both
>> > gets smaller and closer to the origin. What would you expect it to do?
>>
>> I certainly didn't expect it to scale toward the global origin. In the
>> manual, both examples of linear_extrude with a scale parameter do have a
>> 'center=true' parameter, but I had no idea that the position of the thing
>> being extruded REQUIRED that, in order to scale toward the center of the
>> figure being extruded.
>>
>> Anyway, now I know. Thank you and acwest.
>>
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>>

> Discuss@.openscad

>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
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: Strange behaviour of linear_extrude()

JordanBrown
In reply to this post by lar3ry
On 2/13/2020 2:04 PM, lar3ry wrote:
I certainly didn't expect it to scale toward the global origin.

"Global origin" is an interesting concept.  As the human running the program and looking at the preview, it looks like there's a global origin, a "one true [0,0,0]", where the crosshairs intersect, but while you're designing it's best to completely ignore that concept.

Any given object has an origin, a [0,0,0] for *that* object.  When you then translate that object, *its* [0,0,0] goes somewhere else, and the new object, the translated one, has its own [0,0,0].

If you have the sequence
cube(10);
translate([10,0,0]) {
    cube(10);
    translate([10,0,0]) {
        cube(10);
    }
}

Each cube is at its own [0,0,0].  Each translate takes that coordinate system, and moves it to a different position in the "parent" coordinate system.

The same is true for rotation and scaling.  Each object is defined in terms of *its* coordinate system, but as you transform it the transformed objects are with respect to different coordinate systems.

Linear extrude doesn't extrude towards or away from any "global origin".  Like any of the other transformations, it operates relative to the origin of its child.  That's true whether its child is a square centered around [0,0] or a square centered around [10,0]... it operates relative to [0,0].  Again, that's its child's [0,0], not any kind of global [0,0].  The object resulting from the linear_extrude might then be translated far away from what's displayed as [0,0,0], but that doesn't affect the processing of the extrusion itself.

I'm not explaining this very well.  The concept is, I think, quite simple, but sometimes it hurts your brain.

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

Re: Strange behaviour of linear_extrude()

nophead
I think that is just a philosophical way of looking at it. The fact remains that the scale transform simply multiples each coordinate of its child by a constant. The fact that 0 is the only number that doesn't change under that transform is just how multiplication works.

On Thu, 13 Feb 2020 at 23:40, Jordan Brown <[hidden email]> wrote:
On 2/13/2020 2:04 PM, lar3ry wrote:
I certainly didn't expect it to scale toward the global origin.

"Global origin" is an interesting concept.  As the human running the program and looking at the preview, it looks like there's a global origin, a "one true [0,0,0]", where the crosshairs intersect, but while you're designing it's best to completely ignore that concept.

Any given object has an origin, a [0,0,0] for *that* object.  When you then translate that object, *its* [0,0,0] goes somewhere else, and the new object, the translated one, has its own [0,0,0].

If you have the sequence
cube(10);
translate([10,0,0]) {
    cube(10);
    translate([10,0,0]) {
        cube(10);
    }
}

Each cube is at its own [0,0,0].  Each translate takes that coordinate system, and moves it to a different position in the "parent" coordinate system.

The same is true for rotation and scaling.  Each object is defined in terms of *its* coordinate system, but as you transform it the transformed objects are with respect to different coordinate systems.

Linear extrude doesn't extrude towards or away from any "global origin".  Like any of the other transformations, it operates relative to the origin of its child.  That's true whether its child is a square centered around [0,0] or a square centered around [10,0]... it operates relative to [0,0].  Again, that's its child's [0,0], not any kind of global [0,0].  The object resulting from the linear_extrude might then be translated far away from what's displayed as [0,0,0], but that doesn't affect the processing of the extrusion itself.

I'm not explaining this very well.  The concept is, I think, quite simple, but sometimes it hurts your brain.
_______________________________________________
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: Strange behaviour of linear_extrude()

lar3ry
In reply to this post by JordanBrown
JordanBrown wrote

> On 2/13/2020 2:04 PM, lar3ry wrote:
>> I certainly didn't expect it to scale toward the global origin.
>
> "Global origin" is an interesting concept.  As the human running the
> program and looking at the preview, it looks like there's a global
> origin, a "one true [0,0,0]", where the crosshairs intersect, but while
> you're designing it's best to completely ignore that concept.
>
> Any given object has an origin, a [0,0,0] for *that* object.  When you
> then translate that object, *its* [0,0,0] goes somewhere else, and the
> new object, the translated one, has its own [0,0,0].
>
> If you have the sequence
>
>     cube(10);
>     translate([10,0,0]) {
>         cube(10);
>         translate([10,0,0]) {
>             cube(10);
>         }
>     }
>
> Each cube is at its own [0,0,0].  Each translate takes that coordinate
> system, and moves it to a different position in the "parent" coordinate
> system.
>
> The same is true for rotation and scaling.  Each object is defined in
> terms of *its* coordinate system, but as you transform it the
> transformed objects are with respect to different coordinate systems.
>
> Linear extrude doesn't extrude towards or away from any "global
> origin".  Like any of the other transformations, it operates relative to
> the origin of its child.  That's true whether its child is a square
> centered around [0,0] or a square centered around [10,0]... it operates
> relative to [0,0].  Again, that's its child's [0,0], not any kind of
> global [0,0].  The object resulting from the linear_extrude might then
> be translated far away from what's displayed as [0,0,0], but that
> doesn't affect the processing of the extrusion itself.
>
> I'm not explaining this very well.  The concept is, I think, quite
> simple, but sometimes it hurts your brain.

Actually, I think I do get it. I just tried something that probably made me
understand where you are coming from.

translate([20,20,0])
        linear_extrude(20, scale = .5)
                circle(10);
translate([30,30,0])
        linear_extrude(20, scale = .5)
    square(10);

The circle worked fine in this case, exactly as I would expect, but the
square did not, and if I understand what you are saying, it is because the
origin of the circle is the centre of it, while the origin of the square is
the lower left. So the the scale worked toward the origin in both cases.

Well, even if I still have it wrong, at least it's something that will keep
me from scratching my head for a few hours the next time this comes up.

Thanks Jordan!




--
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: Strange behaviour of linear_extrude()

Ronaldo
In reply to this post by lar3ry
The really strange behavior of linear_extrude has not been considered here yet. As many people has said, the scale in linear_extrude is taken relative to the origin and that is true even for non-uniform scales. The same happens with the twist which is essentially a continuous rotation along the straight up path: the intermediate sections are rotations about the origin. All that seems natural to me.

What is strange to me is the behavior when both a non-uniform scale and twist are used in the same linear_extrude. As the picture bellow shows, the intermediate sections of the linear_extrude of a square with non-uniform scale and twist will not be a rectangle as might be expected. In the picture, the intermediate sections (obtained by cutting the shapes at some level) are displayed in yellow.

linear_extrude_cases.PNG
Top view:
linear_extrude_top_view.PNG

In the top view, the lower line has a scale and no twist, the second just twist and, in the third, both are set. I would expect that the intermediate sections in the third line be rotations of the scaled base square, and so, it would be a rectangle. However, it is the scale of the rotated base square. This order of applying the transforms deforms the shape in an unexpected unreasonable way. That seems a bad choice and should be considered a bug to be corrected.

I have written a code in user's space to linear extrude a polygon expressed by its vertices that applies the rotation after the scale and published it in another thread (http://forum.openscad.org/Weird-intersection-results-tp28232p28253.html).  
 
h   = 5;       // linear_extrude height
a   = 180;     // twist angle
s   = [1,0.3]; // scale
cut = 2/3;     // height level cut

tower(1,0,[0,0,0]); // at the origin

intersection() {
  union(){
    translate([5, 5,0])  triplet(s,0);
    translate([5,15,0])  triplet(1,a);
    translate([5,25,0])  triplet(s,a);
  }
  color("yellow")
    cube([1000,1000,2*h*cut],center=true);
}

module axis()
  color("red")
    translate([-0.1,-0.1,0])
      cube([0.2,0.2,10.1]);

module tower(s,t,c) {
  linear_extrude(h, scale=s, twist=t, slices=100, convexity=4)
    translate(c)
      square(3,center=true);
  axis();
}

module triplet(s=1,t=0)
{
  translate([ 0,0,0]) tower(s,t,[0,0,0]);
  translate([10,0,0]) tower(s,t,[1.5,1.5,0]);
  translate([20,0,0]) tower(s,t,[2,2,0]);
}


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

Re: Strange behaviour of linear_extrude()

jon_bondy

Does this variability give us more power, albeit at the expense of needing to understand a more complex tool?

Jon

On 2/14/2020 9:05 AM, Ronaldo Persiano wrote:
The really strange behavior of linear_extrude has not been considered here yet. As many people has said, the scale in linear_extrude is taken relative to the origin and that is true even for non-uniform scales. The same happens with the twist which is essentially a continuous rotation along the straight up path: the intermediate sections are rotations about the origin. All that seems natural to me.   ... ... ...



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

Re: Strange behaviour of linear_extrude()

JordanBrown
On 2/14/2020 6:30 AM, jon wrote:

Does this variability give us more power, albeit at the expense of needing to understand a more complex tool?


No.  It appears that linear_extrude does the rotate first, and then the scale, and so as Ronaldo says distorts the shape.  If you wanted scale-first, as I agree seems the more obvious result, I don't think there's any way to get it.

Unfortunately, I doubt it can be "fixed", because rotate-first isn't *wrong*, just unexpected.  Somebody might have designed around that behavior.  But there could be a parameter to switch the order.


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

Re: Strange behaviour of linear_extrude()

Parkinbot
In reply to this post by Ronaldo
Ronaldo,
you are right. This *seems* like a strange behaviour, and obviously comes
from a *wrong* application order of the transformations.

linear_extrude(height = 100, twist = 310, scale = [1, .2])
translate([30, 0, 0])square(20, center = true);

The following sweep() shows in which order the implementation of
linear_extrude() does its transformations:

sweep(linear_extrude(height = 100, twist = 310, scale = [1, .2]));
function linear_extrude(height, twist, scale, slices) =
[for (i=[0:slices])
  let(dh= height/slices)         // calc height per slice
  let(ds= ([1,1]-scale)/slices)  // calc scale per slice
     S(1-ds[0]*i, 1-ds[1]*i, 1,  // scale
     Rz(-twist/slices*i,         // rotate
     Tz(i*dh, Tx(30, square(20))))) //
];

and you expect it to do this (scale and rotation interchanged):

color("red")sweep(linear_extrude1(height = 100, twist = 310, scale = [1,
.2]));
function linear_extrude1(height, twist, scale, slices) =
[for (i=[0:slices])
  let(dh= height/slices)         // calc height per slice
  let(ds= ([1,1]-scale)/slices)  // calc scale per slice
     Rz(-twist/slices*i,         // rotate
     S(1-ds[0]*i, 1-ds[1]*i, 1,  // scale
     Tz(i*dh, Tx(30, rev(square(20)))))) //
  ];

but if you look at the red object in the result, you will see, that the
rotation is not scaled as you might want.  And I am afraid you can't have
both ... unless you compute and add a skew operation that compensates for
the unwanted skew.

<http://forum.openscad.org/file/t887/linear_extrude.png>





--
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: Strange behaviour of linear_extrude()

Ronaldo
Parkinbot,

Your first code seems to be equivalent to my extrude_up module that operates on polygons given by points. That is what I would expect that linear_extrude to be: simply the twist of a straight up extrusion, scaled or not. I don't want to scale a rotation (except eventually with a uniform scale; so no skew). It makes no sense to me. I don't see any use of that to model anything.

Try a very twisted extrusion:

linear_extrude(height = 100, twist = 10*310, scale = [1,.2]) translate([30,0]) square(20);

That shape is not conical, nor cylindrical. It seems a very strange hat when hulled! Ouch!


Em sáb., 15 de fev. de 2020 às 18:32, Parkinbot <[hidden email]> escreveu:
Ronaldo,
you are right. This *seems* like a strange behaviour, and obviously comes
from a *wrong* application order of the transformations.

linear_extrude(height = 100, twist = 310, scale = [1, .2])
translate([30, 0, 0])square(20, center = true);

The following sweep() shows in which order the implementation of
linear_extrude() does its transformations:

sweep(linear_extrude(height = 100, twist = 310, scale = [1, .2]));
function linear_extrude(height, twist, scale, slices) =
[for (i=[0:slices])
  let(dh= height/slices)         // calc height per slice
  let(ds= ([1,1]-scale)/slices)  // calc scale per slice
     S(1-ds[0]*i, 1-ds[1]*i, 1,  // scale
     Rz(-twist/slices*i,         // rotate
     Tz(i*dh, Tx(30, square(20))))) //
];

and you expect it to do this (scale and rotation interchanged):

color("red")sweep(linear_extrude1(height = 100, twist = 310, scale = [1,
.2]));
function linear_extrude1(height, twist, scale, slices) =
[for (i=[0:slices])
  let(dh= height/slices)         // calc height per slice
  let(ds= ([1,1]-scale)/slices)  // calc scale per slice
     Rz(-twist/slices*i,         // rotate
     S(1-ds[0]*i, 1-ds[1]*i, 1,  // scale
     Tz(i*dh, Tx(30, rev(square(20)))))) //
  ];

but if you look at the red object in the result, you will see, that the
rotation is not scaled as you might want.  And I am afraid you can't have
both ... unless you compute and add a skew operation that compensates for
the unwanted skew.

<http://forum.openscad.org/file/t887/linear_extrude.png>





--
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
12