通过叉积将向量旋转 90 度

M.B*_*.B. 0 matlab rotation linear-algebra cross-product geometry-surface

我试图理解一个代码,其中作者将 3D 中的向量旋转了 90 度。他们使用了一个交叉产品来做到这一点。交叉乘积如何包含旋转 90 度?任何解释都会有所帮助。

    % Inputs:
    %   V  #vertices by dim list of mesh vertex positions
    %   F  #faces by simplex-size list of mesh face indices
    % Gradient of a scalar function defined on piecewise linear elements (mesh)
    % is constant on each triangle i,j,k:
    % grad(Xijk) = (Xj-Xi) * (Vi - Vk)^R90 / 2A + (Xk-Xi) * (Vj - Vi)^R90 / 2A
    % grad(Xijk) = Xj * (Vi - Vk)^R90 / 2A + Xk * (Vj - Vi)^R90 / 2A + 
    %             -Xi * (Vi - Vk)^R90 / 2A - Xi * (Vj - Vi)^R90 / 2A
    % where Xi is the scalar value at vertex i, Vi is the 3D position of vertex
    % i, and A is the area of triangle (i,j,k). ^R90 represent a rotation of 
    % 90 degrees
    %
    % renaming indices of vertices of triangles for convenience
    i1 = F(:,1); i2 = F(:,2); i3 = F(:,3); 
    % #F x 3 matrices of triangle edge vectors, named after opposite vertices
    v32 = V(i3,:) - V(i2,:);  v13 = V(i1,:) - V(i3,:); v21 = V(i2,:) - V(i1,:);

    % area of parallelogram is twice area of triangle
    % area of parallelogram is || v1 x v2 || 
    n  = cross(v32,v13,2); 

    % This does correct l2 norm of rows so that it contains #F list of twice
    % triangle areas
    dblA = normrow(n);

    % now normalize normals to get unit normals
    u = normalizerow(n);

    % rotate each vector 90 degrees around normal ---- ????
    eperp21 = bsxfun(@times,cross(u,v21),1./dblA);
    eperp13 = bsxfun(@times,cross(u,v13),1./dblA);
Run Code Online (Sandbox Code Playgroud)

fla*_*awr 5

3D中的叉积 a x b两个向量的ab向量中的结果p := a x b垂直于这两个ab

这意味着如果将向量与u表示旋转轴的单位向量交叉相乘,您将得到一个绕旋转轴旋转 90 度的向量。