Make axis reflective so line moves in opposite direction

2 views (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 29 Nov 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.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!