Discuss Scratch

drf341
Scratcher
9 posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

I am trying to print out the 3 functions above on the same screen. Other projects that i looked at do some very cool stuff, but makes it so that only one function is graphed or it links the two graphs and makes them not the traditional graphs we want to see in a maths class. I am thinking in terms of f(x)=sinx on a Cartesian plane so that y goes from -1 to 1. This thinking may not work for Scratch and so far I cant make it work. For my logic to work I would need a change in x that would be in degrees and not integers. Thanks for the help.

Last edited by drf341 (June 13, 2017 17:31:56)

footsocktoe
Scratcher
1000+ posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

drf341 wrote:

Any thoughts on how to do calculations using degrees instead integers

Just that there are 360 of them in a circle and in Scratch facing right is 90 degrees and straight up is zero degrees.

The number 360 was chosen many centuries ago to represent the circle because it can be divided into many different fractions 1/2, 1/3, 1/4, 1/5, 1/6, 1/8, 1/9, 1/10 and still be an even number.
awesome-llama
Scratcher
1000+ posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

drf341 wrote:

Any thoughts on how to do calculations using degrees instead integers
Depends on what calculation you want to do. Anything more specific?
drf341
Scratcher
9 posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

I was trying to graph a sine wave, but to do that i would need to move the sprite along a change in x that will go from 0-2pi. Thus I would need to change the scale not by integers but by some degree.
drmcw
Scratcher
1000+ posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

Scratch already uses degrees rather than radians.
drf341
Scratcher
9 posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

I saw that scratch turns in degrees, but it does not use the move command in degrees only integers. I put it radian here just because its the way I think of degrees. Like i said I am seeing if I can do a graph of cos,sin and tan. On paper or in other programming languages this is not a problem, I just get the library I need and go. Scratch is a bit different and I was hoping that a middle school student would be able to make a program here that would print out all three graphs (print on screen, not on paper). However, I cant seem to get this to work, so how can I expect kids to. Thus i put the fate of the project into the scratch communities hands to see if this is doable.
DanloVorje
Scratcher
100+ posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

The sin, cos, and tan operations are all in the dropdown menu of this block under “operators”:
sqrtof9
It assumes the input value is in degrees. So you could graph a sine wave using
repeatintervalchangexby1setytosinofxposition*frequency*amplitude

Hope this helps!

–Danlo
drf341
Scratcher
9 posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

That bit of code helps a lot, thank you. I did see a problem with it, as it assumes (0,0) starting point. The graph of sine prints out partially. So I will see if I can fix that. I will also credit you for the code if I ever get it to work Danlo.
drmcw
Scratcher
1000+ posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

It has nothing to do with turning or moving which does take non-integer number incidentally. The only difference between scratch and other languages is that Scratch uses degrees rather than radians but converting between the two is trivial anyway.

I really think you're overthinking this as it's really incredibly easy as DanloVorje has demonstrated.
drmcw
Scratcher
1000+ posts

Scratch graphing Sine, Cosine and Tan all on the same screen?

Just doing a search gets this https://scratch.mit.edu/projects/68896192/

Powered by DjangoBB