- Rotational transformation tensor from vector n1 to n2
| 44 | |
| 45 | //- Rotational transformation tensor from vector n1 to n2 |
| 46 | inline tensor rotationTensor |
| 47 | ( |
| 48 | const vector& n1, |
| 49 | const vector& n2 |
| 50 | ) |
| 51 | { |
| 52 | const scalar s = n1 & n2; |
| 53 | const vector n3 = n1 ^ n2; |
| 54 | const scalar magSqrN3 = magSqr(n3); |
| 55 | |
| 56 | // n1 and n2 define a plane n3 |
| 57 | if (magSqrN3 > SMALL) |
| 58 | { |
| 59 | // Return rotational transformation tensor in the n3-plane |
| 60 | return |
| 61 | s*I |
| 62 | + (1 - s)*sqr(n3)/magSqrN3 |
| 63 | + (n2*n1 - n1*n2); |
| 64 | } |
| 65 | // n1 and n2 are contradirectional |
| 66 | else if (s < 0) |
| 67 | { |
| 68 | // Return mirror transformation tensor |
| 69 | return I + 2*n1*n2; |
| 70 | } |
| 71 | // n1 and n2 are codirectional |
| 72 | else |
| 73 | { |
| 74 | // Return null transformation tensor |
| 75 | return I; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | //- Rotational transformation tensor about the x-axis by omega radians |
no test coverage detected