From 359da594db4580f7578276d8f1b420a23510f5ac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 10 Aug 2017 16:16:26 +0200 Subject: tracker/pt: move Affine class to cv/ --- cv/affine.cpp | 32 ++++++++++++++++++++++++++++++++ cv/affine.hpp | 29 +++++++++++++++++++++++++++++ cv/numeric.hpp | 22 ++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 cv/affine.cpp create mode 100644 cv/affine.hpp create mode 100644 cv/numeric.hpp (limited to 'cv') diff --git a/cv/affine.cpp b/cv/affine.cpp new file mode 100644 index 00000000..9018e107 --- /dev/null +++ b/cv/affine.cpp @@ -0,0 +1,32 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "affine.hpp" + +Affine::Affine() : R(mat33::eye()), t(0,0,0) {} + +Affine::Affine(const mat33& R, const vec3& t) : R(R),t(t) {} + +Affine operator*(const Affine& X, const Affine& Y) +{ + return Affine(X.R*Y.R, X.R*Y.t + X.t); +} + +Affine operator*(const mat33& X, const Affine& Y) +{ + return Affine(X*Y.R, X*Y.t); +} + +Affine operator*(const Affine& X, const mat33& Y) +{ + return Affine(X.R*Y, X.t); +} + +vec3 operator*(const Affine& X, const vec3& v) +{ + return X.R*v + X.t; +} diff --git a/cv/affine.hpp b/cv/affine.hpp new file mode 100644 index 00000000..aedb0bc8 --- /dev/null +++ b/cv/affine.hpp @@ -0,0 +1,29 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#pragma once + +#include +#include "numeric.hpp" +using namespace types; + + + +class Affine final +{ +public: + Affine(); + Affine(const mat33& R, const vec3& t); + + mat33 R; + vec3 t; +}; + +Affine operator*(const Affine& X, const Affine& Y); +Affine operator*(const mat33& X, const Affine& Y); +Affine operator*(const Affine& X, const mat33& Y); +vec3 operator*(const Affine& X, const vec3& v); diff --git a/cv/numeric.hpp b/cv/numeric.hpp new file mode 100644 index 00000000..4761af1d --- /dev/null +++ b/cv/numeric.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +namespace types { + using f = double; + + struct constants final + { + constants() = delete; + static constexpr f eps = f(1e-8); + }; + + template using vec = cv::Vec; + using vec2 = vec<2>; + using vec3 = vec<3>; + + template using mat = cv::Matx; + using mat33 = mat<3, 3>; + using mat22 = mat<2, 2>; +} -- cgit v1.2.3