How to get starting and ending point of mouse cursor?

조회 수: 2 (최근 30일)
Joy
Joy 2012년 8월 8일
I need to calculate the difference between the initial point and the point where the mouse cursor is while the mouse is moving. What I'm doing now is that I've calculated the rotation matrix, and all I have to do is to click the mouse at one point and move the mouse around.This action will rotate the image, at the same time, while moving the mouse. Only when I let go, the image will stay at the resulted image.
I've done something similar to http://www.mathworks.com/help/techdoc/ref/rbbox.html. But I don't want the 'finalRect=rbbox'
Does anyone know how to remove the rectangle rubberband, and the 2 current point remain the same?

채택된 답변

Walter Roberson
Walter Roberson 2012년 8월 8일
  댓글 수: 1
Joy
Joy 2012년 8월 8일
Thanks. I've looked through this. But where do I put my rotation calculation? Inside the 'WindowButtonMotionFcn'?
point1 = get(gca,'CurrentPoint'); % button down detected
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint'); % button up detected
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
r=[r(1)+(point2(1)-point1(1)) r(2)+(point2(2)-point1(2)) 0];
This is the code that I've now. Can you help me with the motion fcn? How am i going to substitute the Xdata and the Ydata from my code to the 'WindowButtonMotionFcn' example? Thanks again.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by