How do I get the angle between three points input by ginput() in appdesigner?

4 views (last 30 days)
[x, y] = ginput(3);
app.UIFigure.HandleVisibility = fhv;
x = round(x);
y = round(y);
I received the input with ginput(), but I don't know how to convert it to angle.
(R2022b)

Accepted Answer

David Hill
David Hill on 30 Nov 2022
Edited: David Hill on 30 Nov 2022
z=[x,y];
d=diff(z);
Angle=acos(dot(-d(1,:),d(2,:))/norm(d(1,:))/norm(d(2,:)));
  1 Comment
채호 박
채호 박 on 30 Nov 2022
Thank you so much. I just have a few questions.
If I receive input from ginput(6) and the angle between the first three points is angle1, then the angle between the third points is angle2
z=[x,y];
d=diff(z);
app.angle1=acos(dot(-d(1,:),d(2,:))/norm(d(1,:))/norm(d(2,:)));
app.angle2=acos(dot(-d(4,:),d(5,:))/norm(d(4,:))/norm(d(5,:)));
Is it right?
+) If I use angle1, 'Use app.angle1 to reference app properties' appears. Is this correct?
properties (Access = private)
angle1
end

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!