I’m playing around with PixelFlow and the Wind Tunnel LIC example. I went to UUIC airfoil database and grabbed the coordinates for the Eppler 193 airfoil which is a good one for model airplanes. I wrote a little sketch to read the coordinates and draw them. I used the only method I know for drawing from point to point and to my amazement, it drew an airfoil.
I took that code and inserted it into the PixelFlow example and was again amazed. The problem is there are 60 coordinates and it doesn’t connect the dots exactly right. If I use a strokeWeight of 1, then the fluid finds ways to get inside the airfoil, so it doesn’t see it as solid. I upped the strokeWeight to 4 and it stopped but it just isn’t quite right.
looks impressive,
can you tell me why you need to do 60 little shapes instead
one shape with the for …60 vertex inside?
and if you miss the last point ( = first point ) could do a
endShape(CLOSE);
and for the structure, see
can do a create shape in setup and a
draw shape ( width/2.height/2) in draw,
so no need to do that absolute in the create shape
I don’t know, really. I’m a code klutz and everything is a struggle for me. I’m all ears if you have a better way to draw a shape. I do know airfoils vary in subtle ways and small changes can make a big difference in lift and drag for a given condition.
Holey moley, that’s good. That’s a much better way, wow.
Aww shucks, except it wont work with the way PixelFlow draws obstacles. The klunky way I did it actually worked for some reason I don’t know. PixelFlow uses processing.opengl.PGraphics2D somehow to make the obstacles. I can draw a PShape but the fluid doesn’t see it.
Here’s an example of how a fluid-visible obstacle is made:
It looks to me like (PGraphics2D) is a cast? Yup it casts PGraphics to PGraphics2D. I tried casting PShape to PGraphics and PGraphics2D and it doesn’t allow that.
I got it working. I draw the PShape while within the PGraphics2D. I rewrote one of the functions in the Wind_Tunnel_LIC example, with a lot of help, thanks. Here it is:
public void resetObstacles(){
float dimxy = 2 * height/3f;
float th = 20;
load_file();
for (int i = 0; i < coordinates.length; i++) {
pg_obstacles_drawing.beginDraw();
pg_obstacles_drawing.beginDraw();
pg_obstacles_drawing.clear();
pg_obstacles_drawing.noStroke();
pg_obstacles_drawing.fill(255);
pg_obstacles_drawing.rectMode(CENTER);
s = createShape();
s.beginShape();
s.fill(125);
for ( i = 0; i<coordinates.length; i++) s.vertex(700*x[i]-500, -700*y[i]+50);
s.rotate(radians(7));
s.endShape(CLOSE);
shape(s,width/2,height/2);
pg_obstacles_drawing.endDraw();
pg_obstacles_drawing.endDraw();
}
}
One last note, even this PShape with noFill and a strokeWeight of 2 has Holes in it and the fluid will find a way inside. I find that ironic that the Holes were why I wanted to improve it and theyre still there. The airfoil is drawn more accurately, however, and that was needed.
Yeah, the extra begin and end were a mistake. It was late. The extra for loop isn’t necessary either. I need to learn to clean up the code before I post it. Thanks for the help, @kll