Loading...
Searching...
No Matches
terra::linalg::trafo Namespace Reference

Functions

template<std::floating_point ScalarType>
dense::Mat< ScalarType, 3, 3 > trafo_mat_cartesian_to_normal_tangential (const dense::Vec< ScalarType, 3 > &n_input)
 Constructs a robust orthonormal transformation matrix from Cartesian to (normal–tangential–tangential) coordinates.
 
template<std::floating_point ScalarType>
dense::Mat< ScalarType, 3, 3 > trafo_mat_normal_tangential_to_cartesian_trafo (const dense::Vec< ScalarType, 3 > &n_input)
 Constructs the inverse transformation matrix from (normal–tangential–tangential) to Cartesian coordinates.
 
template<std::floating_point ScalarType, std::floating_point ScalarTypeGrid, util::FlagLike FlagType>
void cartesian_to_normal_tangential_in_place (VectorQ1Vec< ScalarType, 3 > &vec_cartesian, const grid::Grid3DDataVec< ScalarTypeGrid, 3 > &coords_shell, const grid::Grid4DDataScalar< FlagType > mask_data, const FlagType &flag)
 
template<std::floating_point ScalarType, std::floating_point ScalarTypeGrid, util::FlagLike FlagType>
void normal_tangential_to_cartesian_in_place (VectorQ1Vec< ScalarType, 3 > &vec_normal_tangential, const grid::Grid3DDataVec< ScalarTypeGrid, 3 > &coords_shell, const grid::Grid4DDataScalar< FlagType > mask_data, const FlagType &flag)
 

Function Documentation

◆ cartesian_to_normal_tangential_in_place()

template<std::floating_point ScalarType, std::floating_point ScalarTypeGrid, util::FlagLike FlagType>
void terra::linalg::trafo::cartesian_to_normal_tangential_in_place ( VectorQ1Vec< ScalarType, 3 > &  vec_cartesian,
const grid::Grid3DDataVec< ScalarTypeGrid, 3 > &  coords_shell,
const grid::Grid4DDataScalar< FlagType >  mask_data,
const FlagType &  flag 
)

◆ normal_tangential_to_cartesian_in_place()

template<std::floating_point ScalarType, std::floating_point ScalarTypeGrid, util::FlagLike FlagType>
void terra::linalg::trafo::normal_tangential_to_cartesian_in_place ( VectorQ1Vec< ScalarType, 3 > &  vec_normal_tangential,
const grid::Grid3DDataVec< ScalarTypeGrid, 3 > &  coords_shell,
const grid::Grid4DDataScalar< FlagType >  mask_data,
const FlagType &  flag 
)

◆ trafo_mat_cartesian_to_normal_tangential()

template<std::floating_point ScalarType>
dense::Mat< ScalarType, 3, 3 > terra::linalg::trafo::trafo_mat_cartesian_to_normal_tangential ( const dense::Vec< ScalarType, 3 > &  n_input)

Constructs a robust orthonormal transformation matrix from Cartesian to (normal–tangential–tangential) coordinates.

Given a surface normal n, this function returns the 3×3 matrix \( R \) whose rows form a right-handed orthonormal basis \( \{ \hat{n}, \mathbf{t}_1, \mathbf{t}_2 \} \) such that:

\[ \mathbf{v}_{\text{local}} = R \, \mathbf{v}_{\text{cartesian}}, \qquad \mathbf{v}_{\text{cartesian}} = R^{\mathsf{T}} \, \mathbf{v}_{\text{local}} . \]

The basis vectors are constructed as:

  • \( \hat{n} = \frac{\mathbf{n}}{||\mathbf{n}||} \)
  • \( \mathbf{t}_1 = \mathrm{normalize}(\mathbf{r} \times \hat{n}) \), where \( \mathbf{r} \) is the coordinate axis least aligned with \( \hat{n} \)
  • \( \mathbf{t}_2 = \hat{n} \times \mathbf{t}_1 \)

This ensures numerical stability even when \( \hat{n} \) is nearly axis-aligned.

Template Parameters
ScalarTypeFloating-point scalar type (e.g. float, double).
Parameters
n_inputSurface normal vector at the point of interest (not required to be unit length).
Returns
3×3 transformation matrix \( R \) with rows \( [\,\hat{n}^\mathrm{T},\, \mathbf{t}_1^\mathrm{T},\, \mathbf{t}_2^\mathrm{T}\,] \).

◆ trafo_mat_normal_tangential_to_cartesian_trafo()

template<std::floating_point ScalarType>
dense::Mat< ScalarType, 3, 3 > terra::linalg::trafo::trafo_mat_normal_tangential_to_cartesian_trafo ( const dense::Vec< ScalarType, 3 > &  n_input)

Constructs the inverse transformation matrix from (normal–tangential–tangential) to Cartesian coordinates.

This function returns the transpose of the orthonormal transformation matrix \( R \) produced by trafo_mat_cartesian_to_normal_tangential, since for an orthonormal basis \( R^{-1} = R^{\mathsf{T}} \).

Hence, for any vector \( \mathbf{v} \):

\[ \mathbf{v}_{\text{local}} = R \, \mathbf{v}_{\text{cartesian}}, \qquad \mathbf{v}_{\text{cartesian}} = R^{\mathsf{T}} \, \mathbf{v}_{\text{local}} . \]

Template Parameters
ScalarTypeFloating-point scalar type (e.g. float, double).
Parameters
n_inputSurface normal vector at the point of interest (not required to be unit length).
Returns
The 3×3 inverse transformation matrix \( R^{\mathsf{T}} \) that maps local (n, t₁, t₂) coordinates back to Cartesian space.