How can I rotate a vector by a certain amount along a specific plane?
이전 댓글 표시
I have three points in inertial space which is enough to specify a plane. I have a vector that lies in this plane, and would like to rotate this vector so that it becomes perpendicular with its original self, through a rotation about the plane. For example:
my points:
a=[1 .3 .5];
b=[0 0 0];
c=[4 5 6];
%plane passes through points a, b, and c, a is the vector to rotate
EDIT
I mean to say a rotation on the plane (rotating with the pivot being the origin 0,0,0)
채택된 답변
추가 답변 (1개)
Bjorn Gustavsson
2021년 5월 31일
편집: Bjorn Gustavsson
2021년 6월 1일
Simply take another vector that lies in your plane, here c (you should understand why we can use c straight away). Then form an array that's in the plane but perpendicular to a:
d = c-dot(c,a)*a;
Then you get a vector that's perpendicular to a:
g = cross(a,d);
Here you'll have to plug in a normalization in order to not scale a. That was for rotating a out of the plane. For the rotation around the normal-vector of the plane you're close to done after the calculation of d - just normalize it to give it the same length as a.
HTH
댓글 수: 8
Alessandro Maria Laspina
2021년 5월 31일
Bjorn Gustavsson
2021년 5월 31일
Ok, so then use that part of my solution.
Alessandro Maria Laspina
2021년 6월 1일
Alessandro Maria Laspina
2021년 6월 1일
Bjorn Gustavsson
2021년 6월 1일
편집: Bjorn Gustavsson
2021년 6월 3일
OK, fixed a typo. The vector d lies in the plane you want and is perpendicultar to a - provided the array c does not happen to be parallel or anti-parallel with a (which is statistically improbable, but you should most likely check for that). This is easy to see if you sketch on paper - you'll just imagine being lucky enough that your plane lies perfectly aligned with the paper. Since this array is perpendicular to a you only need to scale it to have the same length as a, if you have a direction-preference you might also multipy the vector with -1.
d = c-dot(c,a)*a/norm(a)^2; % perp to a
d = d*norm(a)/norm(d); % scaled to same length
HTH
Alessandro Maria Laspina
2021년 6월 3일
편집: Alessandro Maria Laspina
2021년 6월 3일
Alessandro Maria Laspina
2021년 6월 3일
편집: Alessandro Maria Laspina
2021년 6월 3일
Bjorn Gustavsson
2021년 6월 3일
OK, now I think I've fixed the typos properly. The correct equation should be:
d = c-dot(c,a/norm(a))*a/norm(a); % subtract the projection of c in the direction of a to get a vector perp to a
d = d*norm(a)/norm(d); % scaled to same length of a
카테고리
도움말 센터 및 File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!