Joined Jul 2005
2,091 Posts

Hey Odysis,
I am writing a Visual C# code that generates the shape based on mathematical equations. The slope is just one of many parameters that can be altered anytime. The goal is to write a program that generates arbitrary props/fans based on parameters like slope, diameter, width, airfoil, twist... Also, I want to test different variants to find the sweet spot of a micro fan. The perfect blade shape I believe you get when you roll the airfoil onto a cylinder surface and control the slope as a function of radius.
What about the shapeways issues?? The 10mm fans I got were great. In fact, an airfoil needs to be adapted to have a certain thickness at the trailing edge, otherwise you will always get issues. What problems did you have?
Chris
using System;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
protected override void OnPaint(PaintEventArgs paintEvnt)
{
double[] yt = new double[35] { 0.0000000f, 0.0007400f, 0.0020500f, 0.0040100f, 0.0072501f, 0.0101101f, 0.0159602f, 0.0218602f, 0.0276603f, 0.0333003f, 0.0386704f, 0.0437004f, 0.0482705f, 0.0523105f, 0.0557406f, 0.0585106f, 0.0605606f, 0.0618406f, 0.0623106f, 0.0619406f, 0.0606906f, 0.0585006f, 0.0552506f, 0.0509405f, 0.0456905f, 0.0397704f, 0.0336203f, 0.0275703f, 0.0218302f, 0.0165302f, 0.0116701f, 0.0071601f, 0.0033300f, 0.0009300f, 0.0001700f };
double[] xt = new double[35] { 0.0000000f, 0.0000900f, 0.0007100f, 0.0022600f, 0.0060001f, 0.0105801f, 0.0232502f, 0.0406604f, 0.0627206f, 0.0892309f, 0.1198912f, 0.1543615f, 0.1923019f, 0.2333023f, 0.2769428f, 0.3227532f, 0.3702637f, 0.4189842f, 0.4683847f, 0.5179552f, 0.5671857f, 0.6155261f, 0.6625966f, 0.7080970f, 0.7517775f, 0.7934279f, 0.8326283f, 0.8688086f, 0.9013990f, 0.9298793f, 0.9537596f, 0.9728698f, 0.9873199f, 0.9966900f, 1.0000000f };
double[] yb = new double[33] { 0.0000000f, .0007200f, .0019000f, .0036000f, .0062501f, .0083701f, .0126101f, .0165302f, .0200702f, .0232402f, .0259903f, .0282703f, .0300003f, .0310903f, .0313703f, .0306303f, .0287603f, .0257803f, .0218802f, .0175402f, .0131101f, .0088901f, .0051001f, .0019100f, 0.0005700f, 0.0022600f, 0.0031800f, 0.0033800f, 0.0030200f, 0.0022800f, 0.0013600f, 0.0005300f, 0.0001700f };
double[] xb = new double[33] { 0.0000000f, 0.0002500f, 0.0011500f, 0.0031300f, 0.0076201f, 0.0126801f, 0.0268403f, 0.0459705f, 0.0699307f, 0.0984610f, 0.1312113f, 0.1677617f, 0.2076921f, 0.2505225f, 0.2957530f, 0.3430134f, 0.3920439f, 0.4425844f, 0.4944449f, 0.5472355f, 0.6002760f, 0.6528665f, 0.7042770f, 0.7537276f, 0.8004881f, 0.8437984f, 0.8829688f, 0.9173292f, 0.9462994f, 0.9694097f, 0.9862698f, 0.9965400f, 1.0000000f };
double[,] x = new double[100, 100];
double[,] y = new double[100, 100];
double[,] z = new double[100, 100];
double ox = 0.33333333;
double oy = 0;
double a = .3;
double r;
int nt = 35;
int nb = 33;
int n, j, i;
int x0 = 600;
int y0 = 300;
string sx1, sy1, sz1, sx2, sy2, sz2, sx3, sy3, sz3, sx4, sy4, sz4, snx, sny, snz;
double b, nx, ny, nz, ax, bx,ay,by,az,bz;
n = nt + nb  1;
//urrippe
a = 0;
for (i = nt  1; i >= 0; i = i  1)
{
x[0, nt  i  1] = (xt[i] * Math.Cos(a) + yt[i] * Math.Sin(a)) + ox;
y[0, nt  i  1] = (xt[i] * Math.Sin(a) + yt[i] * Math.Cos(a)) + oy;
z[0, nt  i  1] = 0;
}
for (i = 0; i < nb; i = i + 1)
{
x[0, nt + i  1] = (xb[i] * Math.Cos(a) + yb[i] * Math.Sin(a)) + ox;
y[0, nt + i  1] = (xb[i] * Math.Sin(a) + yb[i] * Math.Cos(a)) + oy;
z[0, nt + i  1] = 0;
}
for (j = 1; j <= 90; j = j + 1)
{
a = .8 / ((double)j / 90 + 1);
r = .4 * ((double)j / 90 + 1);
for (i = 0; i < n; i = i + 1)
{
x[j, i] = (x[0, i] * Math.Cos(a) + y[0, i] * Math.Sin(a)) + ox;
y[j, i] = (x[0, i] * Math.Sin(a) + y[0, i] * Math.Cos(a)) + oy;
b = x[j, i] / r;
z[j, i] = Math.Cos(b) * r;// / (double)j;
x[j, i] = Math.Sin(b) * r;// / (double)j;
}
}
//
label1.Text = yt[0].ToString();
// Get the graphics object
Graphics gfx = paintEvnt.Graphics;
// Create a new pen that we shall use for drawing the line
Pen myPen = new Pen(Color.DarkBlue);
// Loop and create a new line 10 pixels below the last one
for (i = 00; i <= 900; i = i + 1)
{
gfx.DrawLine(myPen, 0, i, 1600, i);
}
Pen myPen2 = new Pen(Color.White);
CultureInfo USCulture = new CultureInfo("enUS");
try
{
System.IO.TextWriter writeFile = new StreamWriter("C:\\Blade.stl");
writeFile.WriteLine("solid Blade");
writeFile.WriteLine("");
for (j = 1; j <= 89; j++)
{
for (i = 1; i < n; i++)
{
gfx.DrawLine(myPen2, (int)(x[j, i] * 1000f + x0), (int)(y[j, i] * 1000f + y0 + z[j, i]), (int)(x[j, i  1] * 1000f + x0), (int)(y[j, i  1] * 1000f + y0 + z[j, i  1]));
gfx.DrawLine(myPen2, (int)(x[j + 1, i] * 1000f + x0), (int)(y[j + 1, i] * 1000f + y0 + z[j + 1, i]), (int)(x[j + 1, i  1] * 1000f + x0), (int)(y[j + 1, i  1] * 1000f + y0 + z[j + 1, i]));
gfx.DrawLine(myPen2, (int)(x[j, i] * 1000f + x0), (int)(y[j, i] * 1000f + y0 + z[j, i]), (int)(x[j + 1, i] * 1000f + x0), (int)(y[j + 1, i] * 1000f + y0 + z[j + 1, i]));
sx1 = x[j, i  1].ToString("#.00000000", USCulture);
sy1 = y[j, i  1].ToString("#.00000000", USCulture);
sz1 = z[j, i  1].ToString("#.00000000", USCulture);
sx2 = x[j + 1, i  1].ToString("#.00000000", USCulture);
sy2 = y[j + 1, i  1].ToString("#.00000000", USCulture);
sz2 = z[j + 1, i  1].ToString("#.00000000", USCulture);
sx3 = x[j, i].ToString("#.00000000", USCulture);
sy3 = y[j, i].ToString("#.00000000", USCulture);
sz3 = z[j, i].ToString("#.00000000", USCulture);
sx4 = x[j + 1, i].ToString("#.00000000", USCulture);
sy4 = y[j + 1, i].ToString("#.00000000", USCulture);
sz4 = z[j + 1, i].ToString("#.00000000", USCulture);
bx = x[j + 1, i  1]  x[j, i  1];
by = y[j + 1, i  1]  y[j, i  1];
bz = z[j + 1, i  1]  z[j, i  1];
ax = x[j, i]  x[j, i  1];
ay = y[j, i]  y[j, i  1];
az = z[j, i]  z[j, i  1];
nx = ay * bz  az * by;
ny = az * bx  ax * bz;
nz = ax * by  ay * bx;
snx = nx.ToString("#.00000000", USCulture);
sny = ny.ToString("#.00000000", USCulture);
snz = nz.ToString("#.00000000", USCulture);
//nx=y[j, i  1]*z[]z[j, i  1]*y[];
writeFile.WriteLine("facet normal " + snx + " " + sny + " " + snz);
writeFile.WriteLine("outer loop");
writeFile.WriteLine("vertex " + sx2 + " " + sy2 + " " + sz2);
writeFile.WriteLine("vertex " + sx1 + " " + sy1 + " " + sz1);
writeFile.WriteLine("vertex " + sx3 + " " + sy3 + " " + sz3);
writeFile.WriteLine("endloop");
writeFile.WriteLine("endfacet");
writeFile.WriteLine("facet normal " + snx + " " + sny + " " + snz);
//writeFile.WriteLine("facet normal 0.0 0.0 0.0");
writeFile.WriteLine("outer loop");
writeFile.WriteLine("vertex " + sx2 + " " + sy2 + " " + sz2);
writeFile.WriteLine("vertex " + sx4 + " " + sy4 + " " + sz4);
writeFile.WriteLine("vertex " + sx3 + " " + sy3 + " " + sz3);
writeFile.WriteLine("endloop");
writeFile.WriteLine("endfacet");
}
}
writeFile.WriteLine("");
writeFile.WriteLine("endsolid");
writeFile.Flush();
writeFile.Close();
writeFile = null;
}
catch (IOException ex)
{
MessageBox.Show(ex.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string line = null;
System.IO.TextReader readFile = new StreamReader("C:\\Users\\Andre\\Documents\\Blade.s tl");
while (true)
{
line = readFile.ReadLine();
if (line != null)
{
MessageBox.Show(line);
}
}
readFile.Close();
readFile = null;
}
catch (IOException ex)
{
MessageBox.Show(ex.ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}
