QUGaR 0.0.4
Loading...
Searching...
No Matches
qugar::impl::AffineTransf< dim > Class Template Reference

Class for representing affine transformations. More...

#include <affine_transf.hpp>

Public Types

template<typename T >
using Tensor = Vector<T, dim *(dim + 1) / 2>
 

Public Member Functions

 AffineTransf ()
 Default constructor. Creates the identity transformation.
 
 AffineTransf (const Point< dim > &origin)
 Constructs a new affine tranformation that simply translates the origin.
 
 AffineTransf (const Point< dim > &origin, real scale)
 Constructs a new affine transformation that first applies an isotropic scaling and then translates the origin.
 
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 2)
 AffineTransf (const Point< dim > &origin, const Point< dim > &axis_x)
 Constructs a new 2D affine transformation defined by an origin and the axis_x.
 
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 3)
 AffineTransf (const Point< dim > &origin, const Point< dim > &axis_x, const Point< dim > &axis_y)
 Constructs a new 3D affine transformation defined by an origin and a couple of directions that define the xy-plane.
 
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 2)
 AffineTransf (const Point< dim > &origin, const Point< dim > &axis_x, real scale_x, real scale_y)
 Constructs a new 2D affine transformation defined by an origin, the axis_x, and an orthotropic scaling along the x- and y-axes.
 
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 3)
 AffineTransf (const Point< dim > &origin, const Point< dim > &axis_x, const Point< dim > &axis_y, real scale_x, real scale_y, real scale_z)
 Constructs a new 3D affine transformation defined by an origin, a couple of directions that define the xy-plane, and an orthotropic scaling along the x-, y, and z-axes.
 
 AffineTransf (const Vector< real, n_coefs > &coefs)
 Constructs a new object through its coefficients. a new Affine Transf object.
 
AffineTransf< dim > operator* (const AffineTransf< dim > &rhs) const
 Concatenates two affine transformation to generate a new one.
 
AffineTransf< dim > inverse () const
 Inverts the current transformation.
 
template<typename T >
Vector< T, dim > transform_point (const Vector< T, dim > &point) const
 Transforms a point from the original to the new reference system.
 
template<typename T >
Vector< T, dim > transform_vector (const Vector< T, dim > &vector) const
 Transforms a vector from the original to the new reference system (without translation).
 
template<typename T >
Tensor< T > transform_tensor (const Tensor< T > &tensor) const
 Transforms a (second-order symmetric) tensor from the original to the new reference system (without translation).
 

Static Public Attributes

static constexpr int n_coefs = dim * (dim + 1)
 

Static Private Member Functions

static Vector< real, n_coefscompute_coefs (const Point< dim > &origin, real scale)
 Computes the coefficients of a new 2D affine transformation that translates the origin and apply an isotropic scaling.
 
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 3)
static Vector< real, n_coefscompute_coefs (const Point< dim > &origin, const Point< dim > &axis_x=Point< dim >(numbers::one, numbers::zero, numbers::zero), const Point< dim > &axis_y=Point< dim >(numbers::zero, numbers::one, numbers::zero), real scale_x=numbers::one, real scale_y=numbers::one, real scale_z=numbers::one)
 Computes the coefficients of a new 3D affine transformation defined by an origin, a couple of directions that define the xy-plane, and an orthotropic scaling along the x-, y, and z-axes.
 
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 2)
static Vector< real, n_coefscompute_coefs (const Point< dim > &origin, const Point< dim > &axis_x=Point< dim >(numbers::one, numbers::zero), real scale_x=numbers::one, real scale_y=numbers::one)
 Computes the coefficients of a new 2D affine transformation defined by an origin, the axis_x, and an orthotropic scaling along the x- and y-axes.
 

Private Attributes

Vector< real, n_coefscoefs_
 Transformation coefficients.
 

Detailed Description

template<int dim>
class qugar::impl::AffineTransf< dim >

Class for representing affine transformations.

It transforms points as y = A * x + b, where x is the original point, y is the new point, b is the translation vector, and A is the transformation matrix that may be defined by rotations and scaling.

The member coefs_ stores the involved coefficients. Thus, first dim*dim values of coefs_ contain the values of the matrix A (row-wise), and the last dim values, the ones of the vector b.

Template Parameters
dimParametric direction.

Member Typedef Documentation

◆ Tensor

template<int dim>
template<typename T >
using qugar::impl::AffineTransf< dim >::Tensor = Vector<T, dim *(dim + 1) / 2>

Constructor & Destructor Documentation

◆ AffineTransf() [1/8]

template<int dim>
qugar::impl::AffineTransf< dim >::AffineTransf ( )
explicit

Default constructor. Creates the identity transformation.

◆ AffineTransf() [2/8]

template<int dim>
qugar::impl::AffineTransf< dim >::AffineTransf ( const Point< dim > & origin)
explicit

Constructs a new affine tranformation that simply translates the origin.

Parameters
originNew origin of the reference system.

◆ AffineTransf() [3/8]

template<int dim>
qugar::impl::AffineTransf< dim >::AffineTransf ( const Point< dim > & origin,
real scale )

Constructs a new affine transformation that first applies an isotropic scaling and then translates the origin.

Parameters
originNew origin of the reference system.
scaleScaling factor to be applied along all the directions.

◆ AffineTransf() [4/8]

template<int dim>
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 2)
qugar::impl::AffineTransf< dim >::AffineTransf ( const Point< dim > & origin,
const Point< dim > & axis_x )

Constructs a new 2D affine transformation defined by an origin and the axis_x.

It first rotates the axes and then performs the translation.

The y-axis is computed by rotating axis_x 90 degrees counter-clockwise.

Parameters
originNew origin of the reference system.
axis_xNew x-axis of the system (it will be normalized).

◆ AffineTransf() [5/8]

template<int dim>
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 3)
qugar::impl::AffineTransf< dim >::AffineTransf ( const Point< dim > & origin,
const Point< dim > & axis_x,
const Point< dim > & axis_y )

Constructs a new 3D affine transformation defined by an origin and a couple of directions that define the xy-plane.

It first rotates the axes and then performs the translation.

The given axis_x and axis_y define the xy-plane, but they may not be orthonormal vectors. Thus, the way in which the new system directions are computed is as follows: First, the axis_x is normalized. Then, the z-axis is computed as the normalized cross-product of the normalized vector axis_x and axis_y. Then, the y-axis is recomputed as the cross-product between normalized vectors along the z- and the x-axes.

Parameters
originNew origin of the reference system.
axis_xNew x-axis of the system (it will be rescaled).
axis_yAxis defining the xy-plane together with axis_x. It must be not parallel to axis_x.

◆ AffineTransf() [6/8]

template<int dim>
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 2)
qugar::impl::AffineTransf< dim >::AffineTransf ( const Point< dim > & origin,
const Point< dim > & axis_x,
real scale_x,
real scale_y )

Constructs a new 2D affine transformation defined by an origin, the axis_x, and an orthotropic scaling along the x- and y-axes.

It first applies the scaling, then rotates the axes, and finally performs the translation.

The y-axis is computed by rotating axis_x 90 degrees counter-clockwise.

Parameters
originNew origin of the reference system.
axis_xNew x-axis of the system (it will be rescaled).
scale_xScaling along the new x-axis.
scale_yScaling along the new y-axis.

◆ AffineTransf() [7/8]

template<int dim>
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 3)
qugar::impl::AffineTransf< dim >::AffineTransf ( const Point< dim > & origin,
const Point< dim > & axis_x,
const Point< dim > & axis_y,
real scale_x,
real scale_y,
real scale_z )

Constructs a new 3D affine transformation defined by an origin, a couple of directions that define the xy-plane, and an orthotropic scaling along the x-, y, and z-axes.

It first applies the scaling, then rotates the axes, and finally performs the translation.

The given axis_x and axis_y define the xy-plane, but they may not be orthonormal vectors. Thus, the way in which the new system directions are computed is as follows: First, the axis_x is normalized. Then, the z-axis is computed as the normalized cross-product of the normalized vector axis_x and axis_y. Then, the y-axis is recomputed as the cross-product between normalized vectors along the z- and the x-axes.

Parameters
originNew origin of the reference system.
axis_xNew x-axis of the system (it will be rescaled).
axis_yAxis defining the xy-plane together with axis_x. It must be not parallel to axis_x.
scale_xScaling along the new x-axis.
scale_yScaling along the new y-axis.
scale_zScaling along the new z-axis.

◆ AffineTransf() [8/8]

template<int dim>
qugar::impl::AffineTransf< dim >::AffineTransf ( const Vector< real, n_coefs > & coefs)
explicit

Constructs a new object through its coefficients. a new Affine Transf object.

See the class documentation for information about the coefficients.

Parameters
coefsTransformation coefficients.

Member Function Documentation

◆ compute_coefs() [1/3]

template<int dim>
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 2)
static Vector< real, n_coefs > qugar::impl::AffineTransf< dim >::compute_coefs ( const Point< dim > & origin,
const Point< dim > & axis_x = Point< dim >(numbers::onenumbers::zero),
real scale_x = numbers::one,
real scale_y = numbers::one )
staticnodiscardprivate

Computes the coefficients of a new 2D affine transformation defined by an origin, the axis_x, and an orthotropic scaling along the x- and y-axes.

It first applies the scaling, then rotates the axes, and finally performs the translation.

The y-axis is computed by rotating axis_x 90 degrees counter-clockwise.

The scaling is performed respect to the new (rotated/translated) reference system.

Parameters
originNew origin of the reference system.
axis_xNew x-axis of the system (it will be rescaled).
scale_xScaling along the new x-axis.
scale_yScaling along the new y-axis.

◆ compute_coefs() [2/3]

template<int dim>
template<int dim_aux = dim>
requires (dim_aux == dim && dim == 3)
static Vector< real, n_coefs > qugar::impl::AffineTransf< dim >::compute_coefs ( const Point< dim > & origin,
const Point< dim > & axis_x = Point< dim >(numbers::onenumbers::zeronumbers::zero),
const Point< dim > & axis_y = Point< dim >(numbers::zeronumbers::onenumbers::zero),
real scale_x = numbers::one,
real scale_y = numbers::one,
real scale_z = numbers::one )
staticnodiscardprivate

Computes the coefficients of a new 3D affine transformation defined by an origin, a couple of directions that define the xy-plane, and an orthotropic scaling along the x-, y, and z-axes.

It first applies the scaling, then rotates the axes, and finally performs the translation.

The given axis_x and axis_y define the xy-plane, but they may not be orthonormal vectors. Thus, the way in which the new system directions are computed is as follows: First, the axis_x is normalized. Then, the z-axis is computed as the normalized cross-product of the normalized vector axis_x and axis_y. Then, the y-axis is recomputed as the cross-product between normalized vectors along the z- and the x-axes.

The scaling is performed respect to the new (rotated/translated) reference system.

Parameters
originNew origin of the reference system.
axis_xNew x-axis of the system (it will be rescaled).
axis_yAxis defining the xy-plane together with axis_x. It must be not parallel to axis_x.
scale_xScaling along the new x-axis.
scale_yScaling along the new y-axis.
scale_zScaling along the new z-axis.
Returns
Computed coefficients.

◆ compute_coefs() [3/3]

template<int dim>
static Vector< real, n_coefs > qugar::impl::AffineTransf< dim >::compute_coefs ( const Point< dim > & origin,
real scale )
staticnodiscardprivate

Computes the coefficients of a new 2D affine transformation that translates the origin and apply an isotropic scaling.

It first applies the scaling and then performs the translation.

Parameters
originNew origin of the reference system.
scaleScaling factor to be applied along all the directions.
Returns
Computed coefficients.

◆ inverse()

template<int dim>
AffineTransf< dim > qugar::impl::AffineTransf< dim >::inverse ( ) const

Inverts the current transformation.

Returns
Inverted transformation.

◆ operator*()

template<int dim>
AffineTransf< dim > qugar::impl::AffineTransf< dim >::operator* ( const AffineTransf< dim > & rhs) const

Concatenates two affine transformation to generate a new one.

The new generated transformation is equivalent to, first, applying the given rhs transformation to a point (gradient, hessian), and then, the current one.

Parameters
rhsFirst transformation to apply.
Returns
Concatenated transformations.

◆ transform_point()

template<int dim>
template<typename T >
Vector< T, dim > qugar::impl::AffineTransf< dim >::transform_point ( const Vector< T, dim > & point) const
nodiscard

Transforms a point from the original to the new reference system.

Template Parameters
TType of the point.
Parameters
pointPoint to be transformed.
Returns
Transformed point.

◆ transform_tensor()

template<int dim>
template<typename T >
Tensor< T > qugar::impl::AffineTransf< dim >::transform_tensor ( const Tensor< T > & tensor) const
nodiscard

Transforms a (second-order symmetric) tensor from the original to the new reference system (without translation).

Template Parameters
TType of the tensor.
Parameters
tensorSecond-order symmetric tensor to be transformed.
Returns
Transformed tnesor.

◆ transform_vector()

template<int dim>
template<typename T >
Vector< T, dim > qugar::impl::AffineTransf< dim >::transform_vector ( const Vector< T, dim > & vector) const
nodiscard

Transforms a vector from the original to the new reference system (without translation).

Template Parameters
TType of the vector.
Parameters
vectorVector to be transformed.
Returns
Transformed vector.

Member Data Documentation

◆ coefs_

template<int dim>
Vector<real, n_coefs> qugar::impl::AffineTransf< dim >::coefs_
private

Transformation coefficients.

◆ n_coefs

template<int dim>
int qugar::impl::AffineTransf< dim >::n_coefs = dim * (dim + 1)
staticconstexpr

The documentation for this class was generated from the following file: