# Sine and cosine tutorial

#1

So first, a circle.

To make a circle, put down a when game starts.
Next, place down a set position (explained later)
Then, put a repeat times 75 underneath.
Then do draw a trail (colour) width (width)
After that, put down a set position block.

Inside the x axis, swipe to the right, find cosine and select it.

You still with me? Good

Next, go to the times part at the start of it and pretend that it’s a set size, and choose your size.
Afterwards, go to the actual cosine block and select (self) rotation.

Now, select the y axis.
Next, go to the times part at the start of it and pretend that it’s a set size, and choose your size. Check that it’s the same size as your cosine.
Afterwards, go to the actual sine block and select (self) rotation.

Now go back up to that set position you placed at the start.
For the x axis, place the same one you did in the cosine block ( the addition, aka the x position, but add the width to it.
For the y axis, select the same one you did in the sine (the addition aka the y position

Your code should look something like this, but with your own values:

For an ellipse, do exactly the same thing as the circle, but increase and decrease the multiplication in the x axis to make it longer and shorter, and do the same in the y axis to make it higher and lower.

Now for the sine wave:

Put down a game starts.
Secondly, put down a set position to x =0 and y= the y position you want it to be subtract ten.
Afterwards, do a repeat times 205.
Inside do a draw a trail colour (colour) width (width)

For the x, do set position to (self) x position +5
For the y, add sine. For the multiplication, add how extreme you want your curve to be. Inside the actual sine, add (self) rotation. For the addition, do what you want your y position to be.
After, add a turn degrees five.

For the cosine, do the same thing, but with cosine instead of sine.
It should look the same, just turned ninety degree.

Thanks for reading and I hope this helped! @omtl

20 Likes
#3

That’s was really good! First post!

6 Likes
#4

Nice, thanks for making this second post!

4 Likes
#5

Great tutorial! nice job!

1 Like
#6

I love this, but to make it faster, you can use clones. If you do, create a clone times 90, then do when object is cloned, set pos to 100 x cos(cloneindex) x 4 + width/2, it makes it instant. (Of course, you would still need a draw block…)

3 Likes
#7

Thank you for sharing with the community.

You could also copy & paste the Set Position block from inside the Draw a Trail

4 Likes
#8

True, but sometimes it’s useful when it’s not instant.

3 Likes
#9

Great tutorial!

1 Like
#10

This is a very handy tutorial! Thank you for making it @Legendary_myth

If you don’t mind I moved the topic into the ‘math’ catagory!

2 Likes
#11

It’s fine, thanks.

1 Like