I used the example from the framed polygon tutorial
My goals are
- Present both left and right side triangle locations based on a matrix of x,y window dimensions ( y will be the same for both sides)
- Create matrix containing x, y vectors for all possible sizes of the triangle based on the radius
- Use random selection of radius (to determine size displayed) to determine size of triangles
Here is my code:
frame = [0.20 0.40 .60 .80 1];
screengrid= zeros(2,5);
for i = 1:length(screengrid(:,1:5))
screengrid(1,i) = ptb.winRect(3).* frame(i)
screengrid(2:end,i) = ptb.winRect(4).* frame(i)
end
numSides = 3;
anglesDeg = linspace(0, 360, numSides + 1);
anglesRad = anglesDeg * (pi / 180);
radius = [ 50 75 100 125 150 175 200 225 250];
nr = numel(radius);
na = numel(anglesRad)*2;
tdims = zeros(nr,na);
tdims = zeros(nr,na);
for i = 1:nr
tdims(i,1:4) = cos(anglesRad) .* radius(i) + screengrid(3); % cos = x,
tdims(i,5:8) = -sin(anglesRad) .* radius(i) + screengrid(6); % sin = y
end
l= randperm(length(tdims),1);
LxPosVector = tdims(l,1:4);
LyPosVector = tdims(l,5:8);
Screen(‘FillPoly’, ptb.win, triColor,[LxPosVector; LyPosVector]', isConvex);
Screen(‘Flip’, ptb.win);
The issue is that my triangle needs to be rotated to the right ~45 degrees. I found difficulty w/ rotation matrices due to the number of xy pairs in my matrix. How can I rotate the dimensions. If tdims can be rotated within the loop that would be optimal, otherwise outside the loop is fine. I could make either one work. Maybe I need to redesign the loop.