Sin Y visualization

I made this project a month ago

The project itself is incredible and I have no critique whatsoever.

It’s great that you’re interested in the trig functions, but I have a bunch of suggestions for improvement.

Most importantly, I think you are confused about the variables in a function graph. You are graphing the function y=\sin(x). x is the variable on the horizontal axis, and in your case represents time, since you use TIMER to set it. y is what’s called the “dependent” variable, meaning that its value is determined by some function of x. So what you’re graphing is \sin x, not \sin y.

(To be clear, in principle variable names are arbitrary, and you can call your variables whatever you want. But when graphing a function, it’s a universal convention that x is the variable on the horizontal axis and y is the one on the vertical axis.)

Next, of course you’re really graphing y=100\sin x so that the graph is visible, and that’s a good choice, but if you’re going to display a variable watcher that purports to show the value of \sin x, it should take on values between -1 and 1, because that’s how the sine function works.

I think you made the variable take on values in [-100, 100] because you wanted also to show the value rounded to two digits, which changes slowly enough to be readable. You can round to two decimal digits while still correctly showing the range [-1, 1]. Showing the rounded value is the thing I like best about your project, because you can see how the rate of change of the function slows down near the top and bottom of the graph.

The next thing I’d change is the scale on the x axis. In your version, the graph looks almost like a triangle function, with straight line segments zigzagging up and down. I would spread out the graph so you can see the actual rounded shape of the function.

Now we’re down to details. Instead of using TIMER to control the value of x, I’d just use X POSITION, which lets you draw a smooth graph more easily; after some experimentation, I changed x by 0.5 each time through the loop instead of your 0.1, making the program run much faster but still slow enough so you can see the passage of time.

Now we’re down in the weeds: There’s no need to PEN UP between iterations; better not, in fact, to ensure a continuous curve. You do want to start with PEN UP to avoid a vertical spike at the very beginning of the graph.

And I don’t see any need for the Sin Y visualization script pic (1) in your calculations.

Here’s my version:

EDIT: Oops, I somehow lost the PEN UP before taking the picture. It goes next to the CLEAR.

The constants 3 and 0.5 are just what I found pleasing. You might want to make them sliders so the user can control the shape.

How to make these a slider

  1. Make a variable, e.g., X SCALE for the 3.
  2. Replace every untitled script pic (7) with untitled script pic (8).
  3. RIght-click the variable watcher on the stage and select SLIDER:

    You can use the same menu to set the min and max values. In this case I’d probably choose 1 and 10. (Not 100, because that would make it too hard to distinguish 3 from 4.)

oh, okay

Did you slide the slider while it was running? :~)

yes, are there any fix?

This isn’t a bug! It’s often desirable to change parameters while a program is running. But if you don’t like it you can start the program with


and then use X SCALE ON ENTRY in the rest of the code.

nothing changed the visuals, the bug is fixed though