bpmprocess/get_IQ.c

Go to the documentation of this file.
00001 
00005 #include <bpm/bpm_messages.h>
00006 #include <bpm/bpm_process.h>
00007 
00008 /*
00009   Gets the I and Q from the amp, phase and ref
00010   
00011   @return BPM_SUCCESS upon success, BPM_FAILURE upon failure
00012 */
00013 int get_IQ( double amp, double phase, double refamp, double refphase,
00014             double *Q, double *I ) {
00015 
00016   if( ! Q || ! I ) {
00017     bpm_error( "Invalid pointer arguments in get_IQ(...)",
00018                __FILE__, __LINE__ );
00019     return BPM_FAILURE;
00020   }
00021 
00022   *I = -DBL_MAX;
00023   *Q = -DBL_MAX;
00024 
00025   if( refamp > 0. ) {
00026     *I = amp / refamp * cos( phase - refphase );
00027     *Q = amp / refamp * sin( phase - refphase );
00028   } else {
00029     bpm_warning( "Reference amplitude is 0 in get_IQ(...)",
00030                  __FILE__, __LINE__ );
00031     return BPM_FAILURE;
00032   }
00033 
00034   return BPM_SUCCESS;
00035 }

Generated on Thu Jan 10 10:18:04 2008 for libbpm by  doxygen 1.5.1