Bird wing kinematics

float r1=200; // size of a first segment
float r2=150; // size of a second segment
float a1; // angle one
float a2; // angle two
float w=0; // angular velocity
float A= 175; // amplitude half elipse hight (r1+r2)/2
float b= 75; // half elipse width (r2/2)
float cx= 275; // elipse center (r1+b)
float x;

void setup() {

size(600, 600);
}
void draw() {
display();
render();
}

void display () {
background(255);

stroke(0);
strokeWeight(2);
translate(50, 300);

float x1= r1 * cos (a1);
float y1= r1 * sin(a1);
float x2 = x1+ r2 * cos (a2);
float y2 = y1+ r2 * sin(a2);

circle (0, 0, 5);
line (0, 0, x1, y1);
circle (x1, y1, 5);
line (x1, y1, x2, y2);

noFill ();
strokeWeight (1);
ellipse (cx, 0, 2b, 2A);
}

void render () {

w+=0.01;

float y= A * sin (w);
float dx= b * cos (w);
float x= cx+dx;
float Q1 = tan(y/x); // (+44) > (-44)
float h = y * sin(Q1) + x * cos(Q1); // (200 < 350)

float Q2 = cos ((sq(r2)+sq(h)-sq(r1))/2r2h);
float Q3 = cos ((sq(r1)+sq(h)-sq(r2))/2r1h);

a1=Q1+Q3;
a2=Q1-Q2;

triangle (0, 0, x, y, x, 0);

// println(Q1*(180/PI));
//println (h);
//println(Q3*(180/PI));
//println (Q2*(180/PI));
}Preformatted text

Hi
please can some one help me find error in this code
thanke you

Hey welcome.

Dont forget to format your code with </>

No, not really.

Questions: Do you have a existing code (from somewhere else) or a Wikipedia article where you come from we can use as a source information? So we can tell how the formulas look correctly?

And do you have an image / animation how it is supposed to look?

My first idea was you forgot to give the angles in radians, but this is not helpful

inverse kinematics
if this helps ?

Thanks for that.

But how did you name the angle in the graphic in your Sketch? I can’t see theta 1 and 2 in your code

1 Like

Theta 1 is a1 and theta 2 is a2
alpha is Q1 , beta is Q3

I can’t really help you with this, I am on a journey

Hello,

Please format your code as a courtesy to the community:
https://discourse.processing.org/faq#format-your-code
You can go back and edit it.

I had to edit your code first before I could run it.
I also corrected the spelling error in your subject.

Note the difference between these two:

float Q2 = cos ((sq(r2)+sq(h)-sq(r1))/2*r2*h); // Original

float Q2 = cos ((sq(r2)+sq(h)-sq(r1))/(2*r2*h)); // Modified

Give it a try for Q2 and Q3.

have fun :heart: :smile:

1 Like

hi
thanke you for help. I am new here and just learning things . Sory for mistakes i made.