need help with pointer movement on grid

조회 수: 6 (최근 30일)
h b
h b 2016년 12월 1일
댓글: h b 2017년 1월 13일
I have a grid,say 150*150m with each cell 0.5*0.5m making it a grid of 300*300 cells. I want to move pointer in a random arc path such that the pointer covers each cell (cell should be covered completely) in time steps( if that can be included as well) along its path. The pointer dimensions 1*1m (i.e. spanning 2*2cells in either direction). i need help with coding it.
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 12월 1일
When moving from one location to another, what are the allowed changes in position? For example is it only permitted to move left, right, up, down, by one unit? Or is it permitted to move diagonally by one? Is it permitted to move more than one cell at a time? Is it permitted to move back to where it was immediately previously? Is it permitted to move back to somewhere it has been before? Is each location to be visited exactly once, so the 300*300 grid would be completely covered in exactly 90000 steps?

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2016년 12월 1일
clc; clear all ;
% N = 300 ; M = 150 ;
N = 100 ; M = 50 ;
[X1,Y1] = MeshRectanglularPlate(150,150,N,N) ;
[X2,Y2] = MeshRectanglularPlate(150,150,M,M) ;
nel = size(X2,2) ;
Ele = 1:nel ;
for i = 1:nel
% pick one element randomly
ele = randsample(Ele,1) ;
patch(X1,Y1,'w') ;
hold on
patch(X2(:,ele),Y2(:,ele),'r')
hold off
% remove the elemnet picked
Ele = setdiff(Ele,ele) ;
pause(0.5)
end
  댓글 수: 17
h b
h b 2016년 12월 6일
1. i am unable to move pointer(having dimension 2cells*1cell) cell by cell in a straight path.
2. is it posible to keep certain column of cells in the grid as rotated matching the path shape. eg. in an arc path, square cells rotated to match the shape. Thanks in advance
h b
h b 2017년 1월 13일
i have an issue to formulate logic. how to move pointer in any straight line(column or row) cell by cell. please help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by