Azzera filtri
Azzera filtri

how to find concave angle between three points

8 visualizzazioni (ultimi 30 giorni)
Hello how can I fing agle if I know three points, but I would like to reald also the concave one.
this function ang = atan2(norm(det([P2-P0;P1-P0])),dot(P2-P0,P1-P0)); , it gives me only convex one
thank you
  14 Commenti
Torsten il 22 Nov 2022
Let the OP choose what better fits her needs:
thd = 0:10:360; % a sequence of angles from 0-360
xx = cosd(thd);
yy = sind(thd);
h = numel(thd);
ang = zeros(h,1);
for f = 1:h
P1=[0 0]; % some fixed point
P2=[1 0]; % i'm going to fix this one too
P3=[xx(f) yy(f)]; % this point moves in a circle about P0 [x,y]
angstn = atan2(P3(2) - P1(2), P3(1) - P1(1)) - atan2(P2(2) - P1(2), P2(1) - P1(1));
if angstn < 0
angstn = angstn + 2*pi;
ang(f) = angstn*180/pi;
cosf = cos(ang);
plot(thd,ang) % output is folded at 180
Eliska Paulikova
Eliska Paulikova il 22 Nov 2022
Thank you so much
It means a lot for me
thank you

Accedi per commentare.

Risposte (1)

David Goodmanson
David Goodmanson il 23 Nov 2022
Hi Eliska,
One thing that does not seem to be mentioned so far is your use of the norm function on the determinant. That makes all the sines positive, which puts you into the first or second quadrant and forces all the angles out of atan2d to be 0<=theta<180. Dropping the norm opens up the range of angles to 0<=theta<360. In the code below, (P2-P0) is a reference vector, and the angle is measured counterclockwise from (P2-P0) to (P1-P0) with 0<=theta<360.
P0 = [0 0];
P1 = [-1 2];
P2 = [1 1];
P20 = P2-P0; % reference vector
P10 = P1-P0;
theta = atan2d((det([P20;P10])),dot(P20,P10));
theta = mod(theta,360)


Scopri di più su Computational Geometry in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by