Changeset 2619


Ignore:
Timestamp:
08/02/12 18:19:59 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-2825

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: not available

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Take care of 2pi rotation on RA axis.


Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/EdgeDetector.cpp

    r2613 r2619  
    1212
    1313#include "EdgeDetector.h"
     14#include "MathUtils.h"
    1415
    1516using namespace std ;
     
    2829void EdgeDetector::setDirection( const Matrix<Double> &dir )
    2930{
    30   dir_.reference( dir ) ;
     31  //dir_.reference( dir ) ;
     32  dir_ = dir.copy() ;
     33  Vector<Double> ra( dir_.row(0) ) ;
     34  mathutil::rotateRA( ra ) ;
    3135  resizeTempArea( dir.nrow() ) ;
    3236}
  • trunk/src/MathUtils.cpp

    r2258 r2619  
    292292}
    293293
     294void mathutil::rotateRA( Vector<Double> &v )
     295{
     296  uInt len = v.nelements() ; 
     297  Vector<Double> work( len ) ;
     298
     299  for ( uInt i = 0 ; i < len ; i++ ) {
     300    work[i] = fmod( v[i], C::_2pi ) ;
     301    if ( work[i] < 0.0 ) {
     302      work[i] += C::_2pi ;
     303    }
     304  }
     305  //cout << "zero2twopi: out=" << work << endl ;
     306
     307  Vector<uInt> quad( len ) ;
     308  Vector<uInt> nquad( 4, 0 ) ;
     309  for ( uInt i = 0 ; i < len ; i++ ) {
     310    uInt q = uInt( work[i] / C::pi_2 ) ;
     311    nquad[q]++ ;
     312    quad[i] = q ;
     313  }
     314  //cout << "nquad = " << nquad << endl ;
     315
     316  Vector<Bool> rot( 4, False ) ;
     317  if ( nquad[0] > 0 && nquad[3] > 0
     318       && ( nquad[1] == 0 || nquad[2] == 0 ) ) {
     319    //cout << "need rotation" << endl ;
     320    rot[3] = True ;
     321    rot[2] = (nquad[1]==0 && nquad[2]>0) ;
     322  }
     323  //cout << "rot=" << rot << endl ;
     324
     325  for ( uInt i = 0 ; i < len ; i++ ) {
     326    if ( rot[quad[i]] ) {
     327      v[i] = work[i] - C::_2pi ;
     328    }
     329    else {
     330      v[i] = work[i] ;
     331    }
     332  }
     333}
     334
     335void mathutil::rotateRA( const Vector<Double> &in,
     336                         Vector<Double> &out )
     337{
     338  out = in.copy() ;
     339  rotateRA( out ) ;
     340}
     341
    294342double mathutil::gettimeofday_sec()
    295343{
  • trunk/src/MathUtils.h

    r2258 r2619  
    110110
    111111/**
     112 * RA nomalization: n*2pi rotation if necessary
     113 **/
     114void rotateRA( const casa::Vector<casa::Double> &in,
     115               casa::Vector<casa::Double> &out ) ;
     116void rotateRA( casa::Vector<casa::Double> &v ) ;
     117
     118/**
    112119 * tool to record current time stamp
    113120 **/
Note: See TracChangeset for help on using the changeset viewer.