# moveShapesRandomlyOnCircle

moveShapesRandomlyOnCircle( referenceShape, distance, startAngle, shapeToMove1, shapeToMove2, …)

Moves the shapeToMove(s) arguments relative to the referenceShape the given distance away and at the given angle (which must be in degrees, not radians).

Unlike the regular moveShapesOnCircle() function, this function randomly orders the shapes as it positions them on the circle; that is, rather than arranging the shapes as specified in the parameter list  – shapeToMove1 followed by shapeToMove2 followed by shapeToMove3, etc. – this function selects the shapes randomly as it positions them on the circle.

The location of the shape is saved into the database and automatically associated with the current session, trial and phase (if applicable).

Note that just like the moveShape(…) function, using moveShapesRandomlyOnCircle() creates the dedicated “moved” event in the Events table within the database.

This function is quite handy when you need to move more than one shape at a time and want them all equidistant, and want them to be arranged randomly relative to another.

When using this function, it can be handy to have a reference diagram of the basic angles: The shapes are all spaced evenly around the circle by angle (that is, the size of the shapes is not used when spacing them around the circle).  Thus, the angle between the shapes is calculated using this equation: Arguments

 referenceShape - the reference shape (this shape is not moved) acts as the centre of the imaginary circle around which the other shapes will be placed.   Note that this shape does not need to be visible to use it as the reference shape. distance - the  distance away from the referenceShape to move the shapeToMove (basically, the radius of the imaginary circle on which the shapes will be placed). This value may be either absolute or a percent; if it is a percent then it is a percentage of the larger of the screen’s width. startAngle - The starting angle (in degrees) for the first shape to move. shapeToMove# - Any number of shapes to move.  Each shape will be placed on the imaginary circle in a random order.

Returns

The number of shapes that were moved, which is always the number of shapes passed in.

This function also sets a variable “angle” on the shape itself that describes the angle the shape was positioned at; like everything else, this angle is saved in the database.  You can access this variable after calling the function, but setting the variable does nothing.

Example #1

The following displays a black circle in the centre of the screen, and then moves three equally spaced circles all the way around it:

// Define some colours

define blue = #0000FF

define green = #55AA2B

define fuchsia = #FF00FF

define orange = #FFA500

define grey = #333333

//  Define a basic circle

define type of circle CircleType

colour = #FF0000

x = 50%

y = 50%

isVisible = true

end circle

// Create a centre circle that is black

define centre = create CircleType

centre.Colour = #000000

// Create the first circle

define circle1 = create CircleType

circle1.colour = blue

// Create the second circle

define circle2 = create CircleType

circle2.colour = fuchsia

// Create the third circle

define circle3 = create CircleType

circle3.colour = orange

// Create the forth circle

define circle4 = create CircleType

circle4.colour = grey

// Create the fifth circle

define circle5 = create CircleType

circle5.colour = green

// Arrange the circles randomly around the fixation point

define counter = 0

while counter <= 100

moveShapesRandomlyOnCircle(centre, 200, 90, circle1, circle2, circle3, circle4, circle5 )

wait for 1sec

counter += 1

end while

wait for 5 sec

Example #2

Alternatively, you can pass in a collection of shapes.  This example is the same but with a collection instead

// Define some colours

define blue = #0000FF

define green = #55AA2B

define fuchsia = #FF00FF

define orange = #FFA500

define grey = #333333

//  Define a basic circle

define type of circle CircleType

colour = #FF0000

x = 50%

y = 50%

isVisible = true

end circle

// Create a centre circle that is black

define centre = create CircleType

centre.Colour = #000000

// Create the first circle

define circle1 = create CircleType

circle1.colour = blue

// Create the second circle blue

define circle2 = create CircleType

circle2.colour = fuchsia

// Create the third circle

define circle3 = create CircleType

circle3.colour = orange

// Create the forth circle

define circle4 = create CircleType

circle4.colour = grey

// Create the fifth circle

define circle5 = create CircleType

circle5.colour = green

define collection CirclesCollectionType

circle1

circle2

circle3

circle4

circle5

end collection

define circles = create CirclesCollectionType

// Arrange the circles randomly around the fixation point

define counter = 0

while counter <= 100

moveShapesRandomlyOnCircle(centre, 200, 90, circles )

wait for 1sec

counter += 1

end while

wait for 5 sec