# Cross product magnitude computation

조회 수: 5(최근 30일)
Hi,
Trying to get the elements for a RSW reference frame (orbital mechanics concept), I have problems regarding to the magnitude of one cross product between 2 vectors, the results are very innacurate and after searching on internet I got the conclusion that the problem is on the way that I'm trying to compute the cross product magnitude. My code section is as follows:
Please, could you help me to have a better idea of this cross product magnitude?
SZp = [SZ1; SZ2; SZ3]; % Position difference % 3x262 double
SZv = [SZ4; SZ5; SZ6]; % Velocity difference % 3x262 double
% Axes of the RSW system
er = R_p./sqrt((Sen1).^2 + (Sen2).^2 + (Sen3).^2); % | eR = r/|r| % Sen1,2,3 1x262 double, | | eR, eW, eS 3x262 double
rxv = cross(R_p,V_vel); % r x v % 3x262 double
mrxv = sqrt((rxv(1,:)).^2 + (rxv(2,:)).^2 + (rxv(3,:)).^2); % |r x v| !!! TRYING TO COMPUTE CROSS PRODUCT MAGNITUDE
ew = rxv./mrxv; % r x v / |r x v| ALSO THE PROBLEM COULD BE AT THIS STEP, eW is getting strange results despite eR and eS
es = cross(ew,er); % ew x er
% Projection of the difference on each vector, basis vector
R = dot(SZp,er);
S = dot(SZp,es);
W = dot(SZp,ew);

댓글을 달려면 로그인하십시오.

### 답변(1개)

Gaurav Garg 2021년 1월 27일
Hi Hugo,
The cross-product between two 3xm matrices (C = cross(A,B)) is calculated as follows -
1.) For the third row of resultant matrix C, element-wise product of second row of A and first row of B is subtracted from element-wise product of first row of A and second row of B
2.) For the first row of resultant matrix C, element-wise product of third row of A and second row of B is subtracted from element-wise product of second row of A and third row of B
3.) For the second row of resultant matrix C, element-wise product of first row of A and third row of B is subtracted from element-wise product of third row of A and first row of B
##### 댓글 수: 1표시숨기기 없음
Hugo Hernández Hernández 2021년 5월 15일
Thanks @Gaurav Garg, that time my problem was oriented to other structure, the problem was in the using of norm, unfortunately I did not get that exercise in the correct way and was because for the calculation of the magnitude norm is not always the best option, even the way I did it was not correct, eventually I realized some months after my question that the best way was:
eztmv = zeros(size(tan'));
eytmv = zeros(size(tan'));
extmv = zeros(size(tan'));
eytmv = cross(tan',vtan',2)./sqrt(sum(cross(tan',vtan',2).^2,2));
eztmv = tan'./sqrt(sum(tan'.^2,2));
extmv = cross(ey,ez,2);
Rtmv = zeros(2,1);
Wtmv = zeros(2,1);
Stmv = zeros(2,1);
Rtmv = sum(vtan'.*ez,2);
Wtmv = sum(vtan'.*ey,2);
Stmv = sum(vtan'.*ex,2);
With the use of sum and zeros matrices that time could have worked correctly. Anyway thanks for your support.
Hugo

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!