通过叉积将向量旋转 90 度

Rotate a vector by 90 degree via cross product

我试图理解一个代码,其中作者将 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);

在 3d 中,两个向量 abcross product a x b 导致向量 p := a x b 垂直ab.

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