Graphic display problem after using normalized coordinates in Matlab

1 vue (au cours des 30 derniers jours)
sicheng
sicheng le 3 Août 2024
Commenté : sicheng le 5 Août 2024
Hi,guys.
I encountered a problem. That is, when I use normalized coordinates, no matter how I adjust the diameter of my target circle, there is no change in the image. I can feel the change in the coordinates. But I don't need this. I want the entire image to change after adjusting the diameter.
Here are the codes:
startTask()
Unrecognized function or variable 'showBlackPanelScreen'.

Error in solution>startTask (line 37)
showBlackPanelScreen(2)
function startTask()
targetCenters = zeros(8, 2);
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
radii = 0.3;
waitingForNextTarget = false;
firstMove = true;
resetPosition = [0, 0];
targetSequence = [1,3,5,7,2,4,6,8,8,6,4,2,7,5,3,1];
currentSequenceIndex = 1;
for i = 1:length(angles)
targetCenters(i, 1) = radii * cos(angles(i));
targetCenters(i, 2) = radii * sin(angles(i));
end
targetActivated = false;
currentTarget = 0;
hoverStartTime = [];
cyclesCompleted = 0;
maxCycles = 64;
mousePath = [];
mouseDot = [];
x = 0;
y = 0;
timerObj = timer('TimerFcn', @recordMousePos, 'Period', 0.02 , 'ExecutionMode', 'fixedRate');
checkTargetTimer = timer('TimerFcn', @checkAndActivateTarget, 'Period', 0.02 , 'ExecutionMode', 'fixedRate');
start(checkTargetTimer);
fig = figure('Color', 'black', 'Pointer', 'custom', 'Units', 'normalized', 'Position', [0 0 1 1], 'MenuBar', 'none', 'ToolBar', 'none');
ax = axes('Color', 'black', 'Units', 'normalized', 'Position', [0 0 1 1], 'DataAspectRatio', [1 1 1]);
axis off;
hold on;
drawCircles();
set(fig, 'WindowButtonMotionFcn', @mouseMoved);
setInvisibleCursor();
showBlackPanelScreen(2)
resetMouseAndDotPositionToCenter();
activateRandomTarget();
function setInvisibleCursor()
transparentCursor = NaN(16, 16);
hotspot = [8, 8];
set(fig, 'Pointer', 'custom', 'PointerShapeCData', transparentCursor, 'PointerShapeHotSpot', hotspot);
end
function drawCircles()
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
circleDiameter = radii * 0.2;
%axis equal;
for i = 1:length(angles)
x = radii * cos(angles(i));
y = radii * sin(angles(i));
rectangle('Position', [x - circleDiameter/2, y - circleDiameter/2, circleDiameter, circleDiameter], 'Curvature', [1, 1], 'EdgeColor', 'w', 'FaceColor', 'k', 'LineStyle', '--', 'LineWidth', 3, 'UserData', i);
end
end
end
Sicheng

Réponses (1)

Shishir Reddy
Shishir Reddy le 5 Août 2024
Hi Sicheng
As per my understanding, you are not able to notice any change in the image after changing the diameter, so you would like to see the entire image to change after adjusting the diameter.
In the code provided, the relationship between radii and circleDiameter is given by
circleDiameter = radii * 0.2;
This means that the diameter of each target circle is set to 20% of the radii value. So, to change the circleDiameter value, radii value should also be changed.
For example,
  • If radii is 0.3, the circleDiameter will be 0.06 (0.3 * 0.2).
  • If radii is increased to 0.5, the circleDiameter will be 0.1 (0.5 * 0.2).
When both radii and circleDiameter are increased proportionally, the distance between the center of the screen and the centers of the target circles (radii) increases and the size of each target circle (circleDiameter) also increases proportionally. Because both variables are scaled by the same factor, the overall layout and appearance of the target circles remain visually consistent. The circles will still be evenly spaced around the center, and their relative sizes will remain the same.
Therefore, to clearly visualize the changes in the image after changing the circleDiameter, the proportionality between radii and circleDiameter must be removed and circleDiameter should be given a value which is independent of radii.
I hope this helps.
  1 commentaire
sicheng
sicheng le 5 Août 2024
So what I want to know now is what kind of array will be more consistent with the actual distance? If they are all scaled proportionally, my calculation using dpi may be meaningless.

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by