Hello everyone
I try to code a little sketch that allows me to visualize the linkage between the wings and the crankshaft of a plane with flapping wings.
For now I have “done” this allows me according to some configuration to have something that “works”.
I would like to be able to do something more eficace and also the display will be done more quickly.
According to the settings the connectingrods change length during the race …
Here is what I have (a revolution for the elements to be put in place):
float x =0;
float course= 25;
float a= 40; // distance bielle pivot d'aile
float Bielle=80; // longueur de la bielle
float Angle = 40; // angle de décalage entre deux mannetons
float AxeAile=10; //distance du pivot de l'aile depuis l'axe
float Dist_Pivot_Vilo=75;
float H=0;
float c=0;
int i=1;
int D=0;
int G=90;
float old_DD=0;
float old_DG=0;
float old_BielleD=0;
float old_BielleG=0;
int sens = 1;
void setup() {
size(600, 600); //
frameRate(25);
background(255);
strokeWeight(.2);
stroke(0);
noFill();
smooth();
}
void draw() {
scale(1.5);
background(255);
translate(200, 300);
strokeWeight(.01);
stroke(0);
//axes
ellipse(0, 0, course, course); // course maneton vilebrequin
line(0, 70, 0, -150); // axe vertical vilebrequin
line(70, 0, -70, 0); // axe horizontal vilebrequin
line(70, -Dist_Pivot_Vilo, -70, -Dist_Pivot_Vilo); // axe horizontal pivot d'ailes
line(AxeAile, -Dist_Pivot_Vilo+15, AxeAile, -Dist_Pivot_Vilo-15); // axe vertical pivot d'aile droite
line(-AxeAile, -Dist_Pivot_Vilo+15, -AxeAile, -Dist_Pivot_Vilo-15); // axe vertical pivot d'aile gauche
strokeWeight(.5);
stroke(255, 176, 18);
// orange droite
ellipse (course/2*sin(radians(-270+i)), course/2*cos(radians(-270+i)), 5, 5);
PVector WingD = new PVector(AxeAile+a/2*sin(radians(sens*-270+D)), -Dist_Pivot_Vilo+ a/2*cos(radians(-270+D)));
PVector WingG = new PVector(AxeAile+a/2*sin(radians(-sens*270+G)), -Dist_Pivot_Vilo+ a/2*cos(radians(270+G)));
PVector MannetonD = new PVector(course/2*sin(radians(-270+i)), course/2*cos(radians(-270+i)));
PVector MannetonG = new PVector(course/2*sin(radians(-270+i+Angle)), course/2*cos(radians(-270+i+Angle)));
//(course/2*sin(radians(-270+i+Angle)), course/2*cos(radians(-270+i+Angle)), 5, 5);
PVector WingAxelD = new PVector (30, -Dist_Pivot_Vilo);
PVector WingAxelG = new PVector (30, -Dist_Pivot_Vilo);
float DD = MannetonD.dist(WingAxelD);
float DG = MannetonG.dist(WingAxelG);
float BielleD = MannetonD.dist(WingD); // longueur de la bielle droite
float BielleG = MannetonG.dist(WingG); // longueur de la bielle gauche
//println ((radians(-270+i)));
println(" ");
print("D");
println(int(BielleD)); //
print("G");
println(int(BielleG));
println(" ");
print("D");
println(DD);
print("G");
println(DG);
if (BielleD>Bielle) {
D--;
}
if (BielleD<Bielle) {
D++;
}
if (old_DD > DD) {
WingD.sub(0, 0);
WingD.mult(1);
line(MannetonD.x, MannetonD.y, WingD.x, WingD.y);
ellipse (AxeAile, -Dist_Pivot_Vilo, a, a);
ellipse (WingD.x, WingD.y, 5, 5); // axe bielle d'aile
D++;
} else {
WingD.sub(0, 0);
WingD.mult(1);
line(MannetonD.x, MannetonD.y, WingD.x, WingD.y);
ellipse (AxeAile, -Dist_Pivot_Vilo, a, a);
ellipse (WingD.x, WingD.y, 5, 5); // axe bielle d'aile
D--;
}
strokeWeight(.5);
stroke(2, 201, 23);
// vert gauche
ellipse (course/2*sin(radians(-270+i+Angle)), course/2*cos(radians(-270+i+Angle)), 5, 5); // 90 pour 90º entre le violet et le bleu
if (BielleG>Bielle) {
G++;
}
if (BielleG<Bielle) {
G--;
}
if (old_DG > DG) {
WingG.sub(0, 0);
WingG.mult(1);
line(MannetonG.x, MannetonG.y, -WingG.x, WingG.y);
ellipse (-AxeAile, -Dist_Pivot_Vilo, a, a);
ellipse (-WingG.x, WingG.y, 5, 5); // axe bielle d'aile
G--;
} else {
WingG.sub(0, 0);
WingG.mult(1);
line(MannetonG.x, MannetonG.y, -WingG.x, WingG.y);
ellipse (-AxeAile, -Dist_Pivot_Vilo, a, a);
ellipse (-WingG.x, WingG.y, 5, 5); // axe bielle d'aile
G++;
}
old_BielleD = BielleD;
old_BielleG = BielleG;
old_DD = DD;
old_DG = DG;
i++;
}
You will certainly have noticed that some of the variable names are in French … I am French speaking.