discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Trying to incorporate equation based shapes.

R
Ronaldo
Mon, Mar 21, 2016 1:44 AM

As your airfoil is convex the hull() certainly works. Try this:

// Draw a NACA airfoil

function yt (x,c,t) =
t/0.2c(0.2969sqrt(x/c)-0.126(x/c)-0.3516pow(x/c,2)+0.2843pow(x/c,3)-0.1015*pow(x/c,4));

module airfoil (c,t,m){
p  = concat([ for(i=[m-1:-1:0])
[ cii/(m-1)/(m-1),  yt(cii/(m-1)/(m-1), c, t) ] ],
[ for(i=[0:m-1])
[ cii/(m-1)/(m-1), -yt(cii/(m-1)/(m-1), c, t) ] ]);

rotate([90,0,0]) linear_extrude(0.01)
polygon( p );
}

module blend_airfoils(c1,t1,c2,t2,y,n){
hull (){
airfoil(c1,t1,n);
translate([0,y,0]) airfoil(c2,t2,n);
}
}

blend_airfoils(70,0.1,50,0.2,200,20);

--
View this message in context: http://forum.openscad.org/Trying-to-incorporate-equation-based-shapes-tp3116p16616.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

As your airfoil is convex the hull() certainly works. Try this: // Draw a NACA airfoil function yt (x,c,t) = t/0.2*c*(0.2969*sqrt(x/c)-0.126*(x/c)-0.3516*pow(x/c,2)+0.2843*pow(x/c,3)-0.1015*pow(x/c,4)); module airfoil (c,t,m){ p = concat([ for(i=[m-1:-1:0]) [ c*i*i/(m-1)/(m-1), yt(c*i*i/(m-1)/(m-1), c, t) ] ], [ for(i=[0:m-1]) [ c*i*i/(m-1)/(m-1), -yt(c*i*i/(m-1)/(m-1), c, t) ] ]); rotate([90,0,0]) linear_extrude(0.01) polygon( p ); } module blend_airfoils(c1,t1,c2,t2,y,n){ hull (){ airfoil(c1,t1,n); translate([0,y,0]) airfoil(c2,t2,n); } } blend_airfoils(70,0.1,50,0.2,200,20); -- View this message in context: http://forum.openscad.org/Trying-to-incorporate-equation-based-shapes-tp3116p16616.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
Ronaldo
Mon, Mar 21, 2016 4:14 AM

Or even better:

module blend_airfoils(y){
hull (){
children(0);
translate([0,y,0]) children(1);
}
}

blend_airfoils(200) {
airfoil(70,0.20,30);
airfoil(45,0.1,30);
}

--
View this message in context: http://forum.openscad.org/Trying-to-incorporate-equation-based-shapes-tp3116p16620.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Or even better: module blend_airfoils(y){ hull (){ children(0); translate([0,y,0]) children(1); } } blend_airfoils(200) { airfoil(70,0.20,30); airfoil(45,0.1,30); } -- View this message in context: http://forum.openscad.org/Trying-to-incorporate-equation-based-shapes-tp3116p16620.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Mon, Mar 21, 2016 11:41 AM

Using @Parkinbot's approach. Something like this:

use <naca4.scad>
use <Naca_sweep.scad>
num_points = 100;
airfoil1 = vec3D(airfoil_data(0015, 110, num_points), 0); // NACA, length,
numsamples
airfoil2 = vec3D(airfoil_data(1733, 110, num_points), 20);
airfoil3 = vec3D(airfoil_data(2418, 110, num_points), 40);
// airfoil4 = T_(0,0,80, vec3D(airfoil_data(0015, 130, num_points)));
data = [airfoil1, airfoil2, airfoil3];
sweep(data);
http://forum.openscad.org/file/n16625/2vv5rg5.jpg
The advantage being that airfoil_data() takes a 4-digit NACA number directly
and includes all the non-symmetrical ones.

@Parkinbot does use a different approach which allows you to rotate,scale,
and translate the curves prior to assembly. See airfoil4 for putting the
translation outside the vec_3D().
So making twisted blades like boat propellers is possible in a somewhat
complex description. See his thingiverse for excellent examples.

So to be slightly clearer:

  1. airfoil_data() takes the special 4 digit NACA rep which you can read
    about here:
  1. The Vec3D() function turns the pairs into triplets (I used optional Z arg
    in first 3 airfoils)

  2. Further transforms can be applied (I used Translate which is T_() in
    @parkinbot's approach, in airfoil4)

  3. The resulting list is a transformed sequence of coords suitable for
    sweeping or skinning together.
    @parkinbot's Naca_sweep.scad includes a function sweep() to do this but the
    skin() from elsewhere also works.

The missing part is a splined curve through the airfoils.
To do this you need to play with @Parkinbot's spline functions - referenced
above in his post...

I believe you could call this code approach idiosyncratic but it's effective
at describing a complex series of swept curves in a concise way.

IMHO incorporating these ideas into a module that was consistent across
openSCAD (such as the MCAD module which seem slike it has many unmerged pull
requests) and using the same approach everywhere means we could all benefit
from a NACA lib. (and spline interp, and lofting, etc... All old threads it
would be great to actually resolve in the current design as well as
openSCAD2...)
YMMV, as usual

--
View this message in context: http://forum.openscad.org/Trying-to-incorporate-equation-based-shapes-tp3116p16625.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Using @Parkinbot's approach. Something like this: use <naca4.scad> use <Naca_sweep.scad> num_points = 100; airfoil1 = vec3D(airfoil_data(0015, 110, num_points), 0); // NACA, length, numsamples airfoil2 = vec3D(airfoil_data(1733, 110, num_points), 20); airfoil3 = vec3D(airfoil_data(2418, 110, num_points), 40); // airfoil4 = T_(0,0,80, vec3D(airfoil_data(0015, 130, num_points))); data = [airfoil1, airfoil2, airfoil3]; sweep(data); <http://forum.openscad.org/file/n16625/2vv5rg5.jpg> The advantage being that airfoil_data() takes a 4-digit NACA number directly and includes all the non-symmetrical ones. @Parkinbot does use a different approach which allows you to rotate,scale, and translate the curves prior to assembly. See airfoil4 for putting the translation outside the vec_3D(). So making twisted blades like boat propellers is possible in a somewhat complex description. See his thingiverse for excellent examples. So to be slightly clearer: 1. airfoil_data() takes the special 4 digit NACA rep which you can read about here: - https://en.wikipedia.org/wiki/NACA_airfoil - http://www.pdas.com/naca456pdas.html - would be great to do ALL of these. and extracts the fields for chord ratios etc and then creates the curve as pairs of [X,Y] coordinates. 2. The Vec3D() function turns the pairs into triplets (I used optional Z arg in first 3 airfoils) 3. Further transforms can be applied (I used Translate which is T_() in @parkinbot's approach, in airfoil4) 4. The resulting list is a transformed sequence of coords suitable for sweeping or skinning together. @parkinbot's Naca_sweep.scad includes a function sweep() to do this but the skin() from elsewhere also works. The missing part is a splined curve through the airfoils. To do this you need to play with @Parkinbot's spline functions - referenced above in his post... I believe you could call this code approach idiosyncratic but it's effective at describing a complex series of swept curves in a concise way. IMHO incorporating these ideas into a module that was consistent across openSCAD (such as the MCAD module which seem slike it has many unmerged pull requests) and using the same approach everywhere means we could all benefit from a NACA lib. (and spline interp, and lofting, etc... All old threads it would be great to actually resolve in the current design as well as openSCAD2...) YMMV, as usual -- View this message in context: http://forum.openscad.org/Trying-to-incorporate-equation-based-shapes-tp3116p16625.html Sent from the OpenSCAD mailing list archive at Nabble.com.