| 1345 | } |
| 1346 | |
| 1347 | complex<double> symmetry::phase_shift(component c, int n) const { |
| 1348 | if (c == Dielectric || c == Permeability || c == NO_COMPONENT) return 1.0; |
| 1349 | complex<double> phase = transform(component_direction(c), n).phase; |
| 1350 | // flip tells us if we need to flip the sign. For vectors (E), it is |
| 1351 | // just this simple: |
| 1352 | bool flip = transform(component_direction(c), n).flipped; |
| 1353 | if (is_magnetic(c) || is_B(c)) { |
| 1354 | // Because H is a pseudovector, here we have to figure out if the |
| 1355 | // transformation changes the handedness of the basis. |
| 1356 | bool have_one = false, have_two = false; |
| 1357 | FOR_DIRECTIONS(d) { |
| 1358 | if (transform(d, n).flipped) flip = !flip; |
| 1359 | int shift = (transform(d, n).d - d + 6) % 3; |
| 1360 | if (shift == 1) have_one = true; |
| 1361 | if (shift == 2) have_two = true; |
| 1362 | } |
| 1363 | if (have_one && have_two) flip = !flip; |
| 1364 | } |
| 1365 | if (flip) |
| 1366 | return -phase; |
| 1367 | else |
| 1368 | return phase; |
| 1369 | } |
| 1370 | |
| 1371 | complex<double> symmetry::phase_shift(derived_component c, int n) const { |
| 1372 | if (is_poynting(c)) { |