Home > voicebox > atan2sc.m

atan2sc

PURPOSE ^

ATAN2SC sin and cosine of atan(y/x) [S,C,R,T]=(Y,X)

SYNOPSIS ^

function [s,c,r,t]=atan2sc(y,x)

DESCRIPTION ^

ATAN2SC    sin and cosine of atan(y/x) [S,C,R,T]=(Y,X)

 Outputs:
    s    sin(t) where tan(t) = y/x
    C    cos(t) where tan(t) = y/x
    r    sqrt(x^2 + y^2)
    t    arctan of y/x

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [s,c,r,t]=atan2sc(y,x)
0002 %ATAN2SC    sin and cosine of atan(y/x) [S,C,R,T]=(Y,X)
0003 %
0004 % Outputs:
0005 %    s    sin(t) where tan(t) = y/x
0006 %    C    cos(t) where tan(t) = y/x
0007 %    r    sqrt(x^2 + y^2)
0008 %    t    arctan of y/x
0009 
0010 %      Copyright (C) Mike Brookes 2007
0011 %      Version: $Id: atan2sc.m 713 2011-10-16 14:45:43Z dmb $
0012 %
0013 %   VOICEBOX is a MATLAB toolbox for speech processing.
0014 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 %   This program is free software; you can redistribute it and/or modify
0018 %   it under the terms of the GNU General Public License as published by
0019 %   the Free Software Foundation; either version 2 of the License, or
0020 %   (at your option) any later version.
0021 %
0022 %   This program is distributed in the hope that it will be useful,
0023 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0025 %   GNU General Public License for more details.
0026 %
0027 %   You can obtain a copy of the GNU General Public License from
0028 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0029 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 
0032 
0033 t=NaN;
0034 if y == 0
0035     t=(x<0);
0036     c=1-2*t;
0037     s=0;
0038     r=abs(x);
0039     t=t*pi;
0040 elseif x == 0
0041     s=2*(y>=0)-1;
0042     c=0;
0043     r=abs(y);
0044     t=s*0.5*pi;
0045 elseif (abs(y) > abs(x))
0046     q = x/y;
0047     u = sqrt(1+q^2)*(2*(y>=0)-1);
0048     s = 1/u;
0049     c = s*q;
0050     r = y*u;
0051 else
0052     q = y/x;
0053     u = sqrt(1+q^2)*(2*(x>=0)-1);
0054     c = 1/u;
0055     s = c*q;
0056     r = x*u;
0057 end
0058 if nargout>3 && isnan(t)
0059     t=atan2(s,c);
0060 end

Generated on Tue 10-Oct-2017 08:30:10 by m2html © 2003