我正在尝试使用'FillPoly'在Psychtoolbox中绘制三角形。从试验到试验,三角形的数量各不相同。 3和最大屏幕上有10个三角形。三角形围绕假想的圆均匀分布。 每次试验最多6个对象,三角形绘制正常。 从屏幕上的7个对象开始,不再在屏幕左侧绘制三角形。在屏幕的右侧,它们工作正常。
有谁知道可能导致问题的原因?提前谢谢!
代码中的3个相关位: 首先,设置项目的坐标
angles(1) = 270;% the position of the first item
%setSize(i) = number of items on screen for trial i
step = 360/setSize(i);%other items are positioned in relation to the first
for u = 2:setSize(i),
angles(u) = angles(u-1) + step; % defining the circle points by the angles (first point is already fixed by first angle)
end
% for the triangles
anglesDegtri = linspace(0, 360, 3 + 1);
anglesRadtri = anglesDegtri * (pi / 180);
for j = 1:(setSize(i))
Xvalue = cosd(angles(j))*expinfo.radius + expinfo.x; % coordinate of the center of the object on the screen
Yvalue = sind(angles(j))*expinfo.radius + expinfo.y;
circlevalue(j, 1) = Xvalue- expinfo.radi; % defining the points on the axes for each circle (adding and subtracting the radius to get 4 points per circle)
circlevalue(j, 2) = Yvalue- expinfo.radi;
circlevalue(j, 3) = Xvalue+ expinfo.radi;
circlevalue(j, 4) = Yvalue+ expinfo.radi;
xx(j) = (circlevalue(j,1)+circlevalue(j,3))/2; %x of each item in set size
yy(j) = (circlevalue(j,2)+circlevalue(j,4))/2; %y of each item in set size
end
xx = xx(1,:);
yy = yy(1,:);
我预先计算三角形的坐标。 “设定大小”是给定试验中屏幕上的刺激量,并且可以在3到10之间变化
%precalculating vectors for all possible triangle positions
if setSize(i) == 3
triyPosVector1 = sin(anglesRadtri) .* expinfo.radi2 + yy(1);
trixPosVector1 = cos(anglesRadtri) .* expinfo.radi2 + xx(1);
triyPosVector2 = sin(anglesRadtri) .* expinfo.radi2 + yy(2);
trixPosVector2 = cos(anglesRadtri) .* expinfo.radi2 + xx(2);
triyPosVector3 = sin(anglesRadtri) .* expinfo.radi2 + yy(3);
trixPosVector3 = cos(anglesRadtri) .* expinfo.radi2 + xx(3);
triyPosVector = [triyPosVector1; triyPosVector2; triyPosVector3];
trixPosVector = [trixPosVector1; trixPosVector2; trixPosVector3];
elseif setSize(i) == 4
triyPosVector1 = sin(anglesRadtri) .* expinfo.radi2 + yy(1);
trixPosVector1 = cos(anglesRadtri) .* expinfo.radi2 + xx(1);
triyPosVector2 = sin(anglesRadtri) .* expinfo.radi2 + yy(2);
trixPosVector2 = cos(anglesRadtri) .* expinfo.radi2 + xx(2);
triyPosVector3 = sin(anglesRadtri) .* expinfo.radi2 + yy(3);
trixPosVector3 = cos(anglesRadtri) .* expinfo.radi2 + xx(3);
triyPosVector4 = sin(anglesRadtri) .* expinfo.radi2 + yy(4);
trixPosVector4 = cos(anglesRadtri) .* expinfo.radi2 + xx(4);
triyPosVector = [triyPosVector1; triyPosVector2; triyPosVector3; triyPosVector4];
trixPosVector = [trixPosVector1; trixPosVector2; trixPosVector3; trixPosVector4];
elseif setSize(i) == 5
triyPosVector1 = sin(anglesRadtri) .* expinfo.radi2 + yy(1);
trixPosVector1 = cos(anglesRadtri) .* expinfo.radi2 + xx(1);
triyPosVector2 = sin(anglesRadtri) .* expinfo.radi2 + yy(2);
trixPosVector2 = cos(anglesRadtri) .* expinfo.radi2 + xx(2);
triyPosVector3 = sin(anglesRadtri) .* expinfo.radi2 + yy(3);
trixPosVector3 = cos(anglesRadtri) .* expinfo.radi2 + xx(3);
triyPosVector4 = sin(anglesRadtri) .* expinfo.radi2 + yy(4);
trixPosVector4 = cos(anglesRadtri) .* expinfo.radi2 + xx(4);
triyPosVector5 = sin(anglesRadtri) .* expinfo.radi2 + yy(5);
trixPosVector5 = cos(anglesRadtri) .* expinfo.radi2 + xx(5);
triyPosVector = [triyPosVector1; triyPosVector2; triyPosVector3; triyPosVector4; triyPosVector5];
trixPosVector = [trixPosVector1; trixPosVector2; trixPosVector3; trixPosVector4; trixPosVector5];
elseif setSize(i) == 6
triyPosVector1 = sin(anglesRadtri) .* expinfo.radi2 + yy(1);
trixPosVector1 = cos(anglesRadtri) .* expinfo.radi2 + xx(1);
triyPosVector2 = sin(anglesRadtri) .* expinfo.radi2 + yy(2);
trixPosVector2 = cos(anglesRadtri) .* expinfo.radi2 + xx(2);
triyPosVector3 = sin(anglesRadtri) .* expinfo.radi2 + yy(3);
trixPosVector3 = cos(anglesRadtri) .* expinfo.radi2 + xx(3);
triyPosVector4 = sin(anglesRadtri) .* expinfo.radi2 + yy(4);
trixPosVector4 = cos(anglesRadtri) .* expinfo.radi2 + xx(4);
triyPosVector5 = sin(anglesRadtri) .* expinfo.radi2 + yy(5);
trixPosVector5 = cos(anglesRadtri) .* expinfo.radi2 + xx(5);
triyPosVector6 = sin(anglesRadtri) .* expinfo.radi2 + yy(6);
trixPosVector6 = cos(anglesRadtri) .* expinfo.radi2 + xx(6);
triyPosVector = [triyPosVector1; triyPosVector2; triyPosVector3; triyPosVector4; triyPosVector5; triyPosVector6];
trixPosVector = [trixPosVector1; trixPosVector2; trixPosVector3; trixPosVector4; trixPosVector5; trixPosVector6];
elseif setSize(i) == 7
triyPosVector1 = sin(anglesRadtri) .* expinfo.radi2 + yy(1);
trixPosVector1 = cos(anglesRadtri) .* expinfo.radi2 + xx(1);
triyPosVector2 = sin(anglesRadtri) .* expinfo.radi2 + yy(2);
trixPosVector2 = cos(anglesRadtri) .* expinfo.radi2 + xx(2);
triyPosVector3 = sin(anglesRadtri) .* expinfo.radi2 + yy(3);
trixPosVector3 = cos(anglesRadtri) .* expinfo.radi2 + xx(3);
triyPosVector4 = sin(anglesRadtri) .* expinfo.radi2 + yy(4);
trixPosVector4 = cos(anglesRadtri) .* expinfo.radi2 + xx(4);
triyPosVector5 = sin(anglesRadtri) .* expinfo.radi2 + yy(5);
trixPosVector5 = cos(anglesRadtri) .* expinfo.radi2 + xx(5);
triyPosVector6 = sin(anglesRadtri) .* expinfo.radi2 + yy(6);
trixPosVector6 = cos(anglesRadtri) .* expinfo.radi2 + xx(6);
triyPosVector7 = sin(anglesRadtri) .* expinfo.radi2 + yy(7);
trixPosVector7 = cos(anglesRadtri) .* expinfo.radi2 + xx(7);
triyPosVector = [triyPosVector1; triyPosVector2; triyPosVector3; triyPosVector4; triyPosVector5; triyPosVector6; triyPosVector7];
trixPosVector = [trixPosVector1; trixPosVector2; trixPosVector3; trixPosVector4; trixPosVector5; trixPosVector6; triyPosVector7];
elseif setSize(i) == 8
triyPosVector1 = sin(anglesRadtri) .* expinfo.radi2 + yy(1);
trixPosVector1 = cos(anglesRadtri) .* expinfo.radi2 + xx(1);
triyPosVector2 = sin(anglesRadtri) .* expinfo.radi2 + yy(2);
trixPosVector2 = cos(anglesRadtri) .* expinfo.radi2 + xx(2);
triyPosVector3 = sin(anglesRadtri) .* expinfo.radi2 + yy(3);
trixPosVector3 = cos(anglesRadtri) .* expinfo.radi2 + xx(3);
triyPosVector4 = sin(anglesRadtri) .* expinfo.radi2 + yy(4);
trixPosVector4 = cos(anglesRadtri) .* expinfo.radi2 + xx(4);
triyPosVector5 = sin(anglesRadtri) .* expinfo.radi2 + yy(5);
trixPosVector5 = cos(anglesRadtri) .* expinfo.radi2 + xx(5);
triyPosVector6 = sin(anglesRadtri) .* expinfo.radi2 + yy(6);
trixPosVector6 = cos(anglesRadtri) .* expinfo.radi2 + xx(6);
triyPosVector7 = sin(anglesRadtri) .* expinfo.radi2 + yy(7);
trixPosVector7 = cos(anglesRadtri) .* expinfo.radi2 + xx(7);
triyPosVector8 = sin(anglesRadtri) .* expinfo.radi2 + yy(8);
trixPosVector8 = cos(anglesRadtri) .* expinfo.radi2 + xx(8);
triyPosVector = [triyPosVector1; triyPosVector2; triyPosVector3; triyPosVector4; triyPosVector5; triyPosVector6; triyPosVector7; triyPosVector8];
trixPosVector = [trixPosVector1; trixPosVector2; trixPosVector3; trixPosVector4; trixPosVector5; trixPosVector6; triyPosVector7; triyPosVector8];
elseif setSize(i) == 9
triyPosVector1 = sin(anglesRadtri) .* expinfo.radi2 + yy(1);
trixPosVector1 = cos(anglesRadtri) .* expinfo.radi2 + xx(1);
triyPosVector2 = sin(anglesRadtri) .* expinfo.radi2 + yy(2);
trixPosVector2 = cos(anglesRadtri) .* expinfo.radi2 + xx(2);
triyPosVector3 = sin(anglesRadtri) .* expinfo.radi2 + yy(3);
trixPosVector3 = cos(anglesRadtri) .* expinfo.radi2 + xx(3);
triyPosVector4 = sin(anglesRadtri) .* expinfo.radi2 + yy(4);
trixPosVector4 = cos(anglesRadtri) .* expinfo.radi2 + xx(4);
triyPosVector5 = sin(anglesRadtri) .* expinfo.radi2 + yy(5);
trixPosVector5 = cos(anglesRadtri) .* expinfo.radi2 + xx(5);
triyPosVector6 = sin(anglesRadtri) .* expinfo.radi2 + yy(6);
trixPosVector6 = cos(anglesRadtri) .* expinfo.radi2 + xx(6);
triyPosVector7 = sin(anglesRadtri) .* expinfo.radi2 + yy(7);
trixPosVector7 = cos(anglesRadtri) .* expinfo.radi2 + xx(7);
triyPosVector8 = sin(anglesRadtri) .* expinfo.radi2 + yy(8);
trixPosVector8 = cos(anglesRadtri) .* expinfo.radi2 + xx(8);
triyPosVector9 = sin(anglesRadtri) .* expinfo.radi2 + yy(9);
trixPosVector9 = cos(anglesRadtri) .* expinfo.radi2 + xx(9);
triyPosVector = [triyPosVector1; triyPosVector2; triyPosVector3; triyPosVector4; triyPosVector5; triyPosVector6; triyPosVector7; triyPosVector8; triyPosVector9];
trixPosVector = [trixPosVector1; trixPosVector2; trixPosVector3; trixPosVector4; trixPosVector5; trixPosVector6; triyPosVector7; triyPosVector8; triyPosVector9];
elseif setSize(i) == 10
triyPosVector1 = sin(anglesRadtri) .* expinfo.radi2 + yy(1);
trixPosVector1 = cos(anglesRadtri) .* expinfo.radi2 + xx(1);
triyPosVector2 = sin(anglesRadtri) .* expinfo.radi2 + yy(2);
trixPosVector2 = cos(anglesRadtri) .* expinfo.radi2 + xx(2);
triyPosVector3 = sin(anglesRadtri) .* expinfo.radi2 + yy(3);
trixPosVector3 = cos(anglesRadtri) .* expinfo.radi2 + xx(3);
triyPosVector4 = sin(anglesRadtri) .* expinfo.radi2 + yy(4);
trixPosVector4 = cos(anglesRadtri) .* expinfo.radi2 + xx(4);
triyPosVector5 = sin(anglesRadtri) .* expinfo.radi2 + yy(5);
trixPosVector5 = cos(anglesRadtri) .* expinfo.radi2 + xx(5);
triyPosVector6 = sin(anglesRadtri) .* expinfo.radi2 + yy(6);
trixPosVector6 = cos(anglesRadtri) .* expinfo.radi2 + xx(6);
triyPosVector7 = sin(anglesRadtri) .* expinfo.radi2 + yy(7);
trixPosVector7 = cos(anglesRadtri) .* expinfo.radi2 + xx(7);
triyPosVector8 = sin(anglesRadtri) .* expinfo.radi2 + yy(8);
trixPosVector8 = cos(anglesRadtri) .* expinfo.radi2 + xx(8);
triyPosVector9 = sin(anglesRadtri) .* expinfo.radi2 + yy(9);
trixPosVector9 = cos(anglesRadtri) .* expinfo.radi2 + xx(9);
triyPosVector10 = sin(anglesRadtri) .* expinfo.radi2 + yy(10);
trixPosVector10 = cos(anglesRadtri) .* expinfo.radi2 + xx(10);
triyPosVector = [triyPosVector1; triyPosVector2; triyPosVector3; triyPosVector4; triyPosVector5; triyPosVector6; triyPosVector7; triyPosVector8; triyPosVector9; triyPosVector10];
trixPosVector = [trixPosVector1; trixPosVector2; trixPosVector3; trixPosVector4; trixPosVector5; trixPosVector6; triyPosVector7; triyPosVector8; triyPosVector9; triyPosVector10];
end
%then I draw the stimuli on the screen.
for pos = 1:setSize(i) % Drawing the stimuli
% Draw a triangle
Screen('FillPoly', expinfo.w, expinfo.colors(trial(i).memoryColors(pos), :), [trixPosVector(pos, :); triyPosVector(pos, :)]', 2);
end
答案 0 :(得分:0)
多边形7-10的点当前正以线条的形式绘制到屏幕上。如果您将'FillPoly'更改为'FramePoly',您可以看到它们的位置。 FillPoly命令不显示它们,因为作为一条直线,没有要填充的区域。我还没有读过您用来放置三角形的所有几何逻辑,但似乎算法存在一个问题,即如何确定三角形7-10。