We have to create a custom 3-D coordinate system of which one axis is defined by a vector (in the global coordinate system). The other two coordinate axes can be freely chosen. But the most intuitive would be (in this case) to align an axis of the custom coordinate system with the global one, either which one matches best.
Return the 3element normalized column vector P in a 3-D Cartesian space (regular x,y,z axes we use in general), that * is in a plane (through the origin), defined by its normal vector N * N can be a column- or row vector * N is not necessarily normalized * makes the smallest angle with any of the Cartesian axes specified A * A is a character array containing any of the character xyz and XYZ * when the smallest angle of P with multiple axes mentioned in A is equal, the order of the axes in A defines which is preferred * when A contains only one axis-name, and N is parallel to that axis, the functions return empty an empty matrix .
align_frame([1 0 0],'zyx')
0 0 1
0.9636 -0.1483 -0.2224
0.7071 -0.7071 0
align_frame([0 0 1],'Z')
Note: Solutions wrapped in (f)eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.
MATLAB and Simulink resources for Arduino, LEGO, and Raspberry PiLearn more
Opportunities for recent engineering grads.Apply Today
New to MATLAB?Learn MATLAB today!
Play games and win prizes!Learn more