|
RobinTrace
|
Transfer operation over a ray. More...
#include <transfer.h>
Public Member Functions | |
| transfer () | |
| Default constructor. More... | |
| transfer (Vec3 _D) | |
| Translation initialization constructor. More... | |
| transfer (Mat3 _Bt, Vec3 _D) | |
| Full initialization constructor. More... | |
| void | apply (ray &r) |
| Apply the transfer to a ray. More... | |
Public Attributes | |
| Mat3 | Bt |
| Transpose of the rotation matrix \( B \). More... | |
| Vec3 | D |
| Translation vector \( D \). More... | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const transfer &trf) |
| Printer. | |
Transfer operation over a ray.
The transfer operation defines a new LCS to propagate the ray to. It operates a change of basis and an intersection with the newly defined local plane. Let, in a hypothetical global common coordinate system,
The definition of LCS2 from LCS1 is done with,
The coordinates of the origin and basis vectors of LCS are expressed with,
\[ \begin{cases} A_2 &= B \cdot \overrightarrow{D} \\ \hat{x_2} &= B \cdot \hat{x_1} \\ \hat{y_2} &= B \cdot \hat{y_1} \\ \hat{z_2} &= B \cdot \hat{z_1} \end{cases} \]
Which is to say, LCS2 is obtained from LCS1 by first applying the rotation \( B \) and then translating the origin by \( \overrightarrow{D} \), with \( D \) expressed in the rotated coordinates.
| transfer::transfer | ( | ) |
Default constructor.
The defaults are:
This transfer operation does not change the current LCS.
| transfer::transfer | ( | Vec3 | _D | ) |
Translation initialization constructor.
The translation vector is initialized to _D, while the rotation matrix \( B \) is identity.
| _D | The initial transfer translation vector. |
Full initialization constructor.
The rotation matrix transpose is initialized to _Bt, the translation vector is initialized to _D.
| _Bt | The initial rotation matrix transpose. |
| _D | The initial translation vector. |
| void transfer::apply | ( | ray & | r | ) |
Apply the transfer to a ray.
The operation is decomposed into two successive operations on the ray.
Let the ray coordinates in LCS1, \( (P_1, \overrightarrow{V_1}) \). We first operate the change of basis, which gives us ray coordinates \( (P_2, \overrightarrow{V_2}) \).
\[ \begin{cases} P_2 &= \begin{bmatrix} x_2 \\ y_2 \\ z_2 \end{bmatrix} = B^{-1} \cdot P_1 - \overrightarrow{D} \\ \overrightarrow{V_2} &= \begin{bmatrix} l_2 \\ m_2 \\ n_2 \end{bmatrix} = B^{-1} \cdot \overrightarrow{V_1} \end{cases} \]
\( n_2 = 0 \) is an error case, since the ray is parallel to the LCS2 local plane.
We then operate the intersection of the ray with the LCS2 local plane, obtaining \( (P_3, \overrightarrow{V_3}) \).
\[ \begin{cases} \overrightarrow{V_3} = \overrightarrow{V_2} \\ t = - \frac{z_2}{n_2} \\ P_3 = \begin{bmatrix} x_2 + t \cdot l_2 \\ y_2 + t \cdot m_2 \\ 0 \end{bmatrix} \end{cases} \]
| Mat3 transfer::Bt |
Transpose of the rotation matrix \( B \).
Note that since rotation matrices are orthogonal, we have \( B^{-1} = B^\top \).
| Vec3 transfer::D |
Translation vector \( D \).
Note the translation from LCS1 to LCS2 is applied in the rotated coordinates.