| Reference | Downloads | Github

How to create a lineStim that can rotate around the centre of the screen?

A very simple question:

I need to create a lineStim that can rotate around the centre of the screen.
But rather than rotating around its centre, it needs to rotate around its end point – like a clock hand.

When I create a lineStim using the Polygon component, builder then creates a line that rotates around its centre point

So how can I create a line that rotates around one of its endpoints?

In principle you need to rotate the line by an angle and then also offset it from the centre of the screen by half its length at the same angle.

xpos = cos(x)*length/2
ypos = sin(x)*length/2

Best wishes,


HI @wakecarter,
thanks for this – Yup. Makes sense.
But, alas, that is not working. For some reason, the line is jumping around like crazy.
I want the line to rotate once per 2560ms. This equates to a change in angle of 140.625 degrees per second. Defining the angle (ori) in terms of trial time t thus gives t*140.625
I define my stims in height units and go for a length of .3

So I have ori = t140.625
pos = (.15
cos(t140.625),.15 * sin(t140.625))

and that leads to the crazy jumping.

I then tried to bug catch and simply wanted to the move the x co-ordinate of a polygon in a sine-wave fashion, i.e. set ori = 0, and simply have pos = (.15cos(t140.625), 0)
This shows that the stimulus is jumping along the x axis, rather than moving smoothly.

What am I doing wrong?

I think you need to use radians not degrees

Switch to the Coder view and go to the “Demos” menu. There you will find a shape stim demo that draws a clock face, continually updating the second, minute, and hour hands.

The ori is certainly specified in degrees…

The sin and cos functions use radians

silly me! Duh!