Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to use sin and cos
- RethinkingVoxels
-
Scratcher
1000+ posts
How to use sin and cos
Here's a wikipedia page that might help you.
- Homeless_Mario68
-
Scratcher
89 posts
How to use sin and cos
sin and cos (sine and cosine) are trigonometry functions, most people probably wont need them for simple projects but they can be useful if you know what they do, they take in angle degrees as their parameter
here is an example of what you can do with them
another example is that
here is an example of what you can do with them
set [angle v] to [0]this will make a sprite move in a circle with a radius of 50
repeat (360)
go to x: (([sin v] of (angle)) * [50]) y: (([cos v] of (angle)) * [50])
change [angle v] by (1)
end
another example is that
go to x: ((x position) + (([sin v] of (direction)) * (5))) y: ((y position) + (([cos v] of (direction)) * (5)))will do the same thing as
move (5) steps
- greenphone122
-
Scratcher
1 post
How to use sin and cos
move (i dont know abou sin) steps
ask [do u know sin??????] and wait
forever
say [idk about sin]
end
- MrKingofScratch
-
Scratcher
100+ posts
How to use sin and cos
One of the simplest and more common uses of the sine operator on scratch is to make animated titles!
If you look up an image of a sin wave on a graph, you'll notice two things:
1. it's a smooth curve
2. It repeats itself, and goes both up and down instead of just one direction
These properties are useful because they let use make titles that:
1. Animate smoothly
2. Animate back and forth
Here's an example project I made with this. You can look at the code and try to modify it to make your own title. This same method can also be used to make ocean waves, hoverboards, etc.
Note: the “sine x value” variable is related to the x position on a graph. Don't worry too much about this if you don't understand it, but know that it represents how far into the animation you are
If you look up an image of a sin wave on a graph, you'll notice two things:
1. it's a smooth curve
2. It repeats itself, and goes both up and down instead of just one direction
These properties are useful because they let use make titles that:
1. Animate smoothly
2. Animate back and forth
Here's an example project I made with this. You can look at the code and try to modify it to make your own title. This same method can also be used to make ocean waves, hoverboards, etc.
Note: the “sine x value” variable is related to the x position on a graph. Don't worry too much about this if you don't understand it, but know that it represents how far into the animation you are
Last edited by MrKingofScratch (April 1, 2024 03:15:41)
- kinglert
-
Scratcher
25 posts
How to use sin and cos
One of the simplest and more common uses of the sine operator on scratch is to make animated titles!
If you look up an image of a sin wave on a graph, you'll notice two things:
1. it's a smooth curve
2. It repeats itself, and goes both up and down instead of just one direction
These properties are useful because they let use make titles that:
1. Animate smoothly
2. Animate back and forth
Here's an example project I made with this. You can look at the code and try to modify it to make your own title. This same method can also be used to make ocean waves, hoverboards, etc.
Note: the “sine x value” variable is related to the x position on a graph. Don't worry too much about this if you don't understand it, but know that it represents how far into the animation you are
thx
- Ahaan_06
-
Scratcher
3 posts
How to use sin and cos
Sin is quite useful for epic movements
90+(sin of(timer)*39) for directions
90+(sin of(timer)*39) for directions
- _4o4_
-
Scratcher
7 posts
How to use sin and cos
Sine is basically a function. Try going to https://www.desmos.com/calculator and typing there “sin(x)”. What this basically does is, that given an X position to sin, sin output Y position. You can see that if X=0, then Y=0 as well. That means that sin(0) = 0. But if you go to X=1, then the Y coordinate is ~0.8. So that means that sin(1)=0.8.
Sin always outputs a value from -1 to 1, and can take any value as input. Try making a script like this: set variable A to sin(variable B), and set variable B to a slider, with the range -1000 to 1000, it could get you an idea.
Sin always outputs a value from -1 to 1, and can take any value as input. Try making a script like this: set variable A to sin(variable B), and set variable B to a slider, with the range -1000 to 1000, it could get you an idea.
- kinglert
-
Scratcher
25 posts
How to use sin and cos
when green flag clicked
say [hello] for (2) secs
wait (move () steps) secs
move (67) steps
sing [happy b day v] for (1000) showers
play sound [ v]
wright (bob) secs
*
- kensson_weymouth
-
Scratcher
12 posts
How to use sin and cos
To use the sin and cos blocks go. to
It tells you how far along/ how high up an angle is on a circle
For example:
([abs v] of ()::operators)Then select sin or cos
It tells you how far along/ how high up an angle is on a circle
For example:
<([sin v] of (90)::operators) = [1]>
Last edited by kensson_weymouth (Nov. 19, 2025 19:39:10)
- bRuHbRuHmEmEmAn
-
Scratcher
500+ posts
How to use sin and cos
Please do not necropost. It's the act of bringing an old topic back to the front page, which only clutters it. If you see an old topic that's already been resolved, please report it for necropost and have it closed.when green flag clicked
say [hello] for (2) secs
wait (move () steps) secs
move (67) steps
sing [happy b day v] for (1000) showers
play sound [ v]
wright (bob) secs
- Discussion Forums
- » Help with Scripts
-
» How to use sin and cos