| 1099 | */ |
| 1100 | |
| 1101 | void getRotationMatrix( const int _DIM, double**& B, CBiteRnd& rrnd ) |
| 1102 | { |
| 1103 | CRotMatCacheItem* Cache = NULL; |
| 1104 | int i; |
| 1105 | |
| 1106 | for( i = 0; i < RMCacheCount; i++ ) |
| 1107 | { |
| 1108 | if( RMCache[ i ].Dims == _DIM ) |
| 1109 | { |
| 1110 | Cache = &RMCache[ i ]; |
| 1111 | break; |
| 1112 | } |
| 1113 | } |
| 1114 | |
| 1115 | if( Cache == NULL ) |
| 1116 | { |
| 1117 | if( RMCacheCount == RMCacheSize ) |
| 1118 | { |
| 1119 | printf( "rmcache overflow\n" ); |
| 1120 | Cache = &RMCache[ 0 ]; |
| 1121 | } |
| 1122 | else |
| 1123 | { |
| 1124 | Cache = &RMCache[ RMCacheCount ]; |
| 1125 | Cache -> Dims = _DIM; |
| 1126 | RMCacheCount++; |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | const int ri = rrnd.getInt( CRotMatCacheItem :: EntryCount ); |
| 1131 | |
| 1132 | if( Cache -> rm[ ri ] == NULL ) |
| 1133 | { |
| 1134 | Cache -> rm[ ri ] = new double*[ _DIM ]; |
| 1135 | Cache -> rmbuf[ ri ] = new double[ _DIM * _DIM ]; |
| 1136 | |
| 1137 | for( i = 0; i < _DIM; i++ ) |
| 1138 | { |
| 1139 | Cache -> rm[ ri ][ i ] = Cache -> rmbuf[ ri ] + i * _DIM; |
| 1140 | } |
| 1141 | |
| 1142 | makeRotationMatrix( Cache -> rm[ ri ], _DIM, rrnd ); |
| 1143 | } |
| 1144 | |
| 1145 | B = Cache -> rm[ ri ]; |
| 1146 | } |
| 1147 | }; |