%% Barfoot Prob 7.5.1
C = sym('C%d%d', [3, 3])
u = sym('u%d', [3, 1])
uHat = vechat(u)

%%
% $\mathbf{A} = \left(\mathbf{C}\mathbf{u}\right)^{\wedge}$
Cu = C*u;
A = vechat(Cu)

%%
% $\mathbf{B} = \mathbf{C}\mathbf{u}^{\wedge}\mathbf{C}$
assume(C, 'real')
C*uHat*C'

%%
% Simplified $\mathbf{B} = \mathbf{C}\mathbf{u}^{\wedge}\mathbf{C}$
%
% Use the cross product properties of C's basis to simplify the equation
% See Hughes' Spacecraft Attitude Dynamics Chapter 2.1
assumeAlso(C(:,1) == cross(C(:,2), C(:,3)))
assumeAlso(C(:,2) == cross(C(:,3), C(:,1)))
assumeAlso(C(:,3) == cross(C(:,1), C(:,2)))
B = simplify(C*uHat*C')

%%
% Comparing $\mathbf{A}$ and $\mathbf{B}$
isequal(A, B)

%% Miscellaneous
function R = vechat(phi)
    R = [0 -phi(3) phi(2); phi(3) 0 -phi(1); -phi(2) phi(1) 0];
end