Subversion Repositories gelsvn

Rev

Rev 220 | Rev 357 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 220 Rev 315
Line 29... Line 29...
29
			
29
			
30
			QEM(): A(0), b(0), c(0) {}
30
			QEM(): A(0), b(0), c(0) {}
31
			
31
			
32
			QEM(const CGLA::Vec3d& p0, const CGLA::Vec3d& n0, double w=1.0f):
32
			QEM(const CGLA::Vec3d& p0, const CGLA::Vec3d& n0, double w=1.0f):
33
				A(direct_product(n0,n0) * w), 
33
				A(direct_product(n0,n0) * w), 
34
				b(-n0*dot(n0,p0) * w), 
34
				b(-2*n0*dot(n0,p0) * w), 
35
				c(dot(p0,n0)*dot(p0,n0) * w) {}
35
				c(dot(p0,n0)*dot(p0,n0) * w) {}
36
 
36
 
37
			
37
			
38
			void operator+=(const QEM& q)
38
			void operator+=(const QEM& q)
39
				{
39
				{
Line 42... Line 42...
42
					c += q.c;
42
					c += q.c;
43
				}
43
				}
44
			
44
			
45
			float error(const CGLA::Vec3d& p) const
45
			float error(const CGLA::Vec3d& p) const
46
				{
46
				{
47
					return dot(p,A*p) + 2*dot(b,p)+ c;
47
					return dot(p,A*p) + dot(b,p)+ c;
48
				}
48
				}
49
 
49
 
50
			double determinant() const
50
			double determinant() const
51
				{
51
				{
52
					return CGLA::determinant(A);
52
					return CGLA::determinant(A);
53
				}
53
				}
54
			
54
			
55
			const CGLA::Vec3d grad(const CGLA::Vec3d& _p) const
55
			const CGLA::Vec3d grad(const CGLA::Vec3d& p) const
56
				{
56
				{
57
					CGLA::Vec3d p(_p);
-
 
58
					CGLA::Vec3d g(2*A*p+2*b);
57
					return CGLA::Vec3d(2*A*p+b);
59
					return g;
-
 
60
				}
58
				}
61
			
59
			
62
			CGLA::Vec3d opt_pos(double QEM_thresh = 0.005) const;
60
			CGLA::Vec3d opt_pos(double QEM_thresh = 0.005) const;
63
			
61
			
64
		};
62
		};