Trigonometry
- maiguzman28
- Jun 4, 2020
- 2 min read
Updated: Jul 16, 2020
I am still not sure if it's a good idea to start with this. But I have lots of questions about the functions excercises and I decided to use the time in this.

Funny thing... Trigonometry... I actually failed math in school, so just by hearing the name it really scares me. I had hoped I left math behind me in school. But no...
I had compeltely forgotten about this:
• soh: sine opposite/hypotenuse
• cah: cosine adjacent/hypotenuse
• toa: tangent opposite/adjacent

And about this point I really want to start crying:
sine(theta) y/r → y r * sine(theta)
cosine(theta) x/r → x r * cosine(theta)

I really spent a lot of time trying to do this one, and I really had to rely on my classmates because some of them already did this excercises. Since I am not a logical person at all, I found it very, very challenging.
But it worked!!!

This looked very funny, but it was on the right direction. So I started changing values and it really worked!


The second excercise I find very complicated. This happened:

And then, when I changed the i for a j in the funciton, this happened:


This does not look right.
After asking for help I understood that I was mixing it all up in radiens. So it finally worked:

Changing the values a little bit it looks like this:

void setup() {
size(800, 800);
background(255);
for (int i=0; i<800; i+=100){
for (int j=0; j<360; j+=40){
int x = (int)(cos(radians(j))*(10+i))+400;
int y = (int)(sin(radians(j))*(10+i))+400;
//this ellipse is the big circle of a virus
//body of corona
stroke(185,20,0);
strokeWeight(2);
fill(255, 115, 0);
ellipse(x,y,100,100);
// corona arms, there are two different sizes, so I just switched between the two of them
stroke(185,20,0);
strokeWeight(2);
fill(255,60,0);
ellipse(x,y,20,20);
ellipse(x-25,y-15,12,12);
ellipse(x-35,y+27,20,20);
ellipse(x+30,y+15,12,12);
ellipse(x+35,y-35,20,20);
ellipse(x+45,y+45,12,12);
ellipse(x-65,y,20,20);
ellipse(x-35,y+55,12,12);
ellipse(x,y+65,20,20);
ellipse(x,y-65,12,12);
ellipse(x+65,y,20,20);
ellipse(x-45,y-45,12,12);
}
}
}
The next one:
This one I found surprisinly ok.
void setup() {
size(800, 800);
background(255);
//this loop is to place several viruses in a
//circular shape
for (int r=0; r<360; r=r+1) {
for (int c=0; c<360; c=c+10) {
int x = (int)(cos(radians(c))*r)+400;
int y = (int)(sin(radians(c))*r)+400;
//this ellipse is the big circle of a virus
//body of corona
stroke(185,20,0);
strokeWeight(2);
fill(255, 115, 0);
ellipse(x,y,100,100);
// corona arms, there are two different sizes, so I just switched between the two of them
stroke(185,20,0);
strokeWeight(2);
fill(255,60,0);
ellipse(x,y,20,20);
ellipse(x-25,y-15,12,12);
ellipse(x-35,y+27,20,20);
ellipse(x+30,y+15,12,12);
ellipse(x+35,y-35,20,20);
ellipse(x+45,y+45,12,12);
ellipse(x-65,y,20,20);
ellipse(x-35,y+55,12,12);
ellipse(x,y+65,20,20);
ellipse(x,y-65,12,12);
ellipse(x+65,y,20,20);
ellipse(x-45,y-45,12,12);
c+=20;
r+=20;
}
}
}


Incresing the value of c and r makes the spiral bigger.
All in all I found this ok. It was doable, I only worked four hours on this, so comparing it to the time I invested in other assignments this was easy. The problem that I have with this, it I don't know how well I can retain this information. I think trigonometry is something that I will have to look over and see how I did it whenever I need it. It was less scary than I thought, but still was complicated. A lot, a lot of try and error and not a lot of explanations.
Comments