Specifying 3D points with the mouse

11 visualizaciones (últimos 30 días)
Lindley French
Lindley French el 22 de Nov. de 2011
Comentada: MUTHUKUMAR SETHURAM el 6 de Mayo de 2016
I would like to be able to specify points on the X-Y plane with the mouse, but do so on a 3D plot. For any give point clicked, there should be a unique position on the X-Y plane (except in the degenerate case when the camera is on the X-Y plane).
The math is fairly simple if I can get the figure coordinates clicked by the mouse on a 3D plot. If I recover the projection matrix with T = view;, I think I should be able to back out the transformation by T if I hold z=0.
However, ginput is not returning sensible values when I try this. I am not able to determine what it is trying to return but it is not useful.
Any suggestions?
  1 comentario
MUTHUKUMAR SETHURAM
MUTHUKUMAR SETHURAM el 6 de Mayo de 2016
how to lattitude and longitude value from world Globe(3d) for when you click mouse in matlab ???
Thanks in Advance

Iniciar sesión para comentar.

Respuesta aceptada

Sven
Sven el 23 de Nov. de 2011
In short, don't use ginput(), use get(ax,'CurrentPoint') instead.
Basically the current position of the mouse, combined with the view matrix defines a stabbing vector. It will be up to you to interpret which plane that stabbing vector should intersect. Here is an example which prints out a coordinate in the view axes whenever the mouse moves. You could instead assign it to a 'onButtonPress' callback if you like. I'll be honest and say I can't quite remember which plane the view matrix uses by default, but it sounds from your question like you're on top of interpreting the result of the matrix transformation and are more interested in the replacement of ginput() with something more useful:
function example
figure('WindowButtonMotionFcn',@(src,evnt)printPos())
plot3(rand(5,1),rand(5,1)*20,rand(5,1)*5,'.'), view(3)
function printPos
clickedPt = get(gca,'CurrentPoint');
VMtx = view(gca);
point2d = VMtx * [clickedPt(1,:) 1]';
disp(point2d(1:3)')
end
end
  1 comentario
Puneeth Meruva
Puneeth Meruva el 20 de Jun. de 2013
2 Questions:
1. The three values returned by the example are x,y,z coordinates, right?
2. If so, what location within the figure is considered the origin?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Exploration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by