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