QUGaR 0.0.4
Loading...
Searching...
No Matches
affine_transf.hpp
Go to the documentation of this file.
1// --------------------------------------------------------------------------
2//
3// Copyright (C) 2025-present by Pablo Antolin
4//
5// This file is part of the QUGaR library.
6//
7// SPDX-License-Identifier: MIT
8//
9// --------------------------------------------------------------------------
10
11#ifndef QUGAR_IMPL_AFFINE_TRANSF_HPP
12#define QUGAR_IMPL_AFFINE_TRANSF_HPP
13
20
21#include <qugar/numbers.hpp>
22#include <qugar/point.hpp>
23#include <qugar/types.hpp>
24#include <qugar/vector.hpp>
25
26#include <utility>
27
28namespace qugar::impl {
29
31
32
45template<int dim> class AffineTransf
46{
47public:
48 static constexpr int n_coefs = dim * (dim + 1);
49 template<typename T> using Tensor = Vector<T, dim *(dim + 1) / 2>;
50
53 explicit AffineTransf();
54
58 explicit AffineTransf(const Point<dim> &origin);
59
65 AffineTransf(const Point<dim> &origin, real scale);
66
75 template<int dim_aux = dim>
76 requires(dim_aux == dim && dim == 2)
77 AffineTransf(const Point<dim> &origin, const Point<dim> &axis_x);
78
95 template<int dim_aux = dim>
96 requires(dim_aux == dim && dim == 3)
97 AffineTransf(const Point<dim> &origin, const Point<dim> &axis_x, const Point<dim> &axis_y);
98
110 template<int dim_aux = dim>
111 requires(dim_aux == dim && dim == 2)
112 AffineTransf(const Point<dim> &origin, const Point<dim> &axis_x, real scale_x, real scale_y);
113
133 template<int dim_aux = dim>
134 requires(dim_aux == dim && dim == 3)
136 const Point<dim> &axis_x,
137 const Point<dim> &axis_y,
138 real scale_x,
139 real scale_y,
140 real scale_z);
141
147 explicit AffineTransf(const Vector<real, n_coefs> &coefs);
148
158
163
169 template<typename T> [[nodiscard]] Vector<T, dim> transform_point(const Vector<T, dim> &point) const;
170
177 template<typename T> [[nodiscard]] Vector<T, dim> transform_vector(const Vector<T, dim> &vector) const;
178
185 template<typename T> [[nodiscard]] Tensor<T> transform_tensor(const Tensor<T> &tensor) const;
186
187private:
196 [[nodiscard]] static Vector<real, n_coefs> compute_coefs(const Point<dim> &origin, real scale);
197
220 template<int dim_aux = dim>
221 requires(dim_aux == dim && dim == 3)
222 [[nodiscard]] static Vector<real, n_coefs> compute_coefs(const Point<dim> &origin,
225 real scale_x = numbers::one,
226 real scale_y = numbers::one,
227 real scale_z = numbers::one);
228
242 template<int dim_aux = dim>
243 requires(dim_aux == dim && dim == 2)
244 [[nodiscard]] static Vector<real, n_coefs> compute_coefs(const Point<dim> &origin,
246 real scale_x = numbers::one,
247 real scale_y = numbers::one);
248
251};
252
253
254}// namespace qugar::impl
255
256
257#endif// QUGAR_IMPL_AFFINE_TRANSF_HPP
Class for representing affine transformations.
Definition affine_transf.hpp:46
AffineTransf(const Point< dim > &origin, real scale)
Constructs a new affine transformation that first applies an isotropic scaling and then translates th...
Vector< T, dim > transform_point(const Vector< T, dim > &point) const
Transforms a point from the original to the new reference system.
AffineTransf(const Vector< real, n_coefs > &coefs)
Constructs a new object through its coefficients. a new Affine Transf object.
Vector< T, dim > transform_vector(const Vector< T, dim > &vector) const
Transforms a vector from the original to the new reference system (without translation).
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 th...
Tensor< T > transform_tensor(const Tensor< T > &tensor) const
Transforms a (second-order symmetric) tensor from the original to the new reference system (without t...
AffineTransf(const Point< dim > &origin)
Constructs a new affine tranformation that simply translates the origin.
AffineTransf()
Default constructor. Creates the identity transformation.
static Vector< real, n_coefs > compute_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 directi...
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 scalin...
AffineTransf< dim > inverse() const
Inverts the current transformation.
Vector< real, n_coefs > coefs_
Transformation coefficients.
Definition affine_transf.hpp:250
static constexpr int n_coefs
Definition affine_transf.hpp:48
AffineTransf< dim > operator*(const AffineTransf< dim > &rhs) const
Concatenates two affine transformation to generate a new one.
AffineTransf(const Point< dim > &origin, const Point< dim > &axis_x)
Constructs a new 2D affine transformation defined by an origin and the axis_x.
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...
static Vector< real, n_coefs > compute_coefs(const Point< dim > &origin, real scale)
Computes the coefficients of a new 2D affine transformation that translates the origin and apply an i...
static Vector< real, n_coefs > compute_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,...
Vector< T, dim *(dim+1)/2 > Tensor
Definition affine_transf.hpp:49
Definition affine_transf.hpp:28
std::pair< Point< 3 >, Point< 3 > > create_reference_system_around_axis(Point< 3 > axis_z)
constexpr real zero
Real zero value.
Definition numbers.hpp:20
constexpr real one
Real one value.
Definition numbers.hpp:22
double real
Definition types.hpp:18
::algoim::uvector< T, dim > Vector
Class representing a vector.
Definition vector.hpp:31
Vector< T, dim > Point
Class representing a dim-dimensional Point.
Definition point.hpp:34
Declaration of constant values.
Definition and implementation of Point class.
Declaration of types.