# vrotation

## PURPOSE

This function rotates an entrire matrix by the angle phi (in radians).

## SYNOPSIS

function [rx, ry, rz] = vrotation(X,Y,Z,phi)

## DESCRIPTION

     This function rotates an entrire matrix by the angle phi (in radians).
     The output are the new vector head coordinates for each element in the
     matrix. The required inputs (ie, X, Y, and Z matrices) must be the same
     dimensions.

     For a discussion on how vector rotation works, see:
             http://www.kwon3d.com/theory/transform/rot.html

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function [rx, ry, rz] = vrotation(X,Y,Z,phi)
    0002
    0003 % This function rotates an entrire matrix by the angle phi (in radians).
    0004 % The output are the new vector head coordinates for each element in the
    0005 % matrix. The required inputs (ie, X, Y, and Z matrices) must be the same
    0006 % dimensions.
    0007 %
    0008 % For a discussion on how vector rotation works, see:
    0009 %         http://www.kwon3d.com/theory/transform/rot.html
    0010
    0011 % Written by:
    0012 % Frank L. Engel (fengel2@illinois.edu)
    0013
    0014 % Last edited: 8/26/2009
    0015
    0016
    0017 % Rotation matrix
    0018 Rz = [cos(phi) -sin(phi) 0;...
    0019     sin(phi) cos(phi) 0;...
    0020     0 0 1];
    0021
    0022 % Rotate every element in the matrix
    0023 for i=1:size(X,2)
    0024     for j = 1:size(X,1)
    0025         XYZ = [X(j,i);Y(j,i);Z(j,i)];
    0026         Rotated = Rz*XYZ;
    0027         rx(j,i) = Rotated(1);
    0028         ry(j,i) = Rotated(2);
    0029         rz(j,i) = Rotated(3);
    0030     end
    0031 end