Home > matGeom > geom2d > rotateVector.m

rotateVector

PURPOSE ^

ROTATEVECTOR Rotate a vector by a given angle.

SYNOPSIS ^

function vr = rotateVector(v, angle)

DESCRIPTION ^

ROTATEVECTOR Rotate a vector by a given angle.

   VR = rotateVector(V, THETA)
   Rotate the vector V by an angle THETA, given in radians.

   Example
   rotateVector([1 0], pi/2)
   ans = 
       0   1

   See also
   vectors2d, transformVector, createRotation

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function vr = rotateVector(v, angle)
0002 %ROTATEVECTOR Rotate a vector by a given angle.
0003 %
0004 %   VR = rotateVector(V, THETA)
0005 %   Rotate the vector V by an angle THETA, given in radians.
0006 %
0007 %   Example
0008 %   rotateVector([1 0], pi/2)
0009 %   ans =
0010 %       0   1
0011 %
0012 %   See also
0013 %   vectors2d, transformVector, createRotation
0014 
0015 % ------
0016 % Author: David Legland
0017 % E-mail: david.legland@inrae.fr
0018 % Created: 2011-04-14, using Matlab 7.9.0.529 (R2009b)
0019 % Copyright 2011-2024 INRA - Cepia Software Platform
0020 
0021 % precomputes angles
0022 cot = cos(angle);
0023 sit = sin(angle);
0024 
0025 % compute rotated coordinates
0026 vr = [cot * v(:,1) - sit * v(:,2) , sit * v(:,1) + cot * v(:,2)];

Generated on Thu 21-Nov-2024 11:30:22 by m2html © 2003-2022