Question

I'm drawing 4 rectangles with randomized rotations. They seem randomized in terms of their angels, however I need them to be a little bit different. The rectangles should not be close to each other, they all should be at least 10 degrees apart. And this also should be randomized. How can I define this? Thank you!

rot_angle1=randi(360); 
rot_angle2=randi(360); 
rot_angle3=randi(360); 
rot_angle4=randi(360); 
rect_array=255*ones(1,1);
t1=Screen('MakeTexture',w,rect_array);
t2=Screen('MakeTexture',w,rect_array);
t3=Screen('MakeTexture',w,rect_array);
t4=Screen('MakeTexture',w,rect_array);
t5=Screen('MakeTexture',w,rect_array);

destrect(1,:) = (ul_c + stim_array);
destrect(2,:) = (ur_c + stim_array);
destrect(3,:) = (ll_c + stim_array);
destrect(4,:) = (lr_c + stim_array);

Screen('DrawTexture',w,t2,[],destrect(1,:),rot_angle1);
Screen('DrawTexture',w,t3,[],destrect(2,:),rot_angle2);
Screen('DrawTexture',w,t4,[],destrect(3,:),rot_angle3);
Screen('DrawTexture',w,t5,[],destrect(4,:),rot_angle4);
Screen('Flip',w);
Was it helpful?

Solution

instead of rot_angle1=randi(360); lines, define

rot_angle=randi(36,1,4)*10;

Now there is at least 10 deg apart in each angle, with step size of 10 degrees. Note that this doesn't mean the angles will be unique. using randi there's a chance two rotation angles will be the same. In order to impose uniquness use

rot_angle=randperm(36)*10;

Use rot_angle(1) instead of rot_angle1 etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top