Changeset 2619 for trunk/src/MathUtils.cpp
- Timestamp:
- 08/02/12 18:19:59 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MathUtils.cpp
r2258 r2619 292 292 } 293 293 294 void 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 335 void mathutil::rotateRA( const Vector<Double> &in, 336 Vector<Double> &out ) 337 { 338 out = in.copy() ; 339 rotateRA( out ) ; 340 } 341 294 342 double mathutil::gettimeofday_sec() 295 343 {
Note: See TracChangeset
for help on using the changeset viewer.