Use a matrix to rotate a vector in the direction of another vector
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have two 3D vectors, say A and B, that are perpendicular to each other in an arbitrary plane in 3D space. A and B share origin point P. I would like to rotate vector A in this plane (pivoting about point P) towards vector B by a certain number of degrees $theta$ (or away from B if $theta$ is negative). I would like to do this via a transformation matrix, but I'm having some trouble crafting one on my own. How would I go about this?
vectors transformation
add a comment |Â
up vote
0
down vote
favorite
I have two 3D vectors, say A and B, that are perpendicular to each other in an arbitrary plane in 3D space. A and B share origin point P. I would like to rotate vector A in this plane (pivoting about point P) towards vector B by a certain number of degrees $theta$ (or away from B if $theta$ is negative). I would like to do this via a transformation matrix, but I'm having some trouble crafting one on my own. How would I go about this?
vectors transformation
In your idea vectors A and B have an origin in common?
– gimusi
Jul 25 at 22:07
and is the plane through the origin?
– gimusi
Jul 25 at 22:12
@gimusi yes and yes
– derekantrican
Jul 26 at 12:55
ok then I can revise my answer a little bit to simplify that, if you have some numerica example I can try to solve it
– gimusi
Jul 26 at 12:57
@gimusi I have updated my question a little bit. I will try to draw a picture or something
– derekantrican
Jul 26 at 13:00
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have two 3D vectors, say A and B, that are perpendicular to each other in an arbitrary plane in 3D space. A and B share origin point P. I would like to rotate vector A in this plane (pivoting about point P) towards vector B by a certain number of degrees $theta$ (or away from B if $theta$ is negative). I would like to do this via a transformation matrix, but I'm having some trouble crafting one on my own. How would I go about this?
vectors transformation
I have two 3D vectors, say A and B, that are perpendicular to each other in an arbitrary plane in 3D space. A and B share origin point P. I would like to rotate vector A in this plane (pivoting about point P) towards vector B by a certain number of degrees $theta$ (or away from B if $theta$ is negative). I would like to do this via a transformation matrix, but I'm having some trouble crafting one on my own. How would I go about this?
vectors transformation
edited Jul 26 at 12:59
asked Jul 25 at 21:55


derekantrican
1104
1104
In your idea vectors A and B have an origin in common?
– gimusi
Jul 25 at 22:07
and is the plane through the origin?
– gimusi
Jul 25 at 22:12
@gimusi yes and yes
– derekantrican
Jul 26 at 12:55
ok then I can revise my answer a little bit to simplify that, if you have some numerica example I can try to solve it
– gimusi
Jul 26 at 12:57
@gimusi I have updated my question a little bit. I will try to draw a picture or something
– derekantrican
Jul 26 at 13:00
add a comment |Â
In your idea vectors A and B have an origin in common?
– gimusi
Jul 25 at 22:07
and is the plane through the origin?
– gimusi
Jul 25 at 22:12
@gimusi yes and yes
– derekantrican
Jul 26 at 12:55
ok then I can revise my answer a little bit to simplify that, if you have some numerica example I can try to solve it
– gimusi
Jul 26 at 12:57
@gimusi I have updated my question a little bit. I will try to draw a picture or something
– derekantrican
Jul 26 at 13:00
In your idea vectors A and B have an origin in common?
– gimusi
Jul 25 at 22:07
In your idea vectors A and B have an origin in common?
– gimusi
Jul 25 at 22:07
and is the plane through the origin?
– gimusi
Jul 25 at 22:12
and is the plane through the origin?
– gimusi
Jul 25 at 22:12
@gimusi yes and yes
– derekantrican
Jul 26 at 12:55
@gimusi yes and yes
– derekantrican
Jul 26 at 12:55
ok then I can revise my answer a little bit to simplify that, if you have some numerica example I can try to solve it
– gimusi
Jul 26 at 12:57
ok then I can revise my answer a little bit to simplify that, if you have some numerica example I can try to solve it
– gimusi
Jul 26 at 12:57
@gimusi I have updated my question a little bit. I will try to draw a picture or something
– derekantrican
Jul 26 at 13:00
@gimusi I have updated my question a little bit. I will try to draw a picture or something
– derekantrican
Jul 26 at 13:00
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
3
down vote
accepted
You don’t really need to construct a matrix to do this. Since $A$ and $B$ are orthogonal, $mathbf u = A/|A|$ and $mathbf v = B/|B|$ form an orthonormal basis for their common plane. If you rotate $mathbf u$ through an angle $theta$ toward $mathbf v$, you get $mathbf ucostheta+mathbf vsintheta$, so to rotate $A$ toward $B$, simply multiply this by $|A|$, i.e., $$Acostheta + B Bsintheta.$$
If you really want a matrix, you can use Rodrigues’ rotation formula to construct one. Let $mathbf n = $, the right-handed normal to the plane of rotation, and designate by $mathbf N$ its “cross-product matrix†$$mathbf N = beginbmatrix0&-n_z&n_y\n_z&0&-n_x\-n_y&n_x&0endbmatrix.$$ The corresponding rotation matrix is then $$mathbf R = mathbf I + (sintheta)mathbf N + (1-costheta)mathbf N^2.$$
We don't need but we can always do that! By the way, very useful answer.
– gimusi
Jul 26 at 13:04
Excellent. Your first solutionAcosθ+(∥A∥/∥B∥)Bsinθ
ended up being what I used. Thank you!
– derekantrican
Jul 26 at 15:52
add a comment |Â
up vote
0
down vote
Hint:
first, move your reference system to be in $x'=A/|A|,y'=B/|B|,z'=(A/|A|) times (B/|B|)$, through the corresponding transformation matrix T;
then apply a rotation matrix $R$ bringing $x'$ towards $y'$ by the required angle
finally multiply by $T^-1$
add a comment |Â
up vote
0
down vote
First replace $A$ by $A/|A|$, and similarly for $B$, so that they're unit vectors.
Compute $C = A times B$, the cross product. Let $M$ by the matrix whose columns are $A, B, C$; then $M^-1$ happens to be $M^t$, which is easy to compute -- just put in $A, B, C$ as the rows!
Now let
$$
R = M S M^-1 = M S M^t
$$
where
$$
S = pmatrixc & -s & 0 \
s & c & 0 \
0 & 0 & 1
$$
where $c = cos theta$ and $s = sin theta$, and $R$ is the rotation matrix that you want.
NB: Note that if $theta$ is in degrees, then you need to use $c = cos (pi * theta / 180)$, and similarly for $s$, where $sin$ and $cos$ denote the usual functions that work on angles expressed in radians.
add a comment |Â
up vote
0
down vote
We can proceed as follow
- Fix a basis $mathcalB=v_1,v_2,v_3$ with $v_1=n$ is the normal to the plane, $v_2=A$ and $v_3=B$.
- Then write the rotation matrix $R_mathcalB$ with respect to that basis (we can use the standard rotation matrix).
- Then with respect to the canonical basis, indicating with $M=[v_1,v_2,v_3]$ we have
$$w_mathcalB=R_mathcalBv_mathcalB implies M^-1w=R_mathcalBM^-1vimplies w=MR_mathcalBM^-1v=Rv$$
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You don’t really need to construct a matrix to do this. Since $A$ and $B$ are orthogonal, $mathbf u = A/|A|$ and $mathbf v = B/|B|$ form an orthonormal basis for their common plane. If you rotate $mathbf u$ through an angle $theta$ toward $mathbf v$, you get $mathbf ucostheta+mathbf vsintheta$, so to rotate $A$ toward $B$, simply multiply this by $|A|$, i.e., $$Acostheta + B Bsintheta.$$
If you really want a matrix, you can use Rodrigues’ rotation formula to construct one. Let $mathbf n = $, the right-handed normal to the plane of rotation, and designate by $mathbf N$ its “cross-product matrix†$$mathbf N = beginbmatrix0&-n_z&n_y\n_z&0&-n_x\-n_y&n_x&0endbmatrix.$$ The corresponding rotation matrix is then $$mathbf R = mathbf I + (sintheta)mathbf N + (1-costheta)mathbf N^2.$$
We don't need but we can always do that! By the way, very useful answer.
– gimusi
Jul 26 at 13:04
Excellent. Your first solutionAcosθ+(∥A∥/∥B∥)Bsinθ
ended up being what I used. Thank you!
– derekantrican
Jul 26 at 15:52
add a comment |Â
up vote
3
down vote
accepted
You don’t really need to construct a matrix to do this. Since $A$ and $B$ are orthogonal, $mathbf u = A/|A|$ and $mathbf v = B/|B|$ form an orthonormal basis for their common plane. If you rotate $mathbf u$ through an angle $theta$ toward $mathbf v$, you get $mathbf ucostheta+mathbf vsintheta$, so to rotate $A$ toward $B$, simply multiply this by $|A|$, i.e., $$Acostheta + B Bsintheta.$$
If you really want a matrix, you can use Rodrigues’ rotation formula to construct one. Let $mathbf n = $, the right-handed normal to the plane of rotation, and designate by $mathbf N$ its “cross-product matrix†$$mathbf N = beginbmatrix0&-n_z&n_y\n_z&0&-n_x\-n_y&n_x&0endbmatrix.$$ The corresponding rotation matrix is then $$mathbf R = mathbf I + (sintheta)mathbf N + (1-costheta)mathbf N^2.$$
We don't need but we can always do that! By the way, very useful answer.
– gimusi
Jul 26 at 13:04
Excellent. Your first solutionAcosθ+(∥A∥/∥B∥)Bsinθ
ended up being what I used. Thank you!
– derekantrican
Jul 26 at 15:52
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You don’t really need to construct a matrix to do this. Since $A$ and $B$ are orthogonal, $mathbf u = A/|A|$ and $mathbf v = B/|B|$ form an orthonormal basis for their common plane. If you rotate $mathbf u$ through an angle $theta$ toward $mathbf v$, you get $mathbf ucostheta+mathbf vsintheta$, so to rotate $A$ toward $B$, simply multiply this by $|A|$, i.e., $$Acostheta + B Bsintheta.$$
If you really want a matrix, you can use Rodrigues’ rotation formula to construct one. Let $mathbf n = $, the right-handed normal to the plane of rotation, and designate by $mathbf N$ its “cross-product matrix†$$mathbf N = beginbmatrix0&-n_z&n_y\n_z&0&-n_x\-n_y&n_x&0endbmatrix.$$ The corresponding rotation matrix is then $$mathbf R = mathbf I + (sintheta)mathbf N + (1-costheta)mathbf N^2.$$
You don’t really need to construct a matrix to do this. Since $A$ and $B$ are orthogonal, $mathbf u = A/|A|$ and $mathbf v = B/|B|$ form an orthonormal basis for their common plane. If you rotate $mathbf u$ through an angle $theta$ toward $mathbf v$, you get $mathbf ucostheta+mathbf vsintheta$, so to rotate $A$ toward $B$, simply multiply this by $|A|$, i.e., $$Acostheta + B Bsintheta.$$
If you really want a matrix, you can use Rodrigues’ rotation formula to construct one. Let $mathbf n = $, the right-handed normal to the plane of rotation, and designate by $mathbf N$ its “cross-product matrix†$$mathbf N = beginbmatrix0&-n_z&n_y\n_z&0&-n_x\-n_y&n_x&0endbmatrix.$$ The corresponding rotation matrix is then $$mathbf R = mathbf I + (sintheta)mathbf N + (1-costheta)mathbf N^2.$$
edited Jul 26 at 8:33
answered Jul 26 at 8:14
amd
25.8k2943
25.8k2943
We don't need but we can always do that! By the way, very useful answer.
– gimusi
Jul 26 at 13:04
Excellent. Your first solutionAcosθ+(∥A∥/∥B∥)Bsinθ
ended up being what I used. Thank you!
– derekantrican
Jul 26 at 15:52
add a comment |Â
We don't need but we can always do that! By the way, very useful answer.
– gimusi
Jul 26 at 13:04
Excellent. Your first solutionAcosθ+(∥A∥/∥B∥)Bsinθ
ended up being what I used. Thank you!
– derekantrican
Jul 26 at 15:52
We don't need but we can always do that! By the way, very useful answer.
– gimusi
Jul 26 at 13:04
We don't need but we can always do that! By the way, very useful answer.
– gimusi
Jul 26 at 13:04
Excellent. Your first solution
Acosθ+(∥A∥/∥B∥)Bsinθ
ended up being what I used. Thank you!– derekantrican
Jul 26 at 15:52
Excellent. Your first solution
Acosθ+(∥A∥/∥B∥)Bsinθ
ended up being what I used. Thank you!– derekantrican
Jul 26 at 15:52
add a comment |Â
up vote
0
down vote
Hint:
first, move your reference system to be in $x'=A/|A|,y'=B/|B|,z'=(A/|A|) times (B/|B|)$, through the corresponding transformation matrix T;
then apply a rotation matrix $R$ bringing $x'$ towards $y'$ by the required angle
finally multiply by $T^-1$
add a comment |Â
up vote
0
down vote
Hint:
first, move your reference system to be in $x'=A/|A|,y'=B/|B|,z'=(A/|A|) times (B/|B|)$, through the corresponding transformation matrix T;
then apply a rotation matrix $R$ bringing $x'$ towards $y'$ by the required angle
finally multiply by $T^-1$
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Hint:
first, move your reference system to be in $x'=A/|A|,y'=B/|B|,z'=(A/|A|) times (B/|B|)$, through the corresponding transformation matrix T;
then apply a rotation matrix $R$ bringing $x'$ towards $y'$ by the required angle
finally multiply by $T^-1$
Hint:
first, move your reference system to be in $x'=A/|A|,y'=B/|B|,z'=(A/|A|) times (B/|B|)$, through the corresponding transformation matrix T;
then apply a rotation matrix $R$ bringing $x'$ towards $y'$ by the required angle
finally multiply by $T^-1$
answered Jul 25 at 22:09
G Cab
15.1k31136
15.1k31136
add a comment |Â
add a comment |Â
up vote
0
down vote
First replace $A$ by $A/|A|$, and similarly for $B$, so that they're unit vectors.
Compute $C = A times B$, the cross product. Let $M$ by the matrix whose columns are $A, B, C$; then $M^-1$ happens to be $M^t$, which is easy to compute -- just put in $A, B, C$ as the rows!
Now let
$$
R = M S M^-1 = M S M^t
$$
where
$$
S = pmatrixc & -s & 0 \
s & c & 0 \
0 & 0 & 1
$$
where $c = cos theta$ and $s = sin theta$, and $R$ is the rotation matrix that you want.
NB: Note that if $theta$ is in degrees, then you need to use $c = cos (pi * theta / 180)$, and similarly for $s$, where $sin$ and $cos$ denote the usual functions that work on angles expressed in radians.
add a comment |Â
up vote
0
down vote
First replace $A$ by $A/|A|$, and similarly for $B$, so that they're unit vectors.
Compute $C = A times B$, the cross product. Let $M$ by the matrix whose columns are $A, B, C$; then $M^-1$ happens to be $M^t$, which is easy to compute -- just put in $A, B, C$ as the rows!
Now let
$$
R = M S M^-1 = M S M^t
$$
where
$$
S = pmatrixc & -s & 0 \
s & c & 0 \
0 & 0 & 1
$$
where $c = cos theta$ and $s = sin theta$, and $R$ is the rotation matrix that you want.
NB: Note that if $theta$ is in degrees, then you need to use $c = cos (pi * theta / 180)$, and similarly for $s$, where $sin$ and $cos$ denote the usual functions that work on angles expressed in radians.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
First replace $A$ by $A/|A|$, and similarly for $B$, so that they're unit vectors.
Compute $C = A times B$, the cross product. Let $M$ by the matrix whose columns are $A, B, C$; then $M^-1$ happens to be $M^t$, which is easy to compute -- just put in $A, B, C$ as the rows!
Now let
$$
R = M S M^-1 = M S M^t
$$
where
$$
S = pmatrixc & -s & 0 \
s & c & 0 \
0 & 0 & 1
$$
where $c = cos theta$ and $s = sin theta$, and $R$ is the rotation matrix that you want.
NB: Note that if $theta$ is in degrees, then you need to use $c = cos (pi * theta / 180)$, and similarly for $s$, where $sin$ and $cos$ denote the usual functions that work on angles expressed in radians.
First replace $A$ by $A/|A|$, and similarly for $B$, so that they're unit vectors.
Compute $C = A times B$, the cross product. Let $M$ by the matrix whose columns are $A, B, C$; then $M^-1$ happens to be $M^t$, which is easy to compute -- just put in $A, B, C$ as the rows!
Now let
$$
R = M S M^-1 = M S M^t
$$
where
$$
S = pmatrixc & -s & 0 \
s & c & 0 \
0 & 0 & 1
$$
where $c = cos theta$ and $s = sin theta$, and $R$ is the rotation matrix that you want.
NB: Note that if $theta$ is in degrees, then you need to use $c = cos (pi * theta / 180)$, and similarly for $s$, where $sin$ and $cos$ denote the usual functions that work on angles expressed in radians.
answered Jul 25 at 22:15
John Hughes
59.4k23785
59.4k23785
add a comment |Â
add a comment |Â
up vote
0
down vote
We can proceed as follow
- Fix a basis $mathcalB=v_1,v_2,v_3$ with $v_1=n$ is the normal to the plane, $v_2=A$ and $v_3=B$.
- Then write the rotation matrix $R_mathcalB$ with respect to that basis (we can use the standard rotation matrix).
- Then with respect to the canonical basis, indicating with $M=[v_1,v_2,v_3]$ we have
$$w_mathcalB=R_mathcalBv_mathcalB implies M^-1w=R_mathcalBM^-1vimplies w=MR_mathcalBM^-1v=Rv$$
add a comment |Â
up vote
0
down vote
We can proceed as follow
- Fix a basis $mathcalB=v_1,v_2,v_3$ with $v_1=n$ is the normal to the plane, $v_2=A$ and $v_3=B$.
- Then write the rotation matrix $R_mathcalB$ with respect to that basis (we can use the standard rotation matrix).
- Then with respect to the canonical basis, indicating with $M=[v_1,v_2,v_3]$ we have
$$w_mathcalB=R_mathcalBv_mathcalB implies M^-1w=R_mathcalBM^-1vimplies w=MR_mathcalBM^-1v=Rv$$
add a comment |Â
up vote
0
down vote
up vote
0
down vote
We can proceed as follow
- Fix a basis $mathcalB=v_1,v_2,v_3$ with $v_1=n$ is the normal to the plane, $v_2=A$ and $v_3=B$.
- Then write the rotation matrix $R_mathcalB$ with respect to that basis (we can use the standard rotation matrix).
- Then with respect to the canonical basis, indicating with $M=[v_1,v_2,v_3]$ we have
$$w_mathcalB=R_mathcalBv_mathcalB implies M^-1w=R_mathcalBM^-1vimplies w=MR_mathcalBM^-1v=Rv$$
We can proceed as follow
- Fix a basis $mathcalB=v_1,v_2,v_3$ with $v_1=n$ is the normal to the plane, $v_2=A$ and $v_3=B$.
- Then write the rotation matrix $R_mathcalB$ with respect to that basis (we can use the standard rotation matrix).
- Then with respect to the canonical basis, indicating with $M=[v_1,v_2,v_3]$ we have
$$w_mathcalB=R_mathcalBv_mathcalB implies M^-1w=R_mathcalBM^-1vimplies w=MR_mathcalBM^-1v=Rv$$
edited Jul 26 at 13:03
answered Jul 25 at 22:27
gimusi
65k73583
65k73583
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2862858%2fuse-a-matrix-to-rotate-a-vector-in-the-direction-of-another-vector%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
In your idea vectors A and B have an origin in common?
– gimusi
Jul 25 at 22:07
and is the plane through the origin?
– gimusi
Jul 25 at 22:12
@gimusi yes and yes
– derekantrican
Jul 26 at 12:55
ok then I can revise my answer a little bit to simplify that, if you have some numerica example I can try to solve it
– gimusi
Jul 26 at 12:57
@gimusi I have updated my question a little bit. I will try to draw a picture or something
– derekantrican
Jul 26 at 13:00