psychopy.org | Reference | Downloads | Github

How to make a circle move in a certain frequency and complete a full period?

I tried making a circle move from the center of the screen in a Sinus frequency (X axis only) and complete a full period with a frame rate of 60.

What I’ve tried in the builder is simply:
Position[X,Y] $ = (sin(t)*18, 0)

I want to make a complete period when the circle starts moving exactly from the center, goes right, then left and returns to the center.

The problem: The way I tried thus far, I keep playing with the duration but it’s not precise and not returning to the center.

How do I achieve that and control the variables?

@Eitan_Shteinberg, I tried using pi as the modifier of t, where the duration of the stim was 1 second, and it seems to start and end in the same position . Try:

(sin( (t * pi) * 2 ), 0)

If you want the area that it travels to be shorter

(sin( (t * pi) * 2 ) / 4, 0)
1 Like

The argument to the sin() function is an angle in radians. There are 2 𝝿 radians in a circle. So to do one cycle in one second, you want the argument to range from 0 to 2 𝝿 within one second. That means multiplying t by 2 * pi. That is a little different from David’s suggestion, as the multiplication has to happen within the brackets. It’s the amplitude multiplier that goes outside.

You can independently manipulate the frequency, phase, and amplitude of the wave. To learn more (or more likely, dredge up some of your high school maths/physics), google for “simple harmonic motion”.

2 Likes