-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy patheigen.hpp
98 lines (78 loc) · 3.36 KB
/
eigen.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
Numerical functions for computing minimizers of a least-squares system
of equations.
Copyright (C) 2011 Scott Schaefer
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
(LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EIGEN_H
#define EIGEN_H
#define TOLERANCE 0.0001f
#include "GeoCommon.hpp"
/**
* Uses a jacobi method to return the eigenvectors and eigenvalues
* of a 3x3 symmetric matrix. Note: "a" will be destroyed in this
* process. "d" will contain the eigenvalues sorted in order of
* decreasing modulus and v will contain the corresponding eigenvectors.
*
* @param a the 3x3 symmetric matrix to calculate the eigensystem for
* @param d the variable to hold the eigenvalues
* @param v the variables to hold the eigenvectors
*/
void jacobi ( float a[][3], float d[], float v[][3] );
/**
* Inverts a 3x3 symmetric matrix by computing the pseudo-inverse.
*
* @param mat the matrix to invert
* @param midpoint the point to minimize towards
* @param rvalue the variable to store the pseudo-inverse in
* @param w the place to store the inverse of the eigenvalues
* @param u the place to store the eigenvectors
*/
void matInverse ( float mat[][3], float midpoint[], float rvalue[][3], float w[], float u[][3] );
/**
* Calculates the L2 norm of the residual (the error)
* (Transpose[A].A).x = Transpose[A].B
*
* @param a the matrix Transpose[A].A
* @param b the matrix Transpose[A].B
* @param btb the value Transpose[B].B
* @param point the minimizer found
*
* @return the error of the minimizer
*/
float calcError ( float a[][3], float b[], float btb, float point[] );
/**
* Calculates the normal. This function is not called and doesn't do
* anything right now. It was originally meant to orient the normals
* correctly that came from the principle eigenvector, but we're flat
* shading now.
*/
float *calcNormal ( float halfA[], float norm[], float expectedNorm[] );
/**
* Calculates the minimizer of the given system and returns its error.
*
* @param halfA the compressed form of the symmetric matrix Transpose[A].A
* @param b the matrix Transpose[A].B
* @param btb the value Transpose[B].B
* @param midpoint the point to minimize towards
* @param rvalue the place to store the minimizer
* @param box the volume bounding the voxel this QEF is for
*
* @return the error of the minimizer
*/
float calcPoint ( float halfA[], float b[], float btb, float midpoint[], float rvalue[], BoundingBoxf *box, float *mat );
void qr ( float eqs[][4], int num, float *rvalue );
void qr ( float *mat1, float *mat2, float *rvalue );
void qr ( float eqs[][4], int num = 4, float tol = 0.000001f );
int estimateRank ( float *a );
#endif