How does vrrotvec calculate rotation?

18 ビュー (過去 30 日間)
Michael McGeehan
Michael McGeehan 2021 年 11 月 17 日
編集済み: James Tursa 2023 年 5 月 12 日
Can anybody describe the math behind vrrotvec? The documentation for this function is very sparse and I would like to know how the rotational transformation is being calculated for my own confiendence in my code.
Thanks!

採用された回答

James Tursa
James Tursa 2021 年 11 月 17 日
It is a simple algorithm that uses the cross product for the axis (normalized), and the dot product is used to calculate the angle. I.e., vrrotvec(x,y) is equivalent to the following (but with error checking etc.)
rotation axis = cross(x,y)/norm(cross(x,y))
rotation angle = acos(dot(x,y)/(norm(x)*norm(y)))
then these are concatenated into a 4-element vector
  3 件のコメント
Vignesh Radhakrishnan
Vignesh Radhakrishnan 2023 年 4 月 21 日
Can I get the point y again from x using the inverse of the output of vrrotvec or vrrotvec2mat?
James Tursa
James Tursa 2023 年 5 月 12 日
編集済み: James Tursa 2023 年 5 月 12 日
Do you mean like this?
x = rand(3,1); x = x/norm(x)
x = 3×1
0.7639 0.6442 0.0390
y = rand(3,1); y = y/norm(y)
y = 3×1
0.6172 0.5255 0.5856
r = vrrotvec(x,y)
r = 1×4
0.6445 -0.7646 0.0068 0.5866
m = vrrotvec2mat(r)
m = 3×3
0.9023 -0.0862 -0.4225 -0.0786 0.9306 -0.3576 0.4240 0.3559 0.8328
m * x
ans = 3×1
0.6172 0.5255 0.5856
norm(ans-y)
ans = 1.5701e-16

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by