フィルターのクリア

how can i calculate the angle between a vector and the x axes?

53 ビュー (過去 30 日間)
Maayan
Maayan 2013 年 10 月 1 日
コメント済み: Maayan 2013 年 10 月 1 日
Hi, How can i calculate the angle between a vector and the x axes of my figure? I have been trying to find a function but with no success. I have a 1x2 vector and i would like to know what is the angle between it and the x axes.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 1 日
v=[2 3]
angle1=angle(v(1)+j*v(2))
  3 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 1 日
編集済み: Azzi Abdelmalek 2013 年 10 月 1 日
the vector v is represented by two coordinates v(1) and v(2), or by the complex number v(1)+j*v(2)
Jan
Jan 2013 年 10 月 1 日
@Azzi: Better use 1i for the imaginary unit for clarity.

サインインしてコメントする。

その他の回答 (1 件)

Jan
Jan 2013 年 10 月 1 日
This is the included angle in the range [0, pi]:
v = [rand, rand];
angle = atan2(abs(v(2)), v1)
Perhaps you want an oriented angle from [0, 2*pi] or [-pi, pi]?
  1 件のコメント
Maayan
Maayan 2013 年 10 月 1 日
I will explain you what i'm trying to do and then maybe my problem will be clearer. I have an intensity image where i marked with the impoly function a region of interest. I have a code that gives me back the vertices of the smallest rectangle still containing my polygon. The rectangle is MOST of the times not aligned with the axes. I would like to receive the data inside the rectangle into a matrix form.I have been trying to find out the angle between the largest side of the rectangle and the x axis and then to rotate the image so the rectangle will be aligned with the axes but with no success. I'm using the imrotate function but the rotation isn't happening how i expected.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by