How to get distance & angle of a point from the center of a minor axis ??

조회 수: 2 (최근 30일)
I want to calculate the distance & angle of a point like The point in the below Image : P.S the Center Point isn't (0,0)

채택된 답변

Matt Tearle
Matt Tearle 2013년 3월 20일
편집: Matt Tearle 2013년 3월 21일
Do you have the coordinates of the point and the center (in standard Cartesian coordinates)? If so, just use norm and atan2 of the difference between the two:
p1 = rand(2,1)
p2 = rand(2,1)
d = p2 - p1
norm(d)
atan2(d(2),d(1))
EDIT TO ADD (In response to your comment): Still the same idea -- atan(delta_y,delta_x). It seems that you have data in the form of whole vectors of (x,y) points, and a single center point, in which case:
% coordinates of points
X = [1;2;3;4];
Y = [9;8;7;6];
% coordinates of center
X0 = 2;
Y0 = 2;
% take the difference
dX = X - X0;
dY = Y - Y0;
% and calculate the length
sqrt(dX.^2 + dY.^2)
% and angle
atan2(dY,dX)
% or atan2d(dY,dX) if you prefer degrees to radians
% visualize, for sanity
plot(X,Y,'o',X0,Y0,'x')
  댓글 수: 1
Haytham Mohamed
Haytham Mohamed 2013년 3월 21일
sorry bro , but i don't understand how to get the angle . let me give u some input :
X =[1;2;3;4]
Y =[9;8;7;6]
Center Is (2,2)
How to get the angle of each point from center

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactions, Camera Views, and Lighting에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by