Error with dot product? Dot product of cross product vectors is not 0

3 views (last 30 days)
I am attempting to find a vector normal to a plane. Provided two vectors, and in the plane, a vector normal to both is found using the cross product or . Therefore, and . Have I entered something incorrectly?
%gps reported positions (xSec_DDMMYYYY)
x0_18081997 = [3325396.441 5472597.483 -2057129.050];
x3_18081997 = [3309747.175 5485240.159 -2048664.333];
x0_19081997 = [4389882.255 -4444406.953 -2508462.520];
x3_19081997 = [4402505.030 -4428002.728 -2515303.456];
%determine vector normal to orbital plane
n_18 = cross(x0_18081997,x3_18081997);
check_18 = dot(n_18, x0_18081997);
if ~check_18==0
error('n_18 is not orthogonal to plane.')
end
  1 Comment
Christopher Simpson
Christopher Simpson on 19 Feb 2019
There's some odd behavior where if one of the three elements in either vector is 0 the cross product returns an orthogonal vector.
x0 = [x0_18081997(1) x0_18081997(2) x0_18081997(3)];
x1 = [0 x3_18081997(2) x3_18081997(3)];
ab = cross(x0,x1);
dotab = dot(ab,x0)
But if we use the original vector elements, the cross product no longer returns an orthogonal vector.
x0 = [x0_18081997(1) x0_18081997(2) x0_18081997(3)];
x1 = [x3_18081997(1) x3_18081997(2) x3_18081997(3)];
ab = cross(x0,x1);
dotab = dot(ab,x0)
It is assumed that you've included the script in the original question.

Sign in to comment.

Answers (1)

KSSV
KSSV on 19 Feb 2019
How about trying the same with unit vectors?
%gps reported positions (xSec_DDMMYYYY)
x0_18081997 = [3325396.441 5472597.483 -2057129.050];
x3_18081997 = [3309747.175 5485240.159 -2048664.333];
x0_19081997 = [4389882.255 -4444406.953 -2508462.520];
x3_19081997 = [4402505.030 -4428002.728 -2515303.456];
%determine vector normal to orbital plane
x0_18081997 = x0_18081997/norm(x0_18081997) ;
x3_18081997 = x3_18081997/norm(x3_18081997) ;
n_18 = cross(x0_18081997,x3_18081997);
check_18 = dot(n_18, x0_18081997);
if ~abs(check_18)>=10^-6
error('n_18 is not orthogonal to plane.')
end
  4 Comments
Christopher Simpson
Christopher Simpson on 19 Feb 2019
I get that you're trying to say that it's basically 0.
  • Why are we left with some trace value?
  • Why only when we reduce the magnitude are we able to escape the error?
  • Am I going to need to reduce every vector I use a cross product for to a unit vector first?
  • I thought this was an analytical function. Why would we get some machine remainder for 0?

Sign in to comment.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!