how to find cosine angle known the end points of 2 linesegments
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
krishnasri
am 28 Apr. 2015
Kommentiert: krishnasri
am 5 Mai 2015
There are 2 line segments, known their end points, how can i find angle between them
Akzeptierte Antwort
Guillaume
am 29 Apr. 2015
The arguments you pass to dot and norm must be vectors not scalars
v1 = [1 1]
v2 = [0 3]
D = [v1;v2]; %possibly you have something like this
costheta = dot(D(1, :), D(2, :)) / (norm(D(1, :)) * norm(D(2, :)));
thetaindegrees = acosd(costheta)
0 Kommentare
Weitere Antworten (1)
Roger Stafford
am 29 Apr. 2015
Bearbeitet: Roger Stafford
am 29 Apr. 2015
Using 'atan2' or 'atan2d' and cross product is more accurate for angles that are near zero or near pi (180 degrees.)
a = atan2(norm(cross(D1,D2)),dot(D1,D2)); % Angle in radians
or
a = atan2d(norm(cross(D1,D2)),dot(D1,D2)); % Angle in degrees
Siehe auch
Kategorien
Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!