calculate an angle and distance from three points

조회 수: 7 (최근 30일)
bil bbil
bil bbil 2014년 3월 10일
댓글: Mansour Attaallah 2018년 8월 11일
hi...How to calculate an angle and distance from three points? ex P1 = (x=2, y=50) P2 = (x=9, y=40) P3 = (x=5, y=20)
  댓글 수: 1
Marta Salas
Marta Salas 2014년 3월 10일
You can not define an angle and a distance between 3 points. Do you mean by pairs of those 3 points?

댓글을 달려면 로그인하십시오.

채택된 답변

Roger Stafford
Roger Stafford 2014년 3월 11일
편집: Roger Stafford 2014년 3월 11일
I'll show you how to find one of the angles in the triangle P1 = [x1;y1], P2 = [x2;y2], P3 = [x3;y3]. The inner angle at vertex P1 is given by:
A1 = atan2(abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)), ...
(x2-x1)*(x3-x1)+(y2-y1)*(y3-y1));
As for the "distance", please tell us what kind of distance you have in mind. Distance from what to what?
  댓글 수: 2
bil bbil
bil bbil 2014년 3월 11일
first of all thank you very much. I'm looking for the distance between P1,P2 and P1,P3 for then stored in an array
Mansour Attaallah
Mansour Attaallah 2018년 8월 11일
Thank you very much it is really helpful

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Marta Salas
Marta Salas 2014년 3월 11일
The distance can be calculated as the norm of the vector between two points:
P1 = [2; 50], P2 = [9; 40], P3 = [5; 20]
d1 = norm(P2-P1);
d2 = norm(P3-P1);
distances =[d1; d2]

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by