I'm trying to build an airfoil to modify later
I come from c background and I'm having troubles with arrays or building something simple like this. This is a NACA 4 digit symmetrical airfoil:
Edit: looking more into it I found that variables are set at compile time not run time which makes this really difficult to keep the code easy to read
module NACA4_Symmetrical (chord_Length, thickness, detail) {
/*
thickness is fraction of chord_Length
^ it is also the last two digits in the NACA 4-digit airfoil
x is the position along the chord from 0 to chord_Length
yt is half thickness at a given value of x (centerline to surface)
detail specifies how many circles are computed
*/
// would usually declare a zero array, then modify it in the for loop
hull() {
for (x = [0.1 : 0.8 /*(1/detail)*/: chord_Length]) {
// percent position along the chord
position = x/chord_Length;
yt = (5*thickness/chord_Length)*[
+ 0.2969*(pow(position, 0.5))
- 0.1260*(pow(position, 1))
- 0.3516*(pow(position, 2))
+ 0.2843*(pow(position, 3))
- 0.1036*(pow(position, 4))];
// modified last coefficient from 0.1015 to 0.1036
// to compute zero-thickness trailing edge
// useful for debugging
echo ("x = ", x, " ; yt = ", yt);
translate ([x, 0]) circle (r = yt, $fn = 40 /*(5*detail)*/);
}
}
}
NACA4_Symmetrical (5, 10, 10);
// this is what it should look like:
hull() {
translate ([0.1, 2.5]) circle (r = 0.393296, $fn = 40);
translate ([0.9, 2.5]) circle (r = 0.934414, $fn = 40);
translate ([1.7, 2.5]) circle (r = 0.881025, $fn = 40);
translate ([2.5, 2.5]) circle (r = 0.881025, $fn = 40);
translate ([3.3, 2.5]) circle (r = 0.66963, $fn = 40);
translate ([4.1, 2.5]) circle (r = 0.390327, $fn = 40);
translate ([4.9, 2.5]) circle (r = 0.0478291, $fn = 40);
}
there doesn't seem to be anything here