Ignore:
Timestamp:
01/03/08 15:53:44 (17 years ago)
Author:
bittner
Message:

big merge: preparation for havran ray caster, check if everything works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h

    r2176 r2575  
    66namespace GtpVisibilityPreprocessor { 
    77 
     8 
     9/** 
     10 * Assert whether the argument is a prime number. 
     11 * @param number the number to be checked 
     12 */ 
     13inline bool IsPrime(const int number) { 
     14  bool isIt = true; 
     15  for(int i = 2; i < number; i++) { 
     16        if(number % i == 0) { 
     17          isIt = false; 
     18          break; 
     19        } 
     20  } 
     21        if(number == 2) { 
     22          isIt = false; 
     23        } 
     24        return isIt; 
     25} 
     26 
     27   
     28  /** 
     29 * Find the nth prime number. 
     30 * @param index the ordinal position in the sequence 
     31 */ 
     32inline int FindPrime(const int index) { 
     33  //  if (index < 1) { 
     34  //    cerr<<"FindPrime: The argument must be non-negative."<<endl; 
     35  //    return -1; 
     36  //  } 
     37 
     38  const int primes[] = {-1, 1, 3, 5, 7, 11, 13}; 
     39  if (index <= 6) 
     40        return primes[index]; 
     41 
     42  int prime = 1; 
     43  int found = 1; 
     44  while(found != index) { 
     45        prime += 2; 
     46          if(IsPrime(prime) == true) { 
     47                found++; 
     48          } 
     49  } 
     50  return prime; 
     51} 
     52 
     53   
    854inline float halton(float baseRec, float prev) { 
    955  //  float r = 1 - prev - 1e-10f; 
     
    82128 
    83129 
    84 /** 
    85  * Assert whether the argument is a prime number. 
    86  * @param number the number to be checked 
    87  */ 
    88 inline bool IsPrime(const int number) { 
    89   bool isIt = true; 
    90   for(int i = 2; i < number; i++) { 
    91         if(number % i == 0) { 
    92           isIt = false; 
    93           break; 
    94         } 
    95   } 
    96         if(number == 2) { 
    97           isIt = false; 
    98         } 
    99         return isIt; 
    100 } 
    101  
    102    
    103   /** 
    104  * Find the nth prime number. 
    105  * @param index the ordinal position in the sequence 
    106  */ 
    107 inline int FindPrime(const int index) { 
    108   //  if (index < 1) { 
    109   //    cerr<<"FindPrime: The argument must be non-negative."<<endl; 
    110   //    return -1; 
    111   //  } 
    112  
    113   const int primes[] = {-1, 1, 3, 5, 7, 11, 13}; 
    114   if (index <= 6) 
    115         return primes[index]; 
    116  
    117   int prime = 1; 
    118   int found = 1; 
    119   while(found != index) { 
    120         prime += 2; 
    121           if(IsPrime(prime) == true) { 
    122                 found++; 
    123           } 
    124   } 
    125   return prime; 
    126 } 
    127  
     130   
    128131struct HaltonSequence { 
    129132public: 
Note: See TracChangeset for help on using the changeset viewer.