Minimal rotation matrix for two vectors in $mathbbR^n$

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












Suppose we have two normal vectors $v, u in mathbbR^n, |u|_2=1, |v|_2=1$. We would like to find a rotation matrix $RinmathbbR^n times n$ that satisfies
$R u = v$. This clearly does not uniquely determine matrix $R$ because there are only $n$ equations while there are $n(n-1)/2$ degrees of freedom for $R$. However we can make it unique by forcing it to only rotate vectors in the $Spanu,v$. In other words:
$$forall w in Spanu,v^perp : R w = w$$
Intuitively, it only rotates vectors in the $Spanu,v$ plane while leaving every other direction untouched. In this sense, the rotation matrix is minimal.



In the very simple case that $Spanu,v = Spane_i,e_j$, i.e., the linear space spanned by $u,v$ is the same as the one spanned by $e_i, e_j$ we can compute $R$ as follows: $R = I_n - M$, in which $Min mathbbR^ntimes n$ is only zeros except for its $i$-th and $j$-th rows and columns:
$$M_i, jtimes i, j = beginbmatrix
1-cos theta & sin theta\
-sintheta & 1-costheta \
endbmatrix$$
in which $theta = cos^-1 langle u, v rangle$



Is there a way to compute the rotation matrix for general normal vectors $u, v$?







share|cite|improve this question





















  • Your rotation can be computed as a product of two Householder reflections
    – Omnomnomnom
    Jul 25 at 16:31











  • @MikeEarnest that's what I thought at first too. But it seems $R R^T = I + v v^T - u u^T$, while it's supposed to be $I$, am I right?
    – kvphxga
    Jul 25 at 16:32







  • 1




    The first reflection is in the angle bisector of $u$ and $v$.
    – amd
    Jul 25 at 16:57






  • 1




    Have a look at this math.stackexchange.com/a/598782/485657
    – Mauricio Cele Lopez Belon
    Jul 25 at 21:55














up vote
3
down vote

favorite












Suppose we have two normal vectors $v, u in mathbbR^n, |u|_2=1, |v|_2=1$. We would like to find a rotation matrix $RinmathbbR^n times n$ that satisfies
$R u = v$. This clearly does not uniquely determine matrix $R$ because there are only $n$ equations while there are $n(n-1)/2$ degrees of freedom for $R$. However we can make it unique by forcing it to only rotate vectors in the $Spanu,v$. In other words:
$$forall w in Spanu,v^perp : R w = w$$
Intuitively, it only rotates vectors in the $Spanu,v$ plane while leaving every other direction untouched. In this sense, the rotation matrix is minimal.



In the very simple case that $Spanu,v = Spane_i,e_j$, i.e., the linear space spanned by $u,v$ is the same as the one spanned by $e_i, e_j$ we can compute $R$ as follows: $R = I_n - M$, in which $Min mathbbR^ntimes n$ is only zeros except for its $i$-th and $j$-th rows and columns:
$$M_i, jtimes i, j = beginbmatrix
1-cos theta & sin theta\
-sintheta & 1-costheta \
endbmatrix$$
in which $theta = cos^-1 langle u, v rangle$



Is there a way to compute the rotation matrix for general normal vectors $u, v$?







share|cite|improve this question





















  • Your rotation can be computed as a product of two Householder reflections
    – Omnomnomnom
    Jul 25 at 16:31











  • @MikeEarnest that's what I thought at first too. But it seems $R R^T = I + v v^T - u u^T$, while it's supposed to be $I$, am I right?
    – kvphxga
    Jul 25 at 16:32







  • 1




    The first reflection is in the angle bisector of $u$ and $v$.
    – amd
    Jul 25 at 16:57






  • 1




    Have a look at this math.stackexchange.com/a/598782/485657
    – Mauricio Cele Lopez Belon
    Jul 25 at 21:55












up vote
3
down vote

favorite









up vote
3
down vote

favorite











Suppose we have two normal vectors $v, u in mathbbR^n, |u|_2=1, |v|_2=1$. We would like to find a rotation matrix $RinmathbbR^n times n$ that satisfies
$R u = v$. This clearly does not uniquely determine matrix $R$ because there are only $n$ equations while there are $n(n-1)/2$ degrees of freedom for $R$. However we can make it unique by forcing it to only rotate vectors in the $Spanu,v$. In other words:
$$forall w in Spanu,v^perp : R w = w$$
Intuitively, it only rotates vectors in the $Spanu,v$ plane while leaving every other direction untouched. In this sense, the rotation matrix is minimal.



In the very simple case that $Spanu,v = Spane_i,e_j$, i.e., the linear space spanned by $u,v$ is the same as the one spanned by $e_i, e_j$ we can compute $R$ as follows: $R = I_n - M$, in which $Min mathbbR^ntimes n$ is only zeros except for its $i$-th and $j$-th rows and columns:
$$M_i, jtimes i, j = beginbmatrix
1-cos theta & sin theta\
-sintheta & 1-costheta \
endbmatrix$$
in which $theta = cos^-1 langle u, v rangle$



Is there a way to compute the rotation matrix for general normal vectors $u, v$?







share|cite|improve this question













Suppose we have two normal vectors $v, u in mathbbR^n, |u|_2=1, |v|_2=1$. We would like to find a rotation matrix $RinmathbbR^n times n$ that satisfies
$R u = v$. This clearly does not uniquely determine matrix $R$ because there are only $n$ equations while there are $n(n-1)/2$ degrees of freedom for $R$. However we can make it unique by forcing it to only rotate vectors in the $Spanu,v$. In other words:
$$forall w in Spanu,v^perp : R w = w$$
Intuitively, it only rotates vectors in the $Spanu,v$ plane while leaving every other direction untouched. In this sense, the rotation matrix is minimal.



In the very simple case that $Spanu,v = Spane_i,e_j$, i.e., the linear space spanned by $u,v$ is the same as the one spanned by $e_i, e_j$ we can compute $R$ as follows: $R = I_n - M$, in which $Min mathbbR^ntimes n$ is only zeros except for its $i$-th and $j$-th rows and columns:
$$M_i, jtimes i, j = beginbmatrix
1-cos theta & sin theta\
-sintheta & 1-costheta \
endbmatrix$$
in which $theta = cos^-1 langle u, v rangle$



Is there a way to compute the rotation matrix for general normal vectors $u, v$?









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 25 at 16:34
























asked Jul 25 at 16:15









kvphxga

1163




1163











  • Your rotation can be computed as a product of two Householder reflections
    – Omnomnomnom
    Jul 25 at 16:31











  • @MikeEarnest that's what I thought at first too. But it seems $R R^T = I + v v^T - u u^T$, while it's supposed to be $I$, am I right?
    – kvphxga
    Jul 25 at 16:32







  • 1




    The first reflection is in the angle bisector of $u$ and $v$.
    – amd
    Jul 25 at 16:57






  • 1




    Have a look at this math.stackexchange.com/a/598782/485657
    – Mauricio Cele Lopez Belon
    Jul 25 at 21:55
















  • Your rotation can be computed as a product of two Householder reflections
    – Omnomnomnom
    Jul 25 at 16:31











  • @MikeEarnest that's what I thought at first too. But it seems $R R^T = I + v v^T - u u^T$, while it's supposed to be $I$, am I right?
    – kvphxga
    Jul 25 at 16:32







  • 1




    The first reflection is in the angle bisector of $u$ and $v$.
    – amd
    Jul 25 at 16:57






  • 1




    Have a look at this math.stackexchange.com/a/598782/485657
    – Mauricio Cele Lopez Belon
    Jul 25 at 21:55















Your rotation can be computed as a product of two Householder reflections
– Omnomnomnom
Jul 25 at 16:31





Your rotation can be computed as a product of two Householder reflections
– Omnomnomnom
Jul 25 at 16:31













@MikeEarnest that's what I thought at first too. But it seems $R R^T = I + v v^T - u u^T$, while it's supposed to be $I$, am I right?
– kvphxga
Jul 25 at 16:32





@MikeEarnest that's what I thought at first too. But it seems $R R^T = I + v v^T - u u^T$, while it's supposed to be $I$, am I right?
– kvphxga
Jul 25 at 16:32





1




1




The first reflection is in the angle bisector of $u$ and $v$.
– amd
Jul 25 at 16:57




The first reflection is in the angle bisector of $u$ and $v$.
– amd
Jul 25 at 16:57




1




1




Have a look at this math.stackexchange.com/a/598782/485657
– Mauricio Cele Lopez Belon
Jul 25 at 21:55




Have a look at this math.stackexchange.com/a/598782/485657
– Mauricio Cele Lopez Belon
Jul 25 at 21:55










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Too long for a comment... Let $a^top$ be the projection of $a$ onto the span of $u$ and $v$ such that $a=a^top+a^perp$. Then rotate $a^top$ by $theta$ and add $a^perp$ again.



Alternatively: Extend $u,v$ to a basis. We want $u$ to be mapped to $v$ and $v$ mapped to $2langle u,vrangle v-u$. In respect to this basis the matrix of $R$ is the identity except for the upper left $2times2$ entries; they read
$$beginpmatrix0&-1\ 1&2langle u,vrangleendpmatrix.$$



Even more alternatively: call $c=langle u,vrangle$. Now compute as usual — with a little help of the Gram-matrix of $u$ and $v$ — the tangential component
$$a^top=frac11-c^2bigl((langle u,arangle-clangle v,arangle)u
+(langle v,arangle-clangle u,arangle)vbigr).$$



To obtain $Ra^top$ change $u$ to $v$ and $v$ to $2cv-u$. Now compute
$$Ra=a^perp+Ra^top=a-a^top+Ra^top
=a-frac11+cbigl(langle u+v,arangle u+langle v-(1+2c)u,arangle vbigr).$$






share|cite|improve this answer























  • doesn't $a=⟨a,u⟩u+⟨a,v⟩v+a^perp$ imply $u$ and $v$ must be orthogonal?
    – kvphxga
    Jul 25 at 17:21










  • Yes, you’re right, I will edit.
    – Michael Hoppe
    Jul 25 at 17:40










  • I actually thought of this and tried to find a closed form, but it turned out to be surprisingly messy. But maybe I miscalculated something.
    – kvphxga
    Jul 25 at 18:30










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2862571%2fminimal-rotation-matrix-for-two-vectors-in-mathbbrn%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Too long for a comment... Let $a^top$ be the projection of $a$ onto the span of $u$ and $v$ such that $a=a^top+a^perp$. Then rotate $a^top$ by $theta$ and add $a^perp$ again.



Alternatively: Extend $u,v$ to a basis. We want $u$ to be mapped to $v$ and $v$ mapped to $2langle u,vrangle v-u$. In respect to this basis the matrix of $R$ is the identity except for the upper left $2times2$ entries; they read
$$beginpmatrix0&-1\ 1&2langle u,vrangleendpmatrix.$$



Even more alternatively: call $c=langle u,vrangle$. Now compute as usual — with a little help of the Gram-matrix of $u$ and $v$ — the tangential component
$$a^top=frac11-c^2bigl((langle u,arangle-clangle v,arangle)u
+(langle v,arangle-clangle u,arangle)vbigr).$$



To obtain $Ra^top$ change $u$ to $v$ and $v$ to $2cv-u$. Now compute
$$Ra=a^perp+Ra^top=a-a^top+Ra^top
=a-frac11+cbigl(langle u+v,arangle u+langle v-(1+2c)u,arangle vbigr).$$






share|cite|improve this answer























  • doesn't $a=⟨a,u⟩u+⟨a,v⟩v+a^perp$ imply $u$ and $v$ must be orthogonal?
    – kvphxga
    Jul 25 at 17:21










  • Yes, you’re right, I will edit.
    – Michael Hoppe
    Jul 25 at 17:40










  • I actually thought of this and tried to find a closed form, but it turned out to be surprisingly messy. But maybe I miscalculated something.
    – kvphxga
    Jul 25 at 18:30














up vote
0
down vote













Too long for a comment... Let $a^top$ be the projection of $a$ onto the span of $u$ and $v$ such that $a=a^top+a^perp$. Then rotate $a^top$ by $theta$ and add $a^perp$ again.



Alternatively: Extend $u,v$ to a basis. We want $u$ to be mapped to $v$ and $v$ mapped to $2langle u,vrangle v-u$. In respect to this basis the matrix of $R$ is the identity except for the upper left $2times2$ entries; they read
$$beginpmatrix0&-1\ 1&2langle u,vrangleendpmatrix.$$



Even more alternatively: call $c=langle u,vrangle$. Now compute as usual — with a little help of the Gram-matrix of $u$ and $v$ — the tangential component
$$a^top=frac11-c^2bigl((langle u,arangle-clangle v,arangle)u
+(langle v,arangle-clangle u,arangle)vbigr).$$



To obtain $Ra^top$ change $u$ to $v$ and $v$ to $2cv-u$. Now compute
$$Ra=a^perp+Ra^top=a-a^top+Ra^top
=a-frac11+cbigl(langle u+v,arangle u+langle v-(1+2c)u,arangle vbigr).$$






share|cite|improve this answer























  • doesn't $a=⟨a,u⟩u+⟨a,v⟩v+a^perp$ imply $u$ and $v$ must be orthogonal?
    – kvphxga
    Jul 25 at 17:21










  • Yes, you’re right, I will edit.
    – Michael Hoppe
    Jul 25 at 17:40










  • I actually thought of this and tried to find a closed form, but it turned out to be surprisingly messy. But maybe I miscalculated something.
    – kvphxga
    Jul 25 at 18:30












up vote
0
down vote










up vote
0
down vote









Too long for a comment... Let $a^top$ be the projection of $a$ onto the span of $u$ and $v$ such that $a=a^top+a^perp$. Then rotate $a^top$ by $theta$ and add $a^perp$ again.



Alternatively: Extend $u,v$ to a basis. We want $u$ to be mapped to $v$ and $v$ mapped to $2langle u,vrangle v-u$. In respect to this basis the matrix of $R$ is the identity except for the upper left $2times2$ entries; they read
$$beginpmatrix0&-1\ 1&2langle u,vrangleendpmatrix.$$



Even more alternatively: call $c=langle u,vrangle$. Now compute as usual — with a little help of the Gram-matrix of $u$ and $v$ — the tangential component
$$a^top=frac11-c^2bigl((langle u,arangle-clangle v,arangle)u
+(langle v,arangle-clangle u,arangle)vbigr).$$



To obtain $Ra^top$ change $u$ to $v$ and $v$ to $2cv-u$. Now compute
$$Ra=a^perp+Ra^top=a-a^top+Ra^top
=a-frac11+cbigl(langle u+v,arangle u+langle v-(1+2c)u,arangle vbigr).$$






share|cite|improve this answer















Too long for a comment... Let $a^top$ be the projection of $a$ onto the span of $u$ and $v$ such that $a=a^top+a^perp$. Then rotate $a^top$ by $theta$ and add $a^perp$ again.



Alternatively: Extend $u,v$ to a basis. We want $u$ to be mapped to $v$ and $v$ mapped to $2langle u,vrangle v-u$. In respect to this basis the matrix of $R$ is the identity except for the upper left $2times2$ entries; they read
$$beginpmatrix0&-1\ 1&2langle u,vrangleendpmatrix.$$



Even more alternatively: call $c=langle u,vrangle$. Now compute as usual — with a little help of the Gram-matrix of $u$ and $v$ — the tangential component
$$a^top=frac11-c^2bigl((langle u,arangle-clangle v,arangle)u
+(langle v,arangle-clangle u,arangle)vbigr).$$



To obtain $Ra^top$ change $u$ to $v$ and $v$ to $2cv-u$. Now compute
$$Ra=a^perp+Ra^top=a-a^top+Ra^top
=a-frac11+cbigl(langle u+v,arangle u+langle v-(1+2c)u,arangle vbigr).$$







share|cite|improve this answer















share|cite|improve this answer



share|cite|improve this answer








edited Jul 26 at 16:54


























answered Jul 25 at 17:09









Michael Hoppe

9,55631432




9,55631432











  • doesn't $a=⟨a,u⟩u+⟨a,v⟩v+a^perp$ imply $u$ and $v$ must be orthogonal?
    – kvphxga
    Jul 25 at 17:21










  • Yes, you’re right, I will edit.
    – Michael Hoppe
    Jul 25 at 17:40










  • I actually thought of this and tried to find a closed form, but it turned out to be surprisingly messy. But maybe I miscalculated something.
    – kvphxga
    Jul 25 at 18:30
















  • doesn't $a=⟨a,u⟩u+⟨a,v⟩v+a^perp$ imply $u$ and $v$ must be orthogonal?
    – kvphxga
    Jul 25 at 17:21










  • Yes, you’re right, I will edit.
    – Michael Hoppe
    Jul 25 at 17:40










  • I actually thought of this and tried to find a closed form, but it turned out to be surprisingly messy. But maybe I miscalculated something.
    – kvphxga
    Jul 25 at 18:30















doesn't $a=⟨a,u⟩u+⟨a,v⟩v+a^perp$ imply $u$ and $v$ must be orthogonal?
– kvphxga
Jul 25 at 17:21




doesn't $a=⟨a,u⟩u+⟨a,v⟩v+a^perp$ imply $u$ and $v$ must be orthogonal?
– kvphxga
Jul 25 at 17:21












Yes, you’re right, I will edit.
– Michael Hoppe
Jul 25 at 17:40




Yes, you’re right, I will edit.
– Michael Hoppe
Jul 25 at 17:40












I actually thought of this and tried to find a closed form, but it turned out to be surprisingly messy. But maybe I miscalculated something.
– kvphxga
Jul 25 at 18:30




I actually thought of this and tried to find a closed form, but it turned out to be surprisingly messy. But maybe I miscalculated something.
– kvphxga
Jul 25 at 18:30












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2862571%2fminimal-rotation-matrix-for-two-vectors-in-mathbbrn%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What is the equation of a 3D cone with generalised tilt?

Color the edges and diagonals of a regular polygon

Relationship between determinant of matrix and determinant of adjoint?