Make axis reflective so line moves in opposite direction
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aarav Shah
el 29 de Nov. de 2019
Respondida: Walter Roberson
el 29 de Nov. de 2019
I have a line that is plotted using user input:
plot(xClic, yClic,'');
hold on
% Compute y intercept for slope of 1
b = yClic*xClic;
% Plot the line between the click point and the y intercept
batBeam=plot([xClic,0],[yClic,b],'b');
The limit of the x and y axis is 100. The line stops plotting when x=0 and y=whatever or when x=whatever and y=0.
How do I make a reflective boundary that activates once the line ends at (0,y) or (x,0) that stops after two bounces. For trouble visualizing, think of a laser boucing off a mirror.
This should happen at the endpoint. The line should have the same slope and move in the opposite direction.
0 comentarios
Respuesta aceptada
Walter Roberson
el 29 de Nov. de 2019
You cannot do what you are asking. It is not possible to get an event from the instant that the on-screen drawing of a line reaches a certain point on the screen. The MATLAB graphic system sends coordinate lists of complete lines to the hardware graphic system, which renders the coordinates and flips to new screens all at once (except as needed to transfer rendered information to the display.)
What you will have to do instead is to calculate the point of interception and act upon it appropriately.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!