We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › 3rd: Pythagoras (to learn sin and cos)
Page Index Toggle Pages: 1
3rd: Pythagoras (to learn sin and cos) (Read 1078 times)
3rd: Pythagoras (to learn sin and cos)
Feb 5th, 2010, 12:07pm
 
hello everybody,

last but not least my 3rd project (or call it lesson) i gave to myself.
i finished it today.

the aim was clear! --->i want to get familiar with sin and cos.
and well, i succeeded.

i can recommend this to every newbie like me:

first look what happens when you push the play button
and than try to figure it out on your own. (and don't cheat! Wink)

tip: make yourself a sketch on paper and name the points with letters.

this link is very helpful too (german):

http://de.wikipedia.org/wiki/Sinus_und_Kosinus  

i can promise you, after this you realy understand sin and cos.

all the best.
ingo




Code:



//pythagoras

void setup(){
size(800, 800);
background(0, 30, 80);
stroke(255);
noFill();
strokeWeight(0.3);
smooth();


}

void draw(){

float tempAngel = 180*(0.00125*mouseX);

background(0, 30, 80);

stroke(10);
arc(width/2, 420, 300, 300, PI, TWO_PI);

stroke(255);
rect(250, 420, 300, 300);


//------------------------------- floating Point on circle

float Cx = width/2 + cos(radians(-tempAngel))*150;
float Cy = 420 + sin(radians(-tempAngel))*150;


//------------------------------- triangle

line(250, 420, Cx, Cy);
line(Cx, Cy, 550, 420);


//------------------------------- Square b

float angelA = tempAngel/2;

float b = cos(radians(angelA))*300;

float b04x = 250;
float b04y = 420;
float b01x = Cx;
float b01y = Cy;

float b02x = b01x -sin(radians(angelA))*b;
float b02y = b01y -cos(radians(angelA))*b;

float b03x = b02x -sin(radians(angelA+90))*b;
float b03y = b02y -cos(radians(angelA+90))*b;

beginShape();
vertex(b01x, b01y);
vertex(b02x, b02y);
vertex(b03x, b03y);
vertex(b04x, b04y);

endShape();


//-------------------------------- Square a

float a = cos(radians(90-angelA))*300;

float a01x = 550;
float a01y = 420;
float a04x = Cx;
float a04y = Cy;

float a02x = a01x +sin(radians(angelA+90))*a;
float a02y = a01y +cos(radians(angelA+90))*a;

float a03x = a02x -sin(radians(angelA))*a;
float a03y = a02y -cos(radians(angelA))*a;

beginShape();
vertex(a01x, a01y);
vertex(a02x, a02y);
vertex(a03x, a03y);
vertex(a04x, a04y);
endShape();

}







Re: 3rd: Pythagoras (to learn sin and cos)
Reply #1 - Feb 15th, 2010, 3:53am
 
now also on OP.

http://www.openprocessing.org/visuals/?visualID=7474

Re: 3rd: Pythagoras (to learn sin and cos)
Reply #2 - May 3rd, 2010, 6:33am
 
Thanks for sharing! You'd be surprised how much trigonometry is used to better understand certain problems involving aircraft and propulsion.  Smiley
Page Index Toggle Pages: 1