Vector between vectors in intervals

1 回表示 (過去 30 日間)
Arnd Meiser
Arnd Meiser 2019 年 12 月 3 日
回答済み: Jan 2019 年 12 月 4 日
Hello!
I have two orthogonal vectors in a 3d system: [-0.0345;0.9984;-0.0447] and [0.9838;0.0370;0.0431]. I know that by adding the two I can obtain the middle vector, so the one with 45° to both other vectors. What I want is all the other possible angles in intervals, like from the first vector to the second in steps of 5° (5° to the first, 85° to the second etc.). Any ideas?
Thanks in advance

採用された回答

J Chen
J Chen 2019 年 12 月 3 日
vec1 = [-0.0345;0.9984;-0.0447];
angle = 5*pi/180; % angle of rotation in rad
v = vec1 + tan(angle)*vec2; % length of vec1 is 1
v = v/norm(v); % v is an unit vector 5 degrees from vec1
  1 件のコメント
Arnd Meiser
Arnd Meiser 2019 年 12 月 4 日
That works perfectly, thank you very much!

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

その他の回答 (1 件)

Jan
Jan 2019 年 12 月 4 日
Remark: The inputs vectors are not normalized and only almost orthogonal:
format long g
v1 = [-0.0345; 0.9984; -0.0447]
v2 = [0.9838; 0.0370; 0.0431]
norm(v1) % 0.9999954499896486 almost
norm(v2) % 0.9854385064528379
dot(v1, v2) % 0.001073129999999994 almost
I assume, you've posted the values with a limited number of digits. Use format long g to display more digits.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by