Banuba SDK
|
This class implements affine or perspective 2d transformations Standard usage implies transformation from common basis into other(common, image or standard) basis (e.g. More...
#include <transformation.hpp>
Classes | |
struct | affine_coeffs_t |
Public Types | |
enum class | rotate_t : uint32_t { deg_0 = 0 , deg_90 = 90 , deg_180 = 180 , deg_270 = 270 } |
Rotation is counter clockwise(only in standart basis): More... | |
using | mat_t = std::array<float, mat_s * mat_s> |
3x3 row-maj transform matrix | |
Public Member Functions | |
transformation () | |
Constructs identity transform. | |
transformation (const mat_t &mat) | |
Constructs from mat_t. | |
transformation (mat_t::const_pointer mat) | |
transformation (rotate_t rotate) | |
Constructs rotate transformation. | |
transformation (float scale_x, float scale_y=1.f, float t_x=0, float t_y=0, rotate_t rotate=rotate_t::deg_0, bool flip_x=false, bool flip_y=false) | |
Constructs affine transformation. | |
transformation (affine_coeffs_t coeffs) | |
Constructs affine transformation. | |
transformation (pixel_rect source_rect, pixel_rect target_rect, rotate_t rotate=rotate_t::deg_0, bool flip_x=false, bool flip_y=false) | |
Constructs transformation from source to target rectangle Rotation and flips are around rectangles' center. | |
transformation (transformation &&t) noexcept | |
transformation & | operator= (transformation &&t) noexcept |
transformation (const transformation &t) | |
transformation & | operator= (const transformation &t) |
transformation | operator>> (const transformation &t) const noexcept |
Applies transform t after this e.g. | |
point2d | operator* (const point2d &point) const noexcept |
Apply transform to point. | |
bool | operator== (const transformation &t) const noexcept |
transformation | inverse () const |
Get the inverse of the transformation. | |
transformation | clone () const noexcept |
Clone the transformation. | |
mat_t::const_pointer | data () const noexcept |
Pointer to matrix data in memory (row major) | |
mat_t | get_mat () const noexcept |
Returns 3x3 row-maj transform matrix. | |
mat_t | transposed_data () const noexcept |
Returns transposed matrix data (column major, opengl) | |
std::string | to_string () const noexcept |
Cast to string for debug purposes. | |
bool | is_affine () const noexcept |
Checks if last row is [0, 0, 1] up to float precision. | |
void | normalize_affine () noexcept |
Normalizes transform to be exactly affine. | |
std::optional< transformation::affine_coeffs_t > | extract_affine_coeffs () const |
Tries to extract affine coefficients from transformation. | |
std::shared_ptr< interfaces::transformation > | chain_right (const std::shared_ptr< interfaces::transformation > &t) const override |
interfaces::point2d | transform_point (const interfaces::point2d &p) const override |
Apply transform to point. | |
interfaces::pixel_rect | transform_rect (const interfaces::pixel_rect &rect) const override |
bool | equals (const std::shared_ptr< interfaces::transformation > &t) const override |
std::shared_ptr< interfaces::transformation > | inverse_j () const override |
Get the inverse of the transformation. | |
std::shared_ptr< interfaces::transformation > | clone_j () const override |
Clone the transformation. | |
std::vector< float > | get_mat_j () const override |
Returns 3x3 row-maj transform matrix. | |
Public Member Functions inherited from bnb::interfaces::transformation | |
virtual std::shared_ptr< transformation > | chain_right (const std::shared_ptr< transformation > &t) const =0 |
Applies transform t after this e.g. | |
virtual bool | equals (const std::shared_ptr< transformation > &t) const =0 |
Static Public Member Functions | |
static const transformation & | get_flip_instance (bool flip_x, bool flip_y) |
Get reference to static flip-only transform. | |
Static Public Member Functions inherited from bnb::interfaces::transformation | |
static std::shared_ptr< transformation > | make_identity () |
Constructs identity transform. | |
static std::shared_ptr< transformation > | make_data (const std::vector< float > &mat) |
Constructs from mat_t. | |
static std::shared_ptr< transformation > | make_rot (rotation rot) |
Constructs rotate transformation. | |
static std::shared_ptr< transformation > | make_affine (float scale_x, float scale_y, float t_x, float t_y, rotation rot, bool flip_x, bool flip_y) |
Constructs affine transformation. | |
static std::shared_ptr< transformation > | make_rects (const pixel_rect &source_rect, const pixel_rect &target_rect, rotation rot, bool flip_x, bool flip_y) |
Constructs transformation from source to target rectangle Rotation and flips are around rectangles' center. | |
Static Public Attributes | |
static const int | mat_s = 3 |
This class implements affine or perspective 2d transformations Standard usage implies transformation from common basis into other(common, image or standard) basis (e.g.
written as (common -> image) in documentation)
Frequently used basises are: <f ^f >f vf: direction of face-up vector left, up, right, down
standard basis: ^ y | ^f .--> x
common basis = image(buffer) basis: .--> x | ^f v y
Definition at line 58 of file transformation.hpp.
using bnb::transformation::mat_t = std::array<float, mat_s * mat_s> |
3x3 row-maj transform matrix
Definition at line 64 of file transformation.hpp.
|
strong |
Rotation is counter clockwise(only in standart basis):
Definition at line 70 of file transformation.hpp.
|
virtual |
Reimplemented from bnb::interfaces::transformation.
|
inlineoverride |
Definition at line 161 of file transformation.hpp.
|
inlineoverridevirtual |
Clone the transformation.
Implements bnb::interfaces::transformation.
Definition at line 175 of file transformation.hpp.
|
inlineoverride |
Definition at line 167 of file transformation.hpp.
|
inlineoverridevirtual |
Returns 3x3 row-maj transform matrix.
Implements bnb::interfaces::transformation.
Definition at line 179 of file transformation.hpp.
transformation bnb::transformation::inverse | ( | ) | const |
Get the inverse of the transformation.
std::logic_error | when matrix is singular |
|
inlineoverridevirtual |
Get the inverse of the transformation.
std::logic_error | when matrix is singular |
Implements bnb::interfaces::transformation.
Definition at line 171 of file transformation.hpp.
|
noexcept |
Normalizes transform to be exactly affine.
Results are invalid in case last row is not [~0, ~0, C]
|
noexcept |
Applies transform t after this e.g.
{rotate >> translate;} rotates first: (initial -> rotated) >> (rotated -> translated) = (initial -> translated)
|
static |
Definition at line 61 of file transformation.hpp.