03-25-2016, 01:47 AM 
	
	
	
		Hi there
In a code I'm working, at some point I have two vectors with these values:
Vec: {0.0,1.0,0.0}
VecRef: {1.0,0.0,0.0}
and by computing the dot product e3d_vec:dot(Vec, VecRef) it's returning 0.0 (zero).
By the Dot Product definition, I was expecting to get a value other than zero. It should happens only if both vectors were parallel to each other. (Am I wrong?)
The two vectors cannot be parallel, so I test this value to try fix that - I need them to be perpendicular each other, being the Vec1 the reference one.
Just in case needed, here is the code where I use it:
Any idea about what is wrong?
	
	
	
In a code I'm working, at some point I have two vectors with these values:
Vec: {0.0,1.0,0.0}
VecRef: {1.0,0.0,0.0}
and by computing the dot product e3d_vec:dot(Vec, VecRef) it's returning 0.0 (zero).
By the Dot Product definition, I was expecting to get a value other than zero. It should happens only if both vectors were parallel to each other. (Am I wrong?)
The two vectors cannot be parallel, so I test this value to try fix that - I need them to be perpendicular each other, being the Vec1 the reference one.
Just in case needed, here is the code where I use it:
Code:
force_perpendicular(Vec, VecRef) ->
    DotProd = e3d_vec:dot(Vec, VecRef),
    if abs(DotProd) =< 0.001 -> % vectors are almost parallel
            Nor0 = e3d_vec:cross(VecRef, rot_axis_vec(main_axis(Vec))),
            Rot0 = e3d_mat:rotate(+90.0, Nor0),
            Nor = e3d_mat:mul_vector(Rot0, VecRef);
       true ->
            Nor = e3d_vec:cross(VecRef, Vec)
    end,
    Rot = e3d_mat:rotate(90.0, Nor),
    e3d_vec:norm(e3d_mat:mul_vector(Rot,VecRef)).
main_axis({X,Y,Z}) ->
    if (abs(X) > abs(Y)) ->
            if (abs(Z) > abs(X)) -> z;
               true -> x
            end;
       true ->
            if (abs(Z) > abs(Y)) -> z;
               true -> y
            end
    end.
rot_axis_vec(x) -> {0.0,0.0,1.0}; % rotate vector in x around of z axis
rot_axis_vec(y) -> {0.0,0.0,1.0}; % rotate vector in y around of x axis
rot_axis_vec(z) -> {1.0,0.0,0.0}. % rotate vector in z around of x axisAny idea about what is wrong?
	
 @MicheusVieira   
 @MicheusVieira   
 Micheuss   
 micheus4wings3d   
:![[Image: eq0033M.gif]](http://tutorial.math.lamar.edu/Classes/CalcII/DotProduct_files/eq0033M.gif)
 and 
, are ![[Image: eq0031M.gif]](http://tutorial.math.lamar.edu/Classes/CalcII/CrossProduct_files/eq0031M.gif)