Subversion Repositories gelsvn

Rev

Rev 39 | Rev 220 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 39 Rev 214
1
#include <iostream>
1
#include <iostream>
2
 
2
 
3
#include "QEM.h"
3
#include "QEM.h"
4
#include "LinAlg/LapackFunc.h"
4
#include "LinAlg/LapackFunc.h"
5
 
5
 
6
using namespace LinAlg;
6
using namespace LinAlg;
7
using namespace CGLA;
7
using namespace CGLA;
8
using namespace std;
8
using namespace std;
9
 
9
 
10
namespace Geometry
10
namespace Geometry
11
{
11
{
12
	Vec3f QEM::opt_pos(double sv_thresh) const
12
	Vec3d QEM::opt_pos(double sv_thresh) const
13
	{
13
	{
14
		CMatrix A_num(A);
14
		CMatrix A_num(A);
15
		CVector b_num(b);
15
		CVector b_num(b);
16
 
16
 
17
		CMatrix U;
17
		CMatrix U;
18
		CMatrix V;
18
		CMatrix V;
19
		CVector s;
19
		CVector s;
20
		SVD(A_num,U,s,V);
20
		SVD(A_num,U,s,V);
21
 
21
 
22
// 		double sm = sv_thresh*s[0];
22
// 		double sm = sv_thresh*s[0];
23
// 		for(int i=1;i<3;++i)
23
// 		for(int i=1;i<3;++i)
24
// 			{
24
// 			{
25
// 				if(fabs(s[i])< sm)
25
// 				if(fabs(s[i])< sm)
26
// 					s[i] = 0;
26
// 					s[i] = 0;
27
// 			}
27
// 			}
28
		
28
		
29
		CMatrix A_inv = (V * s) * U;
29
		CMatrix A_inv = (V * s) * U;
30
 
30
 
31
		CVector x(3);
31
		CVector x(3);
32
		x = A_inv * b_num;
32
		x = A_inv * b_num;
33
		Vec3f p(-x[0], -x[1], -x[2]);
33
		Vec3d p(-x[0], -x[1], -x[2]);
34
		if(s[0] == 0)
34
		if(s[0] == 0)
35
			{
35
			{
36
				cout << A << b << s << U << V << endl;
36
				cout << A << b << s << U << V << endl;
37
			}
37
			}
38
			 
-
 
39
 
-
 
40
		return p;
38
		return p;
41
	}
39
	}
42
}
40
}
43
 
41