# v_rotqc2qr

## PURPOSE

V_ROTQC2QR converts a matrix of complex quaternion row vectors into real form

## SYNOPSIS

function qr=v_rotqc2qr(qc)

## DESCRIPTION

    V_ROTQC2QR converts a matrix of complex quaternion row vectors into real form

     Inputs:

         QC(2m,...)   array of complex-valued quaternions

     Outputs:

         QR(4m,...)   array of real-valued quaternions

     The complex-valued quaternion [r+j*b  a+j*c] becomes [r a b c]

## CROSS-REFERENCE INFORMATION

This function calls:

- v_rotqr2ro ROTQR2RO converts a real quaternion to a 3x3 rotation matrix

This function is called by:

## SOURCE CODE

    0001 function qr=v_rotqc2qr(qc)
    0002 %V_ROTQC2QR converts a matrix of complex quaternion row vectors into real form
    0003 %
    0004 % Inputs:
    0005 %
    0006 %     QC(2m,...)   array of complex-valued quaternions
    0007 %
    0008 % Outputs:
    0009 %
    0010 %     QR(4m,...)   array of real-valued quaternions
    0011 %
    0012 % The complex-valued quaternion [r+j*b  a+j*c] becomes [r a b c]
    0013
    0014 %
    0015 %      Copyright (C) Mike Brookes 2000-2018
    0016 %      Version: $Id: v_rotqc2qr.m 10865 2018-09-21 17:22:45Z dmb $
    0017 %
    0018 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0019 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0020 %
    0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0022 %   This program is free software; you can redistribute it and/or modify
    0023 %   it under the terms of the GNU Lesser General Public License as published by
    0024 %   the Free Software Foundation; either version 3 of the License, or
    0025 %   (at your option) any later version.
    0026 %
    0027 %   This program is distributed in the hope that it will be useful,
    0028 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0029 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0030 %   GNU Lesser General Public License for more details.
    0031 %
    0032 %   You can obtain a copy of the GNU Lesser General Public License from
    0033 %   https://www.gnu.org/licenses/ .
    0034 %
    0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0036 persistent a b
    0037 if isempty(a)
    0038     a=[1 3 2 4];
    0039 end
    0040 s=size(qc);
    0041 s(1)=2*s(1); % each complex number needs two reals
    0042 qr=reshape([real(qc(:).'); imag(qc(:).')],4,[]);
    0043 qr=reshape(qr(a,:),s);
    0044 if ~nargout
    0045     qr=qr(1:4); % just select the first one
    0046     v_rotqr2ro(qr(:)); % plot a rotated cube
    0047 end