cgv
|
namespace with classes and algorithms for mathematics More...
Classes | |
class | adjacency_list |
struct | diag_mat |
class | fibo_heap |
class | fmat |
matrix of fixed size dimensions More... | |
class | fvec |
class | interval |
class | mat |
class | mfunc |
struct | perm_mat |
class | qem |
dimension independent implementation of quadric error metrics More... | |
class | quaternion |
struct | random |
struct | register_sparse_les_factory |
helper template to register a sparse les solver More... | |
class | rigid_transform |
class | sparse_les |
class | sparse_les_factory |
factory class for sparse linear system solvers More... | |
class | sparse_les_factory_impl |
implementation of factory class for sparse linear system solvers More... | |
struct | thin_hyper_plate_spline |
struct | thin_plate_spline |
class | tri_diag_mat |
struct | union_find |
class | v2_func |
class | v3_func |
class | vec |
A column vector class. More... | |
Typedefs | |
typedef cgv::data::ref_ptr< sparse_les, true > | sparse_les_ptr |
reference counted pointer type for sparse les solver | |
typedef cgv::data::ref_ptr< sparse_les_factory, true > | sparse_les_factory_ptr |
reference counted pointer type for sparse les solver factories | |
Enumerations | |
enum | SparseLesCaps |
capability options for a sparse linear solver | |
Functions | |
template<typename T > | |
fvec< T, 3 > | mean (const std::vector< fvec< T, 3 > > &P, T inv_n=T(1)/P.size()) |
mean of point set | |
template<typename T , cgv::type::uint32_type N, cgv::type::uint32_type M> | |
void | svd (const fmat< T, N, M > &A, fmat< T, N, N > &U, fvec< T, M > &D, fmat< T, M, M > &V_t, bool ordering=true, int maxiter=30) |
svd wrapper | |
template<typename T , typename T_SVD = T> | |
void | align (const std::vector< fvec< T, 3 > > &source_points, const std::vector< fvec< T, 3 > > &target_points, fmat< T, 3, 3 > &O, fvec< T, 3 > &t, T *scale_ptr=nullptr, bool allow_reflection=false) |
compute rigid body transformation and optionally uniform scaling to align source point set to target point set in least squares sense More... | |
template<typename T > | |
T | bipoly_val (const mat< T > &bp, const T &x1, const T &x2) |
template<typename T > | |
T | bipoly_val (const mat< T > &bp, const vec< T > &x) |
template<typename T > | |
mat< T > | bipoly_int_x1 (const mat< T > &bp, const T &k=0) |
analytic integration of bivariate polynomial int p(x1,x2) dx1 | |
template<typename T > | |
mat< T > | bipoly_int_x2 (const mat< T > &bp, const T &k=0) |
analytic integration of bivariate polynomial int p(x1,x2) dx2 | |
template<typename key_type , typename idx_type > | |
void | bucket_sort (const std::vector< key_type > &keys, size_t nr_keys, std::vector< idx_type > &perm, std::vector< idx_type > *perm_in_ptr=0) |
compute a permutation perm with bucket_sort over index typed keys that a limited to nr_keys, optionally provide an initial permutation | |
template<typename T > | |
mat< T > | create_color_map (unsigned steps=256, std::string name="jet") |
template<typename T > | |
void | rgb_2_xyz (math::mat< T > &m) |
convert matrix columns from rgb to xyz | |
template<typename T > | |
math::vec< T > | xyz_2_rgb (const math::vec< T > &xyz) |
convert colo vector from xyz to rgb | |
template<typename T > | |
void | xyz_2_rgb (math::mat< T > &m) |
convert matrix columns from xyz to rgb | |
template<typename T > | |
const diag_mat< T > | operator* (const T &s, const diag_mat< T > &m) |
multiplication of scalar s and diagonal matrix m | |
template<typename T , typename S > | |
const diag_mat< T > | operator* (const diag_mat< S > &s, const diag_mat< T > &m) |
matrix multiplication of diagonal matrix s and m | |
template<typename T > | |
mat< T > | operator* (const perm_mat &p, const diag_mat< T > &m) |
multiplies a permutation matrix from left to apply a rows permutation | |
template<typename T > | |
mat< T > | operator* (const diag_mat< T > &m, const perm_mat &p) |
multiplies a permutation matrix from right to apply a rows permutation | |
template<typename T > | |
const mat< T > | operator* (const diag_mat< T > &s, const mat< T > &m) |
matrix multiplication of matrix m by a diagonal matrix s | |
template<typename T > | |
const up_tri_mat< T > | operator* (const up_tri_mat< T > &m, const diag_mat< T > &s) |
matrix multiplication of upper triangular matrix m by a diagonal matrix s | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const diag_mat< T > &m) |
output of a diagonal matrix onto an ostream | |
template<typename T > | |
std::istream & | operator>> (std::istream &in, diag_mat< T > &m) |
input of a diagonal matrix from an istream | |
template<typename T > | |
void | sqrdist_transf_1d (const vec< T > &f, vec< T > &d) |
template<typename T > | |
void | sqrdist_transf_2d (const mat< T > &input, mat< T > &output, T on=1) |
compute the squared distance transform of an input image | |
template<typename T > | |
void | dist_transf_2d (mat< T > &input, mat< T > &output, T on=1) |
compute the distance transform of an input image | |
template<typename T > | |
bool | eig_sym (const mat< T > &a, mat< T > &v, diag_mat< T > &d, bool ordering=true, unsigned maxiter=50) |
template<typename T , cgv::type::uint32_type N> | |
fmat< T, N, N > | transpose (const fmat< T, N, N > &m) |
return the transposed of a square matrix | |
template<typename T , cgv::type::uint32_type N, cgv::type::uint32_type M> | |
fmat< T, N, M > | operator* (const T &s, const fmat< T, N, M > &m) |
return the product of a scalar s and a matrix m | |
template<typename T , cgv::type::uint32_type N, cgv::type::uint32_type M> | |
fvec< T, M > | operator* (const fvec< T, N > &v_row, const fmat< T, N, M > &m) |
multiply a row vector from the left to matrix m and return a row vector | |
template<typename T , cgv::type::uint32_type N, cgv::type::uint32_type M> | |
std::ostream & | operator<< (std::ostream &out, const fmat< T, N, M > &m) |
output of a matrix onto an ostream | |
template<typename T , cgv::type::uint32_type N, cgv::type::uint32_type M> | |
std::istream & | operator>> (std::istream &in, fmat< T, N, M > &m) |
input of a matrix onto an ostream | |
template<typename T , cgv::type::uint32_type N, typename S , cgv::type::uint32_type M> | |
fmat< T, N, M > | dyad (const fvec< T, N > &v, const fvec< S, M > &w) |
returns the outer product of vector v and w | |
template<typename T , cgv::type::uint32_type N, cgv::type::uint32_type M> | |
const fmat< T, N, M > | lerp (const fmat< T, N, M > &m1, const fmat< T, N, M > &m2, T t) |
linear interpolation returns (1-t)*m1 + t*m2 | |
template<typename T , cgv::type::uint32_type N, cgv::type::uint32_type M> | |
const fmat< T, N, M > | lerp (const fmat< T, N, M > &m1, const fmat< T, N, M > &m2, fmat< T, N, M > t) |
linear interpolation returns (1-t)*m1 + t*m2 | |
template<typename T > | |
fmat< T, 4, 4 > | zero4 () |
construct 4x4 zero matrix | |
template<typename T > | |
fmat< T, 4, 4 > | identity4 () |
construct 4x4 identity matrix | |
template<typename T > | |
fmat< T, 4, 4 > | translate4 (const fvec< T, 3 > &t) |
construct 4x4 translation matrix from vec3 | |
template<typename T > | |
fmat< T, 4, 4 > | translate4 (const T &tx, const T &ty, const T &tz) |
construct 4x4 translation matrix from xyz components | |
template<typename T > | |
fmat< T, 4, 4 > | scale4 (const fvec< T, 3 > &s) |
construct 4x4 scale matrix from xyz scales | |
template<typename T > | |
fmat< T, 4, 4 > | scale4 (const T &sx, const T &sy, const T &sz) |
construct 4x4 scale matrix from xyz scales | |
template<typename T > | |
fmat< T, 3, 3 > | rotate3 (const T &A, const fvec< T, 3 > &a) |
construct 4x4 rotation matrix from angle in degrees and axis | |
template<typename T > | |
fmat< T, 3, 3 > | rotate3 (const fvec< T, 3 > &A) |
construct 3x3 rotation matrix from kardan angles (roll, pitch, yaw) in degrees | |
template<typename T > | |
fmat< T, 4, 4 > | rotate4 (const T &A, const fvec< T, 3 > &a) |
construct 4x4 rotation matrix from angle in degrees and axis | |
template<typename T > | |
fmat< T, 4, 4 > | rotate4 (const T &A, const T &ax, const T &ay, const T &az) |
construct 4x4 rotation matrix from angle in degrees and axis | |
template<typename T > | |
fmat< T, 4, 4 > | rotate4 (const fvec< T, 3 > &A) |
construct 4x4 rotation matrix from kardan angles (roll, pitch, yaw) in degrees | |
template<typename T > | |
fmat< T, 4, 4 > | pose4 (const fmat< T, 3, 4 > &M) |
construct 4x4 pose matrix from a 3x4 matrix | |
template<typename T > | |
fmat< T, 4, 4 > | pose4 (const fmat< T, 3, 3 > &R, const fvec< T, 3 > &t) |
construct 4x4 pose matrix from a 3x3 rotation matrix and translation vector | |
template<typename T > | |
fmat< T, 4, 4 > | pose4 (const quaternion< T > &q, const fvec< T, 3 > &t) |
construct 4x4 pose matrix from quaternion and translation vector | |
template<typename T > | |
fmat< T, 4, 4 > | look_at4 (const fvec< T, 3 > &eye, const fvec< T, 3 > &focus, const fvec< T, 3 > &view_up_dir) |
return rigid body transformation that performs look at transformation | |
template<typename T > | |
fmat< T, 4, 4 > | ortho4 (const T &l, const T &r, const T &b, const T &t, const T &n, const T &f) |
construct 4x4 frustum matrix for orthographic projection | |
template<typename T > | |
fmat< T, 4, 4 > | frustum4 (const T &l, const T &r, const T &b, const T &t, const T &n, const T &f) |
construct 4x4 frustum matrix for perspective projection | |
template<typename T > | |
fmat< T, 4, 4 > | perspective4 (const T &fovy, const T &aspect, const T &zNear, const T &zFar) |
construct 4x4 perspective frustum matrix | |
template<typename T > | |
fmat< T, 4, 4 > | stereo_frustum_screen4 (int eye, const T &eyeSeparation, const T &screenWidth, const T &screenHeight, const T &zZeroParallax, const T &zNear, const T &zFar) |
return perspective projection for given eye (-1 ... left / 1 ... right) without translation | |
template<typename T > | |
fmat< T, 4, 4 > | stereo_translate_screen4 (int eye, const T &eyeSeparation, const T &screenWidth) |
return translation from center to eye (-1 ... left / 1 ... right) | |
template<typename T > | |
fmat< T, 4, 4 > | stereo_translate4 (int eye, const T &eyeSeparation, const T &fovy, const T &aspect, const T &zZeroParallax) |
return translation from center to eye (-1 ... left / 1 ... right) | |
template<typename T > | |
fmat< T, 4, 4 > | stereo_perspective_screen4 (int eye, const T &eyeSeparation, const T &screenWidth, const T &screenHeight, const T &zZeroParallax, const T &zNear, const T &zFar) |
return perspective projection for given eye (-1 ... left / 1 ... right) including translation | |
template<typename T > | |
fmat< T, 4, 4 > | stereo_perspective4 (int eye, const T &eyeSeparation, const T &fovy, const T &aspect, const T &zZeroParallax, const T &zNear, const T &zFar) |
return perspective projection for given eye (-1 ... left / 1 ... right) including translation | |
double | compute_unit_ball_volume (unsigned n) |
compute volume of unit n-ball living in n-dimensional space with n>=1; results are cached for O(1) runtime | |
double | compute_ball_volume (unsigned n, double R) |
compute volume of n-ball of radius R living in n-dimensional space with n>=1; results are cached for O(1) runtime | |
double | compute_unit_sphere_area (unsigned n) |
compute surface area of a unit n-ball living in n-dimensional space with n>=2 (this is a n-1 dimensional area); results are cached for O(1) runtime | |
double | compute_sphere_area (unsigned n, double R) |
compute surface area of a n-ball of radius R living in n-dimensional space with n>=2 (this is a n-1 dimensional area); results are cached for O(1) runtime | |
template<typename T > | |
T | sign (const T &a, const T &b) |
returns the abs(a)*sign(b) | |
template<typename T > | |
T | sign (const T &v) |
if v >= 0 returns 1 and otherwise -1 | |
template<typename T > | |
T | plus (const T &v) |
if v >= 0 returns v or 0 otherwise | |
template<typename T > | |
T | clamp (const T &v, const T &a, const T &b) |
clamp v at [a,b] | |
template<typename T > | |
T | erf (const T x) |
error function | |
template<typename T > | |
T | erfc (const T x) |
complementary error function | |
template<typename T > | |
T | erfcx (const T x) |
scaled complementary error function | |
template<typename T > | |
T | erfc_inv (const T p) |
inverse complementary error function | |
template<typename T > | |
T | erf_inv (const T p) |
inverse error function | |
template<typename T > | |
T | Phi (const T &x) |
evaluate the cummulative normal distribution function | |
template<typename T > | |
T | inv_Phi (const T &p) |
evaluate the inverse of the error function Phi^(-1)(p), p=0..1 | |
template<typename T , cgv::type::uint32_type N> | |
fvec< T, N > | normalize (const fvec< T, N > &v) |
return normalized vector | |
template<typename T , cgv::type::uint32_type N> | |
std::ostream & | operator<< (std::ostream &out, const fvec< T, N > &v) |
output of a vector | |
template<typename T , cgv::type::uint32_type N> | |
std::istream & | operator>> (std::istream &in, fvec< T, N > &v) |
input of a vector | |
template<typename T , cgv::type::uint32_type N> | |
fvec< T, N > | operator* (const T &s, const fvec< T, N > &v) |
returns the product of a scalar s and vector v | |
template<typename T , cgv::type::uint32_type N> | |
T | dot (const fvec< T, N > &v, const fvec< T, N > &w) |
returns the dot product of vector v and w | |
template<typename T , cgv::type::uint32_type N> | |
T | length (const fvec< T, N > &v) |
returns the length of vector v | |
template<typename T , cgv::type::uint32_type N> | |
fvec< T, N > | abs (const fvec< T, N > &v) |
apply abs function component wise to vector | |
template<typename T , cgv::type::uint32_type N> | |
fvec< T, N > | round (const fvec< T, N > &v) |
apply round function component wise to vector | |
template<typename T , cgv::type::uint32_type N> | |
fvec< T, N > | floor (const fvec< T, N > &v) |
apply floor function component wise to vector | |
template<typename T , cgv::type::uint32_type N> | |
fvec< T, N > | ceil (const fvec< T, N > &v) |
apply ceil function component wise to vector | |
template<typename T , cgv::type::uint32_type N> | |
T | sqr_length (const fvec< T, N > &v) |
returns the squared length of vector v | |
template<typename T , cgv::type::uint32_type N> | |
fvec< T, N > | cross (const fvec< T, N > &v, const fvec< T, N > &w) |
returns the cross product of vector v and w | |
template<typename T , cgv::type::uint32_type N> | |
fvec< T, N+1 > | hom (const fvec< T, N > &v) |
returns the cross product of vector v and w | |
template<typename T , cgv::type::uint32_type N> | |
T | min_value (const fvec< T, N > &v) |
returns the minimal entry | |
template<typename T , cgv::type::uint32_type N> | |
unsigned | min_index (const fvec< T, N > &v) |
returns the index of the smallest value | |
template<typename T , cgv::type::uint32_type N> | |
unsigned | max_index (const fvec< T, N > &v) |
return the index of the largest entry | |
template<typename T , cgv::type::uint32_type N> | |
T | max_value (const fvec< T, N > &v) |
return the value of the largest entry | |
template<typename T , cgv::type::uint32_type N> | |
const fvec< T, N > | lerp (const fvec< T, N > &v1, const fvec< T, N > &v2, T t) |
linear interpolation returns (1-t)*v1 + t*v2 | |
template<typename T , cgv::type::uint32_type N> | |
const fvec< T, N > | lerp (const fvec< T, N > &v1, const fvec< T, N > &v2, fvec< T, N > t) |
linear interpolation returns (1-t)*v1 + t*v2 | |
template<typename T > | |
bool | gaussj (mat< T > &a, mat< T > &b) |
template<typename T > | |
bool | gaussj (mat< T > &a) |
template<typename T > | |
cgv::math::fvec< T, 3 > | rotate (const cgv::math::fvec< T, 3 > &v, const cgv::math::fvec< T, 3 > &n, T a) |
rotate vector v around axis n by angle a (given in radian) More... | |
template<typename T > | |
void | compute_rotation_axis_and_angle_from_vector_pair (const cgv::math::fvec< T, 3 > &v0, const cgv::math::fvec< T, 3 > &v1, cgv::math::fvec< T, 3 > &axis, T &angle) |
compute a rotation axis and a rotation angle in radian that rotates v0 onto v1. More... | |
template<typename T > | |
int | decompose_rotation_to_axis_and_angle (const cgv::math::fmat< T, 3, 3 > &R, cgv::math::fvec< T, 3 > &axis, T &angle) |
decompose a rotation matrix into axis angle representation More... | |
template<typename T > | |
cgv::math::fmat< T, 3, 3 > | build_orthogonal_frame (const cgv::math::fvec< T, 3 > &v0, const cgv::math::fvec< T, 3 > &v1) |
Given two vectors v0 and v1 extend to orthonormal frame and return 3x3 matrix containing frame vectors in the columns. More... | |
template<typename T > | |
diag_mat< T > | inv (const diag_mat< T > &m) |
returns the inverse of a diagonal matrix | |
template<typename T > | |
low_tri_mat< T > | inv (const low_tri_mat< T > &m) |
returns the inverse of a lower triangular matrix | |
template<typename T > | |
up_tri_mat< T > | inv (const up_tri_mat< T > &m) |
returns the inverse of an upper triangular matrix | |
template<typename T > | |
mat< T > | inv (const mat< T > &m) |
returns the inverse of a square matrix | |
template<typename T > | |
mat< T > | inv_22 (const mat< T > &m) |
compute inverse of 2x2 matrix | |
template<typename T > | |
mat< T > | inv_33 (const mat< T > &m) |
compute inverse of 3x3 matrix | |
template<typename T > | |
mat< T > | inv_44 (const mat< T > &m) |
compute inverse of 4x4 matrix | |
template<typename T , cgv::type::uint32_type N> | |
fmat< T, N, N > | inv (const fmat< T, N, N > &m) |
return the inverse of a square matrix | |
template<typename T > | |
fmat< T, 2, 2 > | inv (const fmat< T, 2, 2 > &m) |
compute inverse of 2x2 matrix | |
template<typename T > | |
fmat< T, 3, 3 > | inv (const fmat< T, 3, 3 > &m) |
compute inverse of 3x3 matrix | |
template<typename T > | |
fmat< T, 4, 4 > | inv (const fmat< T, 4, 4 > &m) |
compute inverse of 4x4 matrix | |
template<typename T > | |
bool | solve (const up_tri_mat< T > &a, const vec< T > &b, vec< T > &x) |
template<typename T > | |
bool | solve (const up_tri_mat< T > &a, const mat< T > &b, mat< T > &x) |
template<typename T > | |
bool | solve (const low_tri_mat< T > &a, const vec< T > &b, vec< T > &x) |
template<typename T > | |
bool | solve (const low_tri_mat< T > &a, const mat< T > &b, mat< T > &x) |
template<typename T > | |
bool | solve (const diag_mat< T > &a, const vec< T > &b, vec< T > &x) |
template<typename T > | |
bool | solve (const tri_diag_mat< T > &a, const vec< T > &b, vec< T > &x) |
template<typename T > | |
bool | solve (const diag_mat< T > &a, const mat< T > &b, mat< T > &x) |
template<typename T > | |
bool | solve (const perm_mat &a, const vec< T > &b, vec< T > &x) |
template<typename T > | |
bool | solve (const perm_mat &a, const mat< T > &b, mat< T > &x) |
template<typename T > | |
bool | lu_solve (const mat< T > &a, const vec< T > &b, vec< T > &x) |
template<typename T > | |
bool | solve (const mat< T > &a, const vec< T > &b, vec< T > &x) |
template<typename T > | |
bool | lu_solve (const mat< T > &a, const mat< T > &b, mat< T > &x) |
template<typename T > | |
bool | solve (const mat< T > &a, const mat< T > &b, mat< T > &x) |
template<typename T > | |
bool | qr_solve (const mat< T > &a, const vec< T > &b, vec< T > &x) |
solve ax=b with qr decomposition | |
template<typename T > | |
bool | qr_solve (const mat< T > &a, const mat< T > &b, mat< T > &x) |
template<typename T > | |
bool | svd_solve (const mat< T > &a, const vec< T > &b, vec< T > &x) |
solve ax=b with svd decomposition | |
template<typename T > | |
bool | svd_solve (const mat< T > &a, const mat< T > &b, mat< T > &x) |
solve ax=b with svd decomposition | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const low_tri_mat< T > &m) |
output of a lower triangular matrix onto an ostream | |
template<typename T , typename S > | |
const mat< T > | operator* (const low_tri_mat< T > &m1, const low_tri_mat< S > &m2) |
multiplication of two lower triangular matrices | |
template<typename T > | |
bool | lu (const mat< T > &a, perm_mat &p, low_tri_mat< T > &l, up_tri_mat< T > &u) |
template<typename T > | |
const mat< T > | ceil (const mat< T > &m) |
ceil all components of the matrix | |
template<typename T > | |
const mat< T > | floor (const mat< T > &m) |
floor all components of the matrix | |
template<typename T > | |
const mat< T > | round (const mat< T > &m) |
round all components of the matrix | |
template<typename T > | |
mat< T > | operator* (const T &s, const mat< T > &m) |
return the product of a scalar s and a matrix m | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const mat< T > &m) |
output of a matrix onto an ostream | |
template<typename T > | |
std::istream & | operator>> (std::istream &in, mat< T > &m) |
input of a matrix onto an ostream | |
template<typename T > | |
void | Atx (const mat< T > &a, const vec< T > &x, vec< T > &atx) |
template<typename T , typename S > | |
mat< T > | dyad (const vec< T > &v, const vec< S > &w) |
returns the outer product of vector v and w | |
template<typename T > | |
T | AIC (int k, const T &L) |
template<typename T > | |
T | AIC_ls (int k, int n, const T &RSS) |
template<typename T > | |
T | AICc (int k, int n, const T &L) |
template<typename T > | |
T | AICc_ls (int k, int n, const T &RSS) |
template<typename T > | |
T | AICu_ls (int k, int n, const T &RSS) |
template<typename T > | |
T | BIC (int k, int n, const T &L) |
template<typename T > | |
T | BIC_ls (int k, int n, const T &RSS) |
void | estimate_normal_ls (unsigned nr_points, const float *_points, float *_normal, float *_evals=0, float *_mean=0, float *_evecs=0) |
Compute least squares normal from an array of 3D points. More... | |
void | estimate_normal_wls (unsigned nr_points, const float *_points, const float *_weights, float *_normal, float *_evals=0, float *_mean=0, float *_evecs=0) |
Weighted version of estimate_normal_ls with additional input _weights pointing to nr_points scalar weights. | |
template<typename T , typename I > | |
void | permute_array (size_t N, T *A, I *P) |
permute array A with N values of type T according to permutation P such that A [i] moves to A [P[i]] | |
template<typename T , typename I > | |
void | permute_vector (std::vector< T > &V, std::vector< I > &P) |
interface to permute function for arrays and permutations stored in vectors | |
template<typename T , typename I > | |
void | permute_arrays (T *data, I *P, size_t nr_rows, size_t nr_columns, size_t row_step, size_t column_step) |
permute nr_rows rows of nested 2D array with nr_columns columns, step sizes to step by one row / column need to be provided | |
template<typename T > | |
T | plane_val (const vec< T > &plane, const vec< T > &x) |
template<typename T > | |
vec< T > | plane_val (const vec< T > &plane, const mat< T > &xs) |
evaluate plame equation on multiple positions xs | |
template<typename T > | |
vec< T > | ransac_plane_fit (const mat< T > &points, const T p_out=0.8, const T d_max=0.001, const T p_surety=0.99, bool msac=true) |
template<typename T > | |
vec< T > | mean (const mat< T > &points) |
computes the mean of all column vectors | |
template<typename T > | |
cgv::math::vec< T > | geometric_median (const cgv::math::mat< T > &points, const T &eps=0.0001, const unsigned max_iter=100) |
template<typename T > | |
vec< T > | weighted_mean (const vec< T > &weights, const mat< T > &points) |
computes the weighted mean of all column vectors | |
template<typename T > | |
mat< T > | covmat (const mat< T > &points) |
compute covariance matrix of the column vectors of points | |
template<typename T > | |
mat< T > | weighted_covmat (const vec< T > &weights, const mat< T > &points) |
compute weighted covariance matrix of the column vectors of points | |
template<typename T > | |
void | weighted_covmat_and_mean (const vec< T > &weights, const mat< T > &points, mat< T > &wcovmat, vec< T > &wmean) |
compute covariance matrix and mean of the column vectors of points in one step | |
template<typename T > | |
void | covmat_and_mean (const mat< T > &points, mat< T > &covmat, vec< T > &mean) |
compute covariance matrix and mean of the column vectors of points in one step | |
template<typename T > | |
void | swap_XYZ_2_XZY (mat< T > &points) |
swap second with third row of point matrix | |
template<typename T > | |
void | homog (mat< T > &points) |
Convert a set of non-homogeneous points into homogeneous points. | |
template<typename T > | |
void | unhomog (mat< T > &points) |
Convert a set of homogeneous points into non-homogeneous points by dividing with the last component. | |
template<typename T > | |
void | polar (const mat< T > &c, mat< T > &r, mat< T > &a, int num_iter=15) |
template<typename T > | |
bool | decompose_rotation (const cgv::math::mat< T > &R, cgv::math::vec< T > &axis, T &angle) |
template<typename T > | |
T | poly_val (const vec< T > &p, const T &x) |
template<typename T > | |
vec< T > | poly_val (const vec< T > &p, const vec< T > &x) |
template<typename T > | |
vec< T > | poly_mult (const vec< T > &u, const vec< T > &v) |
1d convolution or polynomial multiplication | |
template<typename T > | |
bool | poly_div (const vec< T > &f, const vec< T > &g, vec< T > &q, vec< T > &r) |
template<typename T > | |
vec< T > | bernstein_polynomial (unsigned j, unsigned g) |
returns bernstein polynomial (bezier basis) | |
template<typename T > | |
fmat< T, 3, 3 > & | pose_orientation (fmat< T, 3, 4 > &pose) |
extract orientation matrix from pose matrix | |
template<typename T > | |
fvec< T, 3 > & | pose_position (fmat< T, 3, 4 > &pose) |
extract position vector from pose matrix | |
template<typename T > | |
fvec< T, 3 > | pose_transform_point (const fmat< T, 3, 4 > &pose, const fvec< T, 3 > &p) |
transform point with pose matrix | |
template<typename T > | |
fvec< T, 3 > | pose_transform_point (const quaternion< T > &q, const fvec< T, 3 > &pos, const fvec< T, 3 > &p) |
transform point with pose quaternion-position pair | |
template<typename T > | |
fvec< T, 3 > | pose_transform_vector (const fmat< T, 3, 4 > &pose, const fvec< T, 3 > &v) |
transform vector with pose matrix | |
template<typename T > | |
fvec< T, 3 > | inverse_pose_transform_point (const fmat< T, 3, 4 > &pose, const fvec< T, 3 > &p) |
transform point with inverse of pose matrix | |
template<typename T > | |
fvec< T, 3 > | inverse_pose_transform_vector (const fmat< T, 3, 4 > &pose, const fvec< T, 3 > &v) |
transform vector with inverse of pose matrix | |
template<typename T > | |
void | invert_pose (fmat< T, 3, 4 > &pose) |
inplace inversion of pose transformation | |
template<typename T > | |
fmat< T, 3, 4 > | pose_inverse (const fmat< T, 3, 4 > &pose) |
return a pose matrix with the inverse pose transformation | |
template<typename T > | |
fmat< T, 3, 4 > | pose_construct (const fmat< T, 3, 3 > &orientation, const fvec< T, 3 > &position) |
construct pose from rotation matrix and position vector | |
template<typename T > | |
fmat< T, 3, 4 > | pose_construct (const quaternion< T > &orientation, const fvec< T, 3 > &position) |
construct pose from rotation quaternion and position vector | |
template<typename T > | |
void | pose_append (fmat< T, 3, 4 > &pose_1, const fmat< T, 3, 4 > &pose_2) |
inplace concatenation of a pose matrix | |
template<typename T > | |
void | pose_transform (const fmat< T, 3, 4 > &pose_transform, fmat< T, 3, 4 > &pose) |
inplace transformation of a pose matrix with another pose transformation matrix | |
template<typename T > | |
fmat< T, 3, 4 > | pose_concat (const fmat< T, 3, 4 > &pose_1, const fmat< T, 3, 4 > &pose_2) |
return concatenate of two pose transformations | |
template<typename T > | |
const qem< T > | operator* (const T &s, const qem< T > &v) |
returns the product of a scalar s and qem v | |
template<typename T > | |
vec< T > | quat_multiply (const vec< T > &v, const vec< T > &q) |
template<typename T > | |
vec< T > | axis_angle_2_quat (vec< T > axis, T angle) |
returns a quaterion q defined by the given axis and angle | |
template<typename T > | |
void | quat_2_axis_angle (const vec< T > &q, vec< T > &axis, T &angle) |
extract the axis and angle in degree from quaternion q | |
template<typename T > | |
vec< T > | quat_rotate (const vec< T > &q, const vec< T > &v) |
returns the rotation of vector v by quaternion q | |
template<typename T > | |
vec< T > | quat_conj (const vec< T > &q) |
returns the conjugate quaternion q | |
template<typename T > | |
vec< T > | quat_normalize (const vec< T > &q) |
returns a normalize version of quaternion q | |
template<typename T > | |
vec< T > | quat_inv (const vec< T > &q) |
return the inverse of quaterion q | |
template<typename T > | |
mat< T > | quat_2_mat_33 (const vec< T > &q) |
convert unit quaternion to 3x3 rotation matrix | |
template<typename T > | |
mat< T > | quat_2_mat_44 (const vec< T > &q) |
convert unit quaternion to 4x4 rotation matrix | |
template<typename T > | |
quaternion< T > | operator* (const T &s, const quaternion< T > &v) |
returns the product of a scalar s and vector v | |
template<typename T > | |
unsigned | num_ransac_iterations (unsigned n_min, const T p_out, const T p_surety=0.99) |
int | solve_quadric (double c[3], double s[2], bool replicate_multiple_solutions=false) |
write the solutions to c[0]+c[1]*x+c[2]*x*x = 0 into s and return the number of solutions | |
int | solve_cubic (double c[4], double s[3], bool replicate_multiple_solutions=false) |
write the solutions to c[0]+c[1]*x+c[2]*x*x+c[3]*x*x*x = 0 into s and return the number of solutions | |
int | solve_quartic (double c[5], double s[4]) |
write the solutions to c[0]+c[1]*x+c[2]*x*x+c[3]*x*x*x+c[4]*x*x*x*x = 0 into s and return the number of solutions | |
template<typename T > | |
T | sphere_val (const vec< T > &sphere, const vec< T > &x) |
template<typename T > | |
vec< T > | sphere_val (const vec< T > &sphere, const mat< T > &xs) |
template<typename T > | |
T | sphere_val2 (const vec< T > &sphere, const vec< T > &x) |
template<typename T > | |
vec< T > | sphere_val2 (const vec< T > &sphere, const mat< T > &xs) |
template<typename T > | |
vec< T > | sphere_fit (const vec< T > &p1) |
construct smallest enclosing sphere of one point | |
template<typename T > | |
vec< T > | sphere_fit (const vec< T > &p1, const vec< T > &p2) |
sphere through 2 points | |
template<typename T > | |
vec< T > | sphere_fit (const vec< T > &O, const vec< T > &A, const vec< T > &B) |
sphere through 3 points | |
template<typename T > | |
vec< T > | sphere_fit (const vec< T > &x1, const vec< T > &x2, const vec< T > &x3, const vec< T > &x4) |
sphere through 4 points | |
template<typename T > | |
vec< T > | mini_ball (cgv::math::mat< T > &points) |
compute smallest enclosing sphere of points | |
template<typename T > | |
T | norm_pdf (const T x, const T mu=0, const T sig=1) |
normal distribution prob density function | |
template<typename T > | |
T | norm_cdf (const T x, const T mu=0, const T sig=1) |
normal cumulative distribution function | |
template<typename T > | |
T | norm_inv (const T &p, const T mu=0, const T sig=1) |
inverse normal cumulative distribution function | |
template<typename T > | |
T | logn_pdf (const T x, const T mu=0, const T sig=1) |
lognormal normal prob distribution function | |
template<typename T > | |
T | logn_cdf (const T x, const T mu=0, const T sig=1) |
log normal cumulative distribution function | |
template<typename T > | |
T | logn_inv (const T p, const T mu=0, const T sig=1) |
inverse log normal cumulative distribution function | |
template<typename T > | |
T | uniform_pdf (const T x, const T a, const T b) |
uniform distribution prob density function | |
template<typename T > | |
T | uniform_cdf (const T x, const T a, const T b) |
uniform cumulative distribution function | |
template<typename T > | |
T | ksc_cdf (const T z) |
complementary cumulative kolmogorov-smirnov distribution function | |
template<typename T > | |
T | invxlogx (const T y) |
helper function to compute ksc_inv | |
template<typename T > | |
T | ksc_inv (const T q) |
inverse complementary cumulative kolmogorv-smirnov distribution function | |
template<typename T > | |
T | ks_inv (const T p) |
inverse of the cumulative kolmogorv-smirnov distribution function | |
template<typename T > | |
T | norm_ks_test (const T mu, const T sig, vec< T > data) |
template<typename T > | |
T | ks_test (vec< T > data1, vec< T > data2) |
template<typename T > | |
bool | svd (const mat< T > &a, mat< T > &u, diag_mat< T > &w, mat< T > &v, bool ordering=true, int maxiter=30) |
template<typename T > | |
mat< T > | null (const mat< T > &a) |
compute the null space of a matrix | |
template<typename T > | |
mat< T > | null (const mat< T > &a, T tol) |
compute the effective null space of a matrix using user defined tolerance | |
template<typename T > | |
unsigned | rank (const mat< T > &a) |
computes the rank of a matrix using svd | |
template<typename T > | |
unsigned | rank (const mat< T > &a, T tol) |
computes the effective rank of a matrix using svd and the given tolerance tol | |
template<typename T > | |
unsigned | solve_underdetermined_system (const cgv::math::mat< T > &A, const cgv::math::vec< T > &b, cgv::math::vec< T > &p, cgv::math::mat< T > &N) |
template<typename T > | |
void | find_nonrigid_transformation (const mat< T > &points1, const mat< T > &points2, thin_plate_spline< T > &spline) |
template<typename T > | |
void | find_nonrigid_transformation (const mat< T > &points1, const mat< T > &points2, thin_hyper_plate_spline< T > &spline) |
template<typename T > | |
void | apply_nonrigid_transformation (const thin_plate_spline< T > &s, mat< T > &points) |
template<typename T > | |
void | apply_nonrigid_transformation (const thin_hyper_plate_spline< T > &s, mat< T > &points) |
template<typename T > | |
const mat< T > | scale_33 (const T &sx, const T &sy, const T &sz) |
creates a 3x3 scale matrix | |
template<typename T > | |
const mat< T > | scale_33 (const T &s) |
creates a 3x3 uniform scale matrix | |
template<typename T > | |
const mat< T > | rotatex_33 (const T &angle) |
creates a 3x3 rotation matrix around the x axis, the angle is in degree | |
template<typename T > | |
const mat< T > | rotatey_33 (const T &angle) |
creates a 3x3 rotation matrix around the y axis, the angle is in degree | |
template<typename T > | |
const mat< T > | rotatez_33 (const T &angle) |
creates a 3x3 rotation matrix around the z axis, the angle is in degree | |
template<typename T > | |
const mat< T > | rotate_22 (const T &angle) |
creates a 2x2 rotation matrix around the z axis, the angle is in degree | |
template<typename T > | |
const mat< T > | rotate_euler_33 (const T &yaw, const T &pitch, const T &roll) |
creates a 3x3 euler rotation matrix from yaw, pitch and roll given in degree | |
template<typename T > | |
const mat< T > | rotate_rodrigues_33 (const vec< T > &r) |
creates a 3x3 rotation matrix from a rodrigues vector | |
template<typename T > | |
const mat< T > | shearxy_33 (const T &shx, const T ­) |
creates a homogen 3x3 shear matrix with given shears shx in x direction, and shy in y direction | |
template<typename T > | |
const mat< T > | shearxz_33 (const T &shx, const T &shz) |
creates a homogen 3x3 shear matrix with given shears shx in x direction, and shy in y direction | |
template<typename T > | |
const mat< T > | shearyz_33 (const T ­, const T &shz) |
creates a homogen 3x3 shear matrix with given shears shy in y direction, and shz in z direction | |
template<typename T > | |
const mat< T > | shear_33 (const T &syx, const T &szx, const T &sxy, const T &szy, const T &sxz, const T &syz) |
creates a homogen 3x3 shear matrix | |
template<typename T > | |
const mat< T > | translate_44 (const T &x, const T &y, const T &z) |
creates a 4x4 translation matrix | |
template<typename T > | |
const mat< T > | translate_44 (const vec< T > &v) |
creates a 4x4 translation matrix | |
template<typename T > | |
const mat< T > | scale_44 (const T &sx, const T &sy, const T &sz) |
creates a 4x4 scale matrix | |
template<typename T > | |
const mat< T > | scale_44 (const T &s) |
creates a 4x4 uniform scale matrix | |
template<typename T > | |
const mat< T > | rotatex_44 (const T &angle) |
creates a 4x4 rotation matrix around the x axis, the angle is in degree | |
template<typename T > | |
const mat< T > | rotatey_44 (const T &angle) |
creates a 4x4 rotation matrix around the y axis, the angle is in degree | |
template<typename T > | |
const mat< T > | rotatez_44 (const T &angle) |
creates a 4x4 rotation matrix around the z axis, the angle is in degree | |
template<typename T > | |
const mat< T > | rotate_euler_44 (const T &yaw, const T &pitch, const T &roll) |
creates a 4x4 euler rotation matrix from yaw, pitch and roll given in degree | |
template<typename T > | |
const mat< T > | shearxy_44 (const T &shx, const T ­) |
creates a homogen 4x4 shear matrix with given shears shx in x direction, and shy in y direction | |
template<typename T > | |
const mat< T > | shearxz_44 (const T &shx, const T &shz) |
creates a homogen 4x4 shear matrix with given shears shx in x direction, and shy in y direction | |
template<typename T > | |
const mat< T > | shearyz_44 (const T ­, const T &shz) |
creates a homogen 4x4 shear matrix with given shears shy in y direction, and shz in z direction | |
template<typename T > | |
const mat< T > | shear_44 (const T &syx, const T &szx, const T &sxy, const T &szy, const T &sxz, const T &syz) |
creates a homogen 4x4 shear matrix | |
template<typename T > | |
const mat< T > | perspective_44 (const T &fovy, const T &aspect, const T &znear, const T &zfar) |
creates a perspective transformation matrix in the same way as gluPerspective does | |
template<typename T > | |
mat< T > | viewport_44 (const T &xoff, const T yoff, const T &width, const T &height) |
creates a viewport transformation matrix | |
template<typename T > | |
const mat< T > | look_at_44 (const T &eyex, const T &eyey, const T &eyez, const T ¢erx, const T ¢ery, const T ¢erz, const T &upx, const T &upy, const T &upz) |
creates a look at transformation matrix in the same way as gluLookAt does | |
template<typename T > | |
const mat< T > | frustrum_44 (const T &left, const T &right, const T &bottom, const T &top, const T &znear, const T &zfar) |
creates a frustrum projection matrix in the same way as glFrustum does | |
template<typename T > | |
const mat< T > | ortho_44 (const T &left, const T &right, const T &bottom, const T &top, const T &znear, const T &zfar) |
creates an orthographic projection matrix in the same way as glOrtho does | |
template<typename T > | |
const mat< T > | ortho2d_44 (const T &left, const T &right, const T &bottom, const T &top) |
creates an orthographic projection matrix in the same way as glOrtho2d does | |
template<typename T > | |
const mat< T > | pick_44 (const T &x, const T &y, const T &width, const T &height, int viewport[4], const mat< double > &modelviewproj, bool flipy=true) |
creates a picking matrix like gluPickMatrix with pixel (0,0) in the lower left corner if flipy=false | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const up_tri_mat< T > &m) |
output of a upper triangular matrix onto an ostream | |
template<typename T > | |
vec< T > | normalize (const vec< T > &v) |
returns a normalized version of v | |
template<typename T , typename S > | |
T | p_norm (const vec< T > &values, const S &p=1) |
return the p-norm of the vector default is p == 1 | |
template<typename T > | |
T | inf_norm (const vec< T > &values) |
return the infinity norm of the vector | |
template<typename T > | |
T | length (const vec< T > &v) |
returns the length of v L2-norm | |
template<typename T > | |
T | sqr_length (const vec< T > &v) |
returns the square length of v | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const vec< T > &v) |
output of a vector | |
template<typename T > | |
std::istream & | operator>> (std::istream &in, vec< T > &v) |
input of a vector | |
template<typename T > | |
const vec< T > | operator* (const T &s, const vec< T > &v) |
returns the product of a scalar s and vector v | |
template<typename T > | |
T | dot (const vec< T > &v, const vec< T > &w) |
returns the dot product of vector v and w | |
template<typename T > | |
vec< T > | cross (const vec< T > &v, const vec< T > &w) |
returns the cross product of vector v and w | |
template<typename T , typename S , typename U > | |
vec< T > | dbl_cross (const vec< T > &a, const vec< S > &b, vec< U > &c) |
returns the double cross product of vector a, b and c a x(b x c) | |
template<typename T , typename S , typename U > | |
T | spat (const vec< T > &a, const vec< S > &b, const vec< U > &c) |
returns the spat product (mixed vector product) of the vectors a, b and c | |
template<typename T > | |
vec< T > | project (const vec< T > &v, const vec< T > &n) |
calculates the projection of v onto n | |
template<typename T > | |
vec< T > | reflect (const vec< T > &v, const vec< T > &n) |
calculates the reflected direction of v; n is the normal of the reflecting surface | |
template<typename T > | |
vec< T > | refract (const vec< T > &v, const vec< T > &n, T c1, T c2, bool *total_reflection=NULL) |
template<typename T > | |
vec< T > | zeros (const unsigned dim) |
create a zero vector | |
template<typename T > | |
vec< T > | ones (const unsigned dim) |
create a one vector | |
template<typename T > | |
vec< T > | floor (const vec< T > &v) |
vector of componentwise floor values | |
template<typename T > | |
vec< T > | ceil (const vec< T > &v) |
vector of componentwise ceil values | |
template<typename T > | |
vec< T > | round (const vec< T > &v) |
vector of componentwise ceil values | |
template<typename T > | |
vec< T > | abs (const vec< T > &v) |
vector of componentwise absolute values | |
template<typename T > | |
T | min_value (const vec< T > &v) |
returns the minimal entry | |
template<typename T > | |
unsigned | min_index (const vec< T > &v) |
returns the index of the smallest value | |
template<typename T > | |
unsigned | max_index (const vec< T > &v) |
return the index of the largest entry | |
template<typename T > | |
T | max_value (const vec< T > &v) |
return the value of the largest entry | |
template<typename T > | |
T | mean_value (const vec< T > &values) |
compute the mean of all values | |
template<typename T > | |
T | var_value (const vec< T > &values) |
template<typename T > | |
T | range_value (const vec< T > &values) |
compute the range of all values | |
template<typename T > | |
T | mad_value (const vec< T > &values) |
compute the median absolut deviation MAD | |
template<typename T > | |
T | std_value (const vec< T > &values) |
template<typename T > | |
void | var_and_mean_value (const vec< T > &values, T &mu, T &var) |
compute the mean and the variance (sigma^2) of all values | |
template<typename T > | |
void | sort_values (vec< T > &values, bool ascending=true) |
sort vector elements in ascending or descending order | |
template<typename T > | |
T | sum_values (const vec< T > &values) |
returns the sum of all entries | |
template<typename T > | |
T | cumsum_values (const vec< T > &values, vec< T > &cumsumvalues) |
template<typename T > | |
T | prod_values (vec< T > &values) |
returns the product of all entries | |
template<typename T > | |
T | select_value (unsigned k, vec< T > &values) |
template<typename T > | |
T | select_median_value (vec< T > &values) |
template<typename T > | |
T | median_value (const vec< T > &values) |
returns median element without modifying the given vector | |
template<typename T > | |
const vec< T > | lin_space (const T &first_val, const T &last_val, unsigned N=10) |
create a linearly spaced vector with N values starting at first_val and ending ant last_val | |
template<typename T > | |
const vec< T > | log_space (const T &first_pow_of_10, const T &last_pow_of_10, unsigned N=10) |
template<typename T > | |
const vec< T > | lerp (const vec< T > &v1, const vec< T > &v2, T t) |
linear interpolation returns (1-t)*v1 + t*v2 | |
template<typename T > | |
const T | lerp (const T &s1, const T &s2, T t) |
linear interpolation returns (1-t)*v1 + t*v2 | |
template<typename T > | |
const vec< T > | slerp (const vec< T > &v0, const vec< T > &v1, T t) |
spherical linear interpolation | |
namespace with classes and algorithms for mathematics
T cgv::math::AIC | ( | int | k, |
const T & | L | ||
) |
Akaike's: An Information Criterion k...number of parameters L...maximized value of likelihood function for estimated model n/k should be > 40 otherwise use AICc (n ... number of samples)
T cgv::math::AIC_ls | ( | int | k, |
int | n, | ||
const T & | RSS | ||
) |
Akaike's: An information criterion for
k...number of parameters n...number of samples RSS...the residual sum of squares n/k should be greater 40 otherwise use AICc
T cgv::math::AICc | ( | int | k, |
int | n, | ||
const T & | L | ||
) |
Akaike's: An information criterion with second order correction term k...number of parameters n.. number of samples L...maximized value of likelihood function for estimated model
T cgv::math::AICc_ls | ( | int | k, |
int | n, | ||
const T & | RSS | ||
) |
Akaike's: An information criterion k...number of parameters n...number of samples RSS...the residual sum of squares
T cgv::math::AICu_ls | ( | int | k, |
int | n, | ||
const T & | RSS | ||
) |
Akaike's: An information criterion k...number of parameters n...number of samples RSS...the residual sum of squares from the estimated model
void cgv::math::align | ( | const std::vector< fvec< T, 3 > > & | source_points, |
const std::vector< fvec< T, 3 > > & | target_points, | ||
fmat< T, 3, 3 > & | O, | ||
fvec< T, 3 > & | t, | ||
T * | scale_ptr = nullptr , |
||
bool | allow_reflection = false |
||
) |
compute rigid body transformation and optionally uniform scaling to align source point set to target point set in least squares sense
Given source points X and target points Y find orthogonal matrix O\in O(3), translation vector t\in R^3 and optionally scale factor s > 0 to minimize
\sum_i ||y_i - (s*O*x_i + t)||^2
Optionally, one can enforce O to be a rotation. Algorithm taken from
Umeyama, Shinji. "Least-squares estimation of transformation parameters between two point patterns." IEEE Transactions on pattern analysis and machine intelligence 13.4 (1991): 376-380.
Second template argument allows to specify a different number type for svd computation
void cgv::math::apply_nonrigid_transformation | ( | const thin_hyper_plate_spline< T > & | s, |
mat< T > & | points | ||
) |
apply thin-hyper-plate-spline deformation in-place (without producing a copy of the points). This method should be used if a large number of points have to be deformed
void cgv::math::apply_nonrigid_transformation | ( | const thin_plate_spline< T > & | s, |
mat< T > & | points | ||
) |
apply thin-plate-spline deformation in-place (without producing a copy of the points). This method should be used if a large number of points have to be deformed
void cgv::math::Atx | ( | const mat< T > & | a, |
const vec< T > & | x, | ||
vec< T > & | atx | ||
) |
multiply A^T*x A is a matrix and x is a vector
T cgv::math::BIC | ( | int | k, |
int | n, | ||
const T & | L | ||
) |
Bayesian information criterion (Schwarz Information Criterion) k...number of parameters n...number of samples
T cgv::math::BIC_ls | ( | int | k, |
int | n, | ||
const T & | RSS | ||
) |
Bayesian information criterion (Schwarz Information Criterion) k...number of parameters n...number of samples RSS...the residual sum of squares from the estimated model
T cgv::math::bipoly_val | ( | const mat< T > & | bp, |
const T & | x1, | ||
const T & | x2 | ||
) |
bivariate polynomials are stored in matrices in the following order: [a,b,c,d a*x1^3*x2^3 + b*x1^2*x2^3 + c*x1*x2^3 + d*x2^3 + e,f,g,h e*x1^3*x2^2 + f*x1^2*x2^2 + g*x1*x2^2 + h*x2^2 + i,j,k,l i*x1^3*x2 + j*x1^2*x2 + k*x1*x2 + l*x2 + m,n,o,p] m*x1^3 + n*x1^2 + o*x1 + p
evaluate a bivariate polynomial p at (x1,x2) p is the coefficients matrix of the bivariate polynomial evaluation is done by using the horner scheme
evaluate a bivariate polynomial p at 2d position x p is the coefficients matrix of the bivariate polynomial evaluation is done by using the horner scheme
cgv::math::fmat<T, 3, 3> cgv::math::build_orthogonal_frame | ( | const cgv::math::fvec< T, 3 > & | v0, |
const cgv::math::fvec< T, 3 > & | v1 | ||
) |
Given two vectors v0 and v1 extend to orthonormal frame and return 3x3 matrix containing frame vectors in the columns.
The implementation has the following assumptions that are not checked:
void cgv::math::compute_rotation_axis_and_angle_from_vector_pair | ( | const cgv::math::fvec< T, 3 > & | v0, |
const cgv::math::fvec< T, 3 > & | v1, | ||
cgv::math::fvec< T, 3 > & | axis, | ||
T & | angle | ||
) |
compute a rotation axis and a rotation angle in radian that rotates v0 onto v1.
An alternative solution is given by the negated axis with negated angle.
|
inline |
creates different type of color map matrices colors are stored as columns in the resulting matrix the number of columns is defined by the parameter steps colormaps can be chosen by name : possible colormaps are "gray" black .. white "bone" grayscale colormap with a higher blue component (looks like xray images) "jet" blue .. cyan .. yellow .. orange .. red "hot" black .. red .. yellow .. white "thermo" black .. magenta .. blue.. cyan..green .. yellow ..red.. white "hsv" red .. yellow .. green .. cyan .. blue .. magenta .. red
T cgv::math::cumsum_values | ( | const vec< T > & | values, |
vec< T > & | cumsumvalues | ||
) |
computes cumulative sums in cumsumvalues cumsumvalues[i] = values[0]+...+values[i-1] returns the sum of all entries
bool cgv::math::decompose_rotation | ( | const cgv::math::mat< T > & | R, |
cgv::math::vec< T > & | axis, | ||
T & | angle | ||
) |
extract axis and angle from rotation matrix returns true if successful problematic cases are angle == 0° and angle == 180°
int cgv::math::decompose_rotation_to_axis_and_angle | ( | const cgv::math::fmat< T, 3, 3 > & | R, |
cgv::math::fvec< T, 3 > & | axis, | ||
T & | angle | ||
) |
decompose a rotation matrix into axis angle representation
The implementation assumes that R is orthonormal and that det(R) = 1, thus no reflections are handled. Negation of axis and angle yield another solution. The function returns three possible status values:
bool cgv::math::eig_sym | ( | const mat< T > & | a, |
mat< T > & | v, | ||
diag_mat< T > & | d, | ||
bool | ordering = true , |
||
unsigned | maxiter = 50 |
||
) |
eigen decomposition of a symmetric matrix using the jacobi method v contains the eigenvectors d contains the eigenvalues a=v*d*transpose(v)
CGV_API void cgv::math::estimate_normal_ls | ( | unsigned | nr_points, |
const float * | _points, | ||
float * | _normal, | ||
float * | _evals = 0 , |
||
float * | _mean = 0 , |
||
float * | _evecs = 0 |
||
) |
Compute least squares normal from an array of 3D points.
Input is the number of points nr_points
and a pointer _points
to the point array. Points are assumed to be float tripples laying consecutively in the memory. Thus a vector P
of type std::vector<cgv::math::fvec<float,3>
> can be passed to this function according to estimate_normal_ls(P.size(), &P.front()[0], ...). The resulting 3D normal is written into the memory point to by _normal
assuming space for 3 floats. If _evals
is specified, also the eigenvalues from the fit are written to 3 floats pointed to by _evals
. If _mean
is specified, also the point mean through which the least squares plane goes is returned. If _evecs
is specified, also the eigenvectors from the fit are written in 3 float trippels to memory pointed to by _evecs
.
void cgv::math::find_nonrigid_transformation | ( | const mat< T > & | points1, |
const mat< T > & | points2, | ||
thin_hyper_plate_spline< T > & | spline | ||
) |
fit thin hyperplate spline to interpolate point correspondences such that for columns i spline.map_position(points1.col(i)) == points2.col(i) points1 and points2 must contain at least 4 3d point correspondences
void cgv::math::find_nonrigid_transformation | ( | const mat< T > & | points1, |
const mat< T > & | points2, | ||
thin_plate_spline< T > & | spline | ||
) |
fit thin plate spline to interpolate point correspondences suc that for columns i spline.map_position(points1.col(i)) == points2.col(i) points1 and points2 must contain at least 3 2d point correspondences
bool cgv::math::gaussj | ( | mat< T > & | a | ) |
inverts a matrix a using gauss jordan elimination returns false if a is singular a is replaced with its inverse
Gauss-Jordan elimination (A*X=B) with full pivoting: The input matrix a is replaced by its inverse and the right hand side matrix b is replaced by ist corresponding solution matrix x. Returns false if the matrix is singular.
cgv::math::vec<T> cgv::math::geometric_median | ( | const cgv::math::mat< T > & | points, |
const T & | eps = 0.0001 , |
||
const unsigned | max_iter = 100 |
||
) |
returns the geometric median of a set of points
kolmogorov-smirnov test for comparing two sampled distributions returns the p-value for the null hypothesis that the the samples data1 are drawn from the same distribution as the samples of data2
const vec<T> cgv::math::log_space | ( | const T & | first_pow_of_10, |
const T & | last_pow_of_10, | ||
unsigned | N = 10 |
||
) |
create a log spaced vector with N values starting at 10^first_pow_of_10 and ending at 10 last_val
bool cgv::math::lu | ( | const mat< T > & | a, |
perm_mat & | p, | ||
low_tri_mat< T > & | l, | ||
up_tri_mat< T > & | u | ||
) |
(P)LU decomposition of a matrix returns false if matrix is singular otherwise a = p*l*u
bool cgv::math::lu_solve | ( | const mat< T > & | a, |
const mat< T > & | b, | ||
mat< T > & | x | ||
) |
solves multiple linear systems ax=b a is full storage matrix x is the matrix of solution vectors (columns) b is the matrix of right-hand sides (columns)
bool cgv::math::lu_solve | ( | const mat< T > & | a, |
const vec< T > & | b, | ||
vec< T > & | x | ||
) |
solve ax=b with lu decomposition a is a full storage matrix
T cgv::math::norm_ks_test | ( | const T | mu, |
const T | sig, | ||
vec< T > | data | ||
) |
kolmogorov-smirnov test for comparing samples with given normal distribution returns the p-value for the null hypothesis that the data is drawn from a normal distribution defined by mu and sigma
unsigned cgv::math::num_ransac_iterations | ( | unsigned | n_min, |
const T | p_out, | ||
const T | p_surety = 0.99 |
||
) |
returns the number of needed ransac iterations n_min... minimal number of needed samples p_out... percentage of inliers p_surety... probability to sample at least one inlier
A plane is defined as a vector (a,b,c,d) => a*x1 + b*x2 +c*x3 +d = 0 evaluate implicit plane equation at x =(x1,x2,x3) return value should be zero on plane
void cgv::math::polar | ( | const mat< T > & | c, |
mat< T > & | r, | ||
mat< T > & | a, | ||
int | num_iter = 15 |
||
) |
polar decomposition of matrix c=r*a r orthonormal matrix a positive semi-definite matrix
bool cgv::math::poly_div | ( | const vec< T > & | f, |
const vec< T > & | g, | ||
vec< T > & | q, | ||
vec< T > & | r | ||
) |
polynomial division f(x)/g(x) = q(x) + r(x)/g(x) returns true if r(x)=0 (rest 0)
T cgv::math::poly_val | ( | const vec< T > & | p, |
const T & | x | ||
) |
polynomials are stored in vectors in the following order: [a,b,c,d] ...a*x^3 + b*x^2 + c*x + d evaluate a polynomial p at x p is the vector of length n+1 whose elements are the coefficients of the polynomial in descending powers. evaluation is done by using the horner scheme
evaluate a polynomial p at multiple positions x p is the vector of length n+1 whose elements are the coefficients of the polynomial in descending powers. evaluation is done by using the horner scheme
bool cgv::math::qr_solve | ( | const mat< T > & | a, |
const mat< T > & | b, | ||
mat< T > & | x | ||
) |
solves multiple linear systems ax=b with qr solver a is full storage matrix x is the matrix of solution vectors (columns) b is the matrix of right-hand sides (columns)
Quaterions are stored in vectors in the following order: [w, x, y, z] -> w + x*i + y*j + z*k
vec<T> cgv::math::ransac_plane_fit | ( | const mat< T > & | points, |
const T | p_out = 0.8 , |
||
const T | d_max = 0.001 , |
||
const T | p_surety = 0.99 , |
||
bool | msac = true |
||
) |
ransac plane fit p_out... outlier prob d_max... threshold distance p_surety... surety to compute number needed samples if m_sac flag is true m-estimator cost function is used if loransac flag is true
vec<T> cgv::math::refract | ( | const vec< T > & | v, |
const vec< T > & | n, | ||
T | c1, | ||
T | c2, | ||
bool * | total_reflection = NULL |
||
) |
calculates the refracted direction of v on a surface with normal n and refraction indices c1,c2, *the optional parameter total reflection will be set true if a total reflection occured otherwise false
cgv::math::fvec<T, 3> cgv::math::rotate | ( | const cgv::math::fvec< T, 3 > & | v, |
const cgv::math::fvec< T, 3 > & | n, | ||
T | a | ||
) |
rotate vector v around axis n by angle a (given in radian)
the cos and sin functions need to be implemented for type T.
T cgv::math::select_median_value | ( | vec< T > & | values | ) |
returns the value of values the input vector arr will be rearanged to have this value in location arr[k], with all smaller elements moved to values[0..k-1] (in arbitrary order) and all larger elements in values[k+1..n] (also in arbitrary order). if the number of components are even then the ceil((n+1)/2) entry is returned
T cgv::math::select_value | ( | unsigned | k, |
vec< T > & | values | ||
) |
returns the kth-smallest value of values the input vector values will be rearranged to have this value in location arr[k], with all smaller elements moved to values[0..k-1] (in arbitrary order) and all larger elements in values[k+1..n] (also in arbitrary order).
bool cgv::math::solve | ( | const diag_mat< T > & | a, |
const mat< T > & | b, | ||
mat< T > & | x | ||
) |
solves multiple linear systems ax=b a is a diagonal matrix x is the matrix of solution vectors (columns) b is the matrix of right-hand sides (columns)
bool cgv::math::solve | ( | const diag_mat< T > & | a, |
const vec< T > & | b, | ||
vec< T > & | x | ||
) |
solves linear system ax=b a is a diagonal matrix
bool cgv::math::solve | ( | const low_tri_mat< T > & | a, |
const mat< T > & | b, | ||
mat< T > & | x | ||
) |
solves multiple linear systems ax=b a is a lower triangular matrix x is the matrix of solution vectors (columns) b is the matrix of right-hand sides (columns)
bool cgv::math::solve | ( | const low_tri_mat< T > & | a, |
const vec< T > & | b, | ||
vec< T > & | x | ||
) |
solves linear system ax=b a is a lower triangular matrix
bool cgv::math::solve | ( | const mat< T > & | a, |
const mat< T > & | b, | ||
mat< T > & | x | ||
) |
solves multiple linear systems ax=b with the svd solver a is full storage matrix x is the matrix of solution vectors (columns) b is the matrix of right-hand sides (columns)
bool cgv::math::solve | ( | const mat< T > & | a, |
const vec< T > & | b, | ||
vec< T > & | x | ||
) |
solve ax=b, standard solver for full storage matrix is lu_solve a is a full storage matrix
bool cgv::math::solve | ( | const perm_mat & | a, |
const mat< T > & | b, | ||
mat< T > & | x | ||
) |
solves multiple linear systems ax=b a is permutation matrix x is the matrix of solution vectors (columns) b is the matrix of right-hand sides (columns)
bool cgv::math::solve | ( | const perm_mat & | a, |
const vec< T > & | b, | ||
vec< T > & | x | ||
) |
solves linear system ax=b a is a permutation matrix
bool cgv::math::solve | ( | const tri_diag_mat< T > & | a, |
const vec< T > & | b, | ||
vec< T > & | x | ||
) |
solves linear system ax=b a is a tri diagonal matrix
bool cgv::math::solve | ( | const up_tri_mat< T > & | a, |
const mat< T > & | b, | ||
mat< T > & | x | ||
) |
solves multiple linear systems ax=b a is an upper triangular matrix x is the matrix of solution vectors (columns) b is the matrix of right-hand sides (columns)
bool cgv::math::solve | ( | const up_tri_mat< T > & | a, |
const vec< T > & | b, | ||
vec< T > & | x | ||
) |
solves linear system ax=b a is an upper triangular matrix
unsigned cgv::math::solve_underdetermined_system | ( | const cgv::math::mat< T > & | A, |
const cgv::math::vec< T > & | b, | ||
cgv::math::vec< T > & | p, | ||
cgv::math::mat< T > & | N | ||
) |
return the rank of m x n matrix A with m < n the solution of the system Ax=b is given as x= p + N *(l_1,...,l_{n-r})^T, r is the rank of A, are the free parameters and N is the nullspace
evaluate implicit sphere equation at x =(x1,x2,x3) returns signed dist
A sphere is defined as a vector (a,b,c,r) => center (a,b,c) and radius r evaluate implicit sphere equation at x =(x1,x2,x3) returns signed dist
vec<T> cgv::math::sphere_val2 | ( | const vec< T > & | sphere, |
const mat< T > & | xs | ||
) |
evaluate implicit sphere equation at x =(x1,x2,x3) returns signed dist
evaluate implicit sphere equation at x =(x1,x2,x3) returns signed squared dist
Implementation of 1d and 2d linear time distance transformation see: "Distance Transforms of Sampled Functions Pedro F. Felzenszwalb and Daniel P. Huttenlocher" for details.
T cgv::math::std_value | ( | const vec< T > & | values | ) |
compute the standard deviation (sigma) of all values, normalization is done by n-1 (unbiased estimator)
bool cgv::math::svd | ( | const mat< T > & | a, |
mat< T > & | u, | ||
diag_mat< T > & | w, | ||
mat< T > & | v, | ||
bool | ordering = true , |
||
int | maxiter = 30 |
||
) |
computes the singular value decomposition of an MxN matrix a = u* w * v^t where u is an MxN matrix, w is a diagonal NxN matrix and v is a NxN square matrix. If the algorithm can't achieve a convergence after 20 iteration false is returned other wise true. The resulting matrices are stored in the parameters u,w,v. Attention: v is returned not v^T ! So to compute the original matrix a from the decomposed matrices you have to multiply u*w*transpose(v). It is possible to store u directly into a to save memory, just put the same reference into a and u. If ordering is true the singular values are sorted in descending order. To ensure that u*w*v^t remains equal to the matrix a the algorithm also exchanges the columns of u and v.
T cgv::math::var_value | ( | const vec< T > & | values | ) |
compute the variance of all values, normalization is done with n-1 (unbiased estimator)