The dcm2Angle( ) function comes from the Aerospace Toolbox. So these functions come from toolboxes with different definitions of quaternion conventions, and how to convert between quaternions and direction cosine matrices and Euler angles will be different between them. Bottom line is yo...
During the forward (bottom-up) pass (shown by the black arrows) the algorithm computes Nagata numbers, which contain the value of each sub-expression, and the dependencies between the nodes as function closures c::d⊸Sparsevd, e.g., N300c⊗2 for the final outcome. In the backward (...