flaring a model

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

flaring a model

leebc
I have a model I've constructed using a series of translates, hulls,
linear_extrudes, and imports.

I want to flare the bottom out so it is wider than it will be
proportionally wider (in X and Y) than it is now but so that the top will
remain the same size.

Is there a way to do this?  Possibly with multimatrix?


Yes, I can rescale the import, but I'd have to recalculate a bunch of stuff.

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

Re: flaring a model

Parkinbot
If you want to scale your model only in XY, say by .9 leaving Z as it is, you
can use

scale([.9, .9, 1]) model();

but there is no conic (or even more general nonlinear) transformation in
OpenSCAD that will map a cylindric object into a truncated cone object or
similar.

However you can extrude an object into a truncated cone object, e.g. by
using

linear_extrude(height = 10, scale = 0.9)  myModel2D();
module myModel2D() circle(10);  




--
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: flaring a model

Max Bond
There's nothing you can do with multmatrix() that you can't do with a series of other transformations (rotate(), translate(), scale(), etc). All it really lets you do is apply multiple transformations at once, which, if you ask me, only serves to obscure the programmer's intentions. Look into Affine transformations if you'd like more information.

If Parkinbot's suggeston doesn't work for your particular use case (and it sounds like you're stuck in 3D since you're using import()), you might try cutting your model into pieces by sweeping across it with a thin cube(), and then scaling these pieces & union()'ing them together. It'll be tricky, and you'll have to be careful so as not to create zero-width gaps, but

Something to the effect of:

function f(h) = ...some function defining your flare (reciprocal function perhaps)...
for (i=[0:depth:myModelHeight/depth]) {
   scale([f(i), f(i), 1]) intersection() {
      translate([0, 0, i]) cube([modelX, modelY, depth]);
      myModel();
   }
}

Note this psuedocode doesn't account for zero-width gaps. Depending on the geometry of your model you may have to create small extrusions that join each section together to prevent ZWGs. Another approach might be to sweep the cube() up your model, use projection() to turn that section into 2D, and then use Parkinbot's approach.

Cheers,
Max

On Sun, Dec 15, 2019 at 5:38 AM Parkinbot <[hidden email]> wrote:
If you want to scale your model only in XY, say by .9 leaving Z as it is, you
can use

scale([.9, .9, 1]) model();

but there is no conic (or even more general nonlinear) transformation in
OpenSCAD that will map a cylindric object into a truncated cone object or
similar.

However you can extrude an object into a truncated cone object, e.g. by
using

linear_extrude(height = 10, scale = 0.9)  myModel2D();
module myModel2D() circle(10); 




--
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: flaring a model

Max Bond
*but it should work.

On Sun, Dec 15, 2019 at 3:23 PM Max Bond <[hidden email]> wrote:
There's nothing you can do with multmatrix() that you can't do with a series of other transformations (rotate(), translate(), scale(), etc). All it really lets you do is apply multiple transformations at once, which, if you ask me, only serves to obscure the programmer's intentions. Look into Affine transformations if you'd like more information.

If Parkinbot's suggeston doesn't work for your particular use case (and it sounds like you're stuck in 3D since you're using import()), you might try cutting your model into pieces by sweeping across it with a thin cube(), and then scaling these pieces & union()'ing them together. It'll be tricky, and you'll have to be careful so as not to create zero-width gaps, but

Something to the effect of:

function f(h) = ...some function defining your flare (reciprocal function perhaps)...
for (i=[0:depth:myModelHeight/depth]) {
   scale([f(i), f(i), 1]) intersection() {
      translate([0, 0, i]) cube([modelX, modelY, depth]);
      myModel();
   }
}

Note this psuedocode doesn't account for zero-width gaps. Depending on the geometry of your model you may have to create small extrusions that join each section together to prevent ZWGs. Another approach might be to sweep the cube() up your model, use projection() to turn that section into 2D, and then use Parkinbot's approach.

Cheers,
Max

On Sun, Dec 15, 2019 at 5:38 AM Parkinbot <[hidden email]> wrote:
If you want to scale your model only in XY, say by .9 leaving Z as it is, you
can use

scale([.9, .9, 1]) model();

but there is no conic (or even more general nonlinear) transformation in
OpenSCAD that will map a cylindric object into a truncated cone object or
similar.

However you can extrude an object into a truncated cone object, e.g. by
using

linear_extrude(height = 10, scale = 0.9)  myModel2D();
module myModel2D() circle(10); 




--
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: flaring a model

Max Bond
Hi Bryan,

I got nerdsniped by this problem and had a pleasant Sunday evening writing a solution to it.

The code needs to be cleaned up, it's slow (because it uses resize()), and I haven't tested it on complex models yet, but it should do what you want it to do.

I'm goin

On Sun, Dec 15, 2019 at 3:24 PM Max Bond <[hidden email]> wrote:
*but it should work.

On Sun, Dec 15, 2019 at 3:23 PM Max Bond <[hidden email]> wrote:
There's nothing you can do with multmatrix() that you can't do with a series of other transformations (rotate(), translate(), scale(), etc). All it really lets you do is apply multiple transformations at once, which, if you ask me, only serves to obscure the programmer's intentions. Look into Affine transformations if you'd like more information.

If Parkinbot's suggeston doesn't work for your particular use case (and it sounds like you're stuck in 3D since you're using import()), you might try cutting your model into pieces by sweeping across it with a thin cube(), and then scaling these pieces & union()'ing them together. It'll be tricky, and you'll have to be careful so as not to create zero-width gaps, but

Something to the effect of:

function f(h) = ...some function defining your flare (reciprocal function perhaps)...
for (i=[0:depth:myModelHeight/depth]) {
   scale([f(i), f(i), 1]) intersection() {
      translate([0, 0, i]) cube([modelX, modelY, depth]);
      myModel();
   }
}

Note this psuedocode doesn't account for zero-width gaps. Depending on the geometry of your model you may have to create small extrusions that join each section together to prevent ZWGs. Another approach might be to sweep the cube() up your model, use projection() to turn that section into 2D, and then use Parkinbot's approach.

Cheers,
Max

On Sun, Dec 15, 2019 at 5:38 AM Parkinbot <[hidden email]> wrote:
If you want to scale your model only in XY, say by .9 leaving Z as it is, you
can use

scale([.9, .9, 1]) model();

but there is no conic (or even more general nonlinear) transformation in
OpenSCAD that will map a cylindric object into a truncated cone object or
similar.

However you can extrude an object into a truncated cone object, e.g. by
using

linear_extrude(height = 10, scale = 0.9)  myModel2D();
module myModel2D() circle(10); 




--
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: flaring a model

Max Bond
Oops, I accidentally hit send.

I'm going to clean this code up & release it on GitHub, and I haven't decided on a license yet, but this draft is licensed CC0 & you can use it in your project if you wish. Attribution would be nice but isn't strictly necessary.

The module assumes that your model is centred at the origin. It sweeps down the object, starting from the top, and takes a 2D slice, which it scales to a particular size. You'll need to write a function that maps the height to a vector with the size of the 2D bounding box at that height (e.g. [[height1, [x1, y1,], [height2, [x2, y2]]...] ). You'll want to play with different values of precision as well. Lower values = more precise.

In the code is a simple example which turns a cylinder into an exponential flare.

As I said, I haven't tested it extensively, but it appears to be outputting manifold models.

Cheers,
Max

On Sun, Dec 15, 2019 at 7:57 PM Max Bond <[hidden email]> wrote:
Hi Bryan,

I got nerdsniped by this problem and had a pleasant Sunday evening writing a solution to it.

The code needs to be cleaned up, it's slow (because it uses resize()), and I haven't tested it on complex models yet, but it should do what you want it to do.

I'm goin

On Sun, Dec 15, 2019 at 3:24 PM Max Bond <[hidden email]> wrote:
*but it should work.

On Sun, Dec 15, 2019 at 3:23 PM Max Bond <[hidden email]> wrote:
There's nothing you can do with multmatrix() that you can't do with a series of other transformations (rotate(), translate(), scale(), etc). All it really lets you do is apply multiple transformations at once, which, if you ask me, only serves to obscure the programmer's intentions. Look into Affine transformations if you'd like more information.

If Parkinbot's suggeston doesn't work for your particular use case (and it sounds like you're stuck in 3D since you're using import()), you might try cutting your model into pieces by sweeping across it with a thin cube(), and then scaling these pieces & union()'ing them together. It'll be tricky, and you'll have to be careful so as not to create zero-width gaps, but

Something to the effect of:

function f(h) = ...some function defining your flare (reciprocal function perhaps)...
for (i=[0:depth:myModelHeight/depth]) {
   scale([f(i), f(i), 1]) intersection() {
      translate([0, 0, i]) cube([modelX, modelY, depth]);
      myModel();
   }
}

Note this psuedocode doesn't account for zero-width gaps. Depending on the geometry of your model you may have to create small extrusions that join each section together to prevent ZWGs. Another approach might be to sweep the cube() up your model, use projection() to turn that section into 2D, and then use Parkinbot's approach.

Cheers,
Max

On Sun, Dec 15, 2019 at 5:38 AM Parkinbot <[hidden email]> wrote:
If you want to scale your model only in XY, say by .9 leaving Z as it is, you
can use

scale([.9, .9, 1]) model();

but there is no conic (or even more general nonlinear) transformation in
OpenSCAD that will map a cylindric object into a truncated cone object or
similar.

However you can extrude an object into a truncated cone object, e.g. by
using

linear_extrude(height = 10, scale = 0.9)  myModel2D();
module myModel2D() circle(10); 




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

resizeSweep.scad (2K) Download Attachment
Screenshot from 2019-12-15 20-23-15.png (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: flaring a model

thehans
In reply to this post by Max Bond

On Sun, Dec 15, 2019 at 4:24 PM Max Bond <[hidden email]> wrote:
There's nothing you can do with multmatrix() that you can't do with a series of other transformations (rotate(), translate(), scale(), etc). 

Mostly true, (and I realize this doesn't help for the original question) but I gotta point out that shear/skew transformations are currently only possible using multmatrix().

 

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

Re: flaring a model

lar3ry
In reply to this post by Max Bond
On 15 Dec 2019 at 19:57, Max Bond wrote:
> Hi Bryan,
> I got nerdsniped by this problem and had a pleasant Sunday evening writing a solution to it.

Hah! I never heard that word before, but it is SO apt. I get nerdsniped all the time. Just this
afternoon I ended up writing a long tutorial on some operations in Inkscape. Yesterday it was
a problem on an Arduino running a WiFi module.

Thanks for the chuckle!


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

Re: flaring a model

Max Bond
In reply to this post by thehans


On Sun, Dec 15, 2019 at 10:07 PM Hans L <[hidden email]> wrote:

On Sun, Dec 15, 2019 at 4:24 PM Max Bond <[hidden email]> wrote:
There's nothing you can do with multmatrix() that you can't do with a series of other transformations (rotate(), translate(), scale(), etc). 

Mostly true, (and I realize this doesn't help for the original question) but I gotta point out that shear/skew transformations are currently only possible using multmatrix().


Good point, I hadn't thought of that.
 
_______________________________________________
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: flaring a model

Max Bond
In reply to this post by lar3ry


On Sun, Dec 15, 2019 at 10:11 PM <[hidden email]> wrote:
On 15 Dec 2019 at 19:57, Max Bond wrote:
> Hi Bryan,
> I got nerdsniped by this problem and had a pleasant Sunday evening writing a solution to it.

Hah! I never heard that word before, but it is SO apt. I get nerdsniped all the time. Just this
afternoon I ended up writing a long tutorial on some operations in Inkscape. Yesterday it was
a problem on an Arduino running a WiFi module.

Thanks for the chuckle!


Anytime :) Here's another https://www.xkcd.com/356/
 
_______________________________________________
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: flaring a model

cacb
In reply to this post by Max Bond
On 15.12.2019 23:23, Max Bond wrote:
> There's nothing you can do with multmatrix() that you can't do with a
> series of other transformations (rotate(), translate(), scale(), etc).

That's not entirely true. You can skew transform with multmatrix, you
cannot do that with the other transformations. In theory you could also
do a perspective transformation (bottom row), but it is disabled in
OpenSCAD.

Carsten Arnholm



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

Re: flaring a model

Ronaldo
In fact, with a perspective transform, Max Bond code might avoid the expensive projection() by cutting a model slice (is this less expensive?) and transforming it directly with multmatrix(). 

Em seg., 16 de dez. de 2019 às 19:03, Carsten Arnholm <[hidden email]> escreveu:
On 15.12.2019 23:23, Max Bond wrote:
> There's nothing you can do with multmatrix() that you can't do with a
> series of other transformations (rotate(), translate(), scale(), etc).

That's not entirely true. You can skew transform with multmatrix, you
cannot do that with the other transformations. In theory you could also
do a perspective transformation (bottom row), but it is disabled in
OpenSCAD.

Carsten Arnholm


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

Re: flaring a model

doug.moen
In reply to this post by cacb
Speaking of nerdsniping:
You can perform a skew by composing rotate() with scale().

Doug.

On Mon, Dec 16, 2019, at 7:01 PM, Carsten Arnholm wrote:

> On 15.12.2019 23:23, Max Bond wrote:
> > There's nothing you can do with multmatrix() that you can't do with a
> > series of other transformations (rotate(), translate(), scale(), etc).
>
> That's not entirely true. You can skew transform with multmatrix, you
> cannot do that with the other transformations. In theory you could also
> do a perspective transformation (bottom row), but it is disabled in
> OpenSCAD.
>
> Carsten Arnholm
>
>
>
> _______________________________________________
> 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