qem.h 16.2 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
/*******************************************************************************
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
 * version 0.1                                                                  *
 * Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
 *                                                                              *
 * This library is free software; you can redistribute it and/or modify it      *
 * under the terms of the GNU Lesser General Public License 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
 *                                                                              *
 * Web site: http://cgogn.unistra.fr/                                           *
 * Contact information: cgogn@unistra.fr                                        *
 *                                                                              *
 *******************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
24

25
/*! \file qem.h
26
27
28
* Header file for Quadric Error Metric classes.
*/

Pierre Kraemer's avatar
Pierre Kraemer committed
29
30
31
#ifndef __QEM__
#define __QEM__

32
#include "Utils/os_spec.h" // allow compilation under windows
33
#include <cmath>
34

Pierre Kraemer's avatar
Pierre Kraemer committed
35
36
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
37
#include "Geometry/tensor.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
38
39
#include "Geometry/plane_3d.h"

40
41
// Eigen includes
#include <Eigen/Dense>
42

43
44
45
/*! \namespace CGoGN
 * \brief namespace for all elements composing the CGoGN library
 */
46
47
namespace CGoGN {

48
49
50
/*! \namespace Utils
 * \brief namespace for tool classes used by CGoGN and its applications
 */
51
namespace Utils {
52

53
54
55
56
57
/*! \class Quadric
 *
 * \brief Quadric for computing the quadric error metric (QEM)
 * introduced by Garland and Heckbert in 1997.
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
58
59
60
61
template <typename REAL>
class Quadric
{
public:
62
	/**
63
64
	 * \brief get CGoGN name of current type
	 *
65
66
67
68
69
70
	 * \return name of the CGoGN type
	 */
	static std::string CGoGNnameOfType()
	{
		return "Quadric" ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
71

72
73
74
	typedef Geom::Vector<3,REAL> VEC3 ;
	typedef Geom::Vector<4,REAL> VEC4 ;
	typedef Geom::Matrix<4,4,double> MATRIX44 ; // double is crucial here !
Pierre Kraemer's avatar
Pierre Kraemer committed
75

76
77
78
	/*!
	 * \brief Default constructor
	 *
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
79
	 * Initializes empty members.
80
	 */
81
	Quadric() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
82

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
83
84
85
86
87
88
	/*!
	 * \brief Constructor
	 *
	 * Initializes empty members (idem. default constructor).
	 * Exists for compatibility reasons.
	 */
89
	Quadric(int i) ;
90
91

	/*!
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
92
	 * \brief Constructor building a quadric given three points (defining a plane);.
93
94
95
96
97
	 *
	 * \param p1 first point
	 * \param p2 second point
	 * \param p3 third point
	 */
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
98
	Quadric(const VEC3& p1, const VEC3& p2, const VEC3& p3) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
99

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
100
101
102
103
104
	/*!
	 * \brief destructor
	 */
	~Quadric() {} ;

105
106
107
	/*!
	 * \brief set members to zero
	 */
108
	void zero() ;
109

110
111
112
113
114
	/*!
	 * \brief affectation operator (by copy)
	 *
	 * \param q the Quadric to copy
	 */
115
	void operator= (const Quadric<REAL>& q) ;
116
117
118
119
120
121

	/*!
	 * \brief sum of Quadric operator
	 *
	 * \param q the Quadric to sum
	 */
122
	Quadric& operator+= (const Quadric<REAL>& q) ;
123
124
125
126
127
128

	/*!
	 * \brief substract of Quadric operator
	 *
	 * \param q the Quadric to substract
	 */
129
	Quadric& operator -= (const Quadric<REAL>& q) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
130

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
	/*!
	 * \brief scalar product operator
	 *
	 * \param v the scalar to multiply the Quadric with
	 */
	Quadric& operator *= (const REAL& v) ;

	/*!
	 * \brief scalar division operator
	 *
	 * \param v the scalar to divide the Quadric with
	 */
	Quadric& operator /= (const REAL& v) ;

	/*!
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
146
	 * \brief error evaluation operator
147
148
149
150
151
	 *
	 * \param v a point expressed in homogeneous coordinates in space
	 *
	 * \return the error
	 */
152
	REAL operator() (const VEC4& v) const ;
153
154

	/*!
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
155
	 * \brief error evaluation operator
156
157
158
159
160
	 *
	 * \param v a point in space
	 *
	 * \param the error
	 */
161
	REAL operator() (const VEC3& v) const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
162

163
164
165
166
167
168
169
170
	/*!
	 * \brief Write to stream operator
	 *
	 * \param out the stream to write to
	 * \param q the Quadric to write in the stream
	 *
	 * \return the stream reference
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
171
172
173
174
	friend std::ostream& operator<<(std::ostream& out, const Quadric<REAL>& q)
	{
		out << q.A ;
		return out ;
175
	} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
176

177
178
179
180
181
182
183
184
	/*!
	 * \brief Read from stream operator
	 *
	 * \param int the stream to read from
	 * \param q the Quadric to write the data that has been read in
	 *
	 * \return the stream reference
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
185
186
187
188
	friend std::istream& operator>>(std::istream& in, Quadric<REAL>& q)
	{
		in >> q.A ;
		return in ;
189
	} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
190

191
192
193
194
195
196
197
	/*!
	 * \brief Method to deduce a position in space that minimizes the error
	 *
	 * \param v the ideal position (if it can be computed)
	 *
	 * \return true if the ideal position has been computed correctly
	 */
198
	bool findOptimizedPos(VEC3& v) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
199
200

private:
201
202
203
204
205
206
207
208
209
	MATRIX44 A ; /*!< The Quadric matrix */

	/*!
	 * \brief method to evaluate the error at a given point in space (homogeneous coordinates)
	 *
	 * \param v the given point
	 *
	 * \return the error
	 */
210
	REAL evaluate(const VEC4& v) const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
211

212
213
214
215
216
217
218
219
	/*!
	 * \brief method to deduce an optimal position in space (homogeneous coordinates)
	 * w.r.t. the current Quadric.
	 *
	 * \param v will contain the optimal position (if it can be computed)
	 *
	 * \return true if an optimal position was correctly computed
	 */
220
	bool optimize(VEC4& v) const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
221
222
} ;

223
224
225
226
227
228
/*! \class QuadricNd
 * \brief extension of Quadric (which is 3D) to nD points.
 * This was published by Garland and Heckbert in 1998 and is meant to define a quadric
 * for a nD-space which contains geometry (3D) + other attributes like color (3D),
 * normals (3D) or texture coordinates (2D) for instance.
 */
229
230
231
232
template <typename REAL, unsigned int N>
class QuadricNd
{
public:
233
234
235
236
237
	/**
	 * \brief get CGoGN name of current type
	 *
	 * \return name of the CGoGN type
	 */
238
239
240
241
	static std::string CGoGNnameOfType()
	{
		return "QuadricNd" ;
	}
242
243
244
245

	typedef Geom::Vector<N,REAL> VECN ;
	typedef Geom::Vector<N+1,REAL> VECNp ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
246
247
248
249
250
	/*!
	 * \brief Default constructor
	 *
	 * Initializes empty members.
	 */
251
	QuadricNd() ;
252

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
253
254
255
256
257
258
	/*!
	 * \brief Constructor
	 *
	 * Initializes empty members (idem. default constructor).
	 * Exists for compatibility reasons.
	 */
259
	QuadricNd(int i) ;
260

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
261
262
263
264
265
266
267
	/*!
	 * \brief Constructor building a quadricNd given three points (defining a plane);
	 *
	 * \param p1 first point
	 * \param p2 second point
	 * \param p3 third point
	 */
268
	QuadricNd(const VECN& p1_r, const VECN& p2_r, const VECN& p3_r) ;
269

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
270
271
272
273
274
275
276
277
	/*!
	 * \brief destructor
	 */
	~QuadricNd() {} ;

	/*!
	 * \brief set members to zero
	 */
278
	void zero() ;
279

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
280
281
282
	/*!
	 * \brief affectation operator (by copy)
	 *
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
283
	 * \param q the QuadricNd to copy
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
284
	 */
285
	void operator= (const QuadricNd<REAL,N>& q) ;
286

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
287
	/*!
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
288
	 * \brief sum of QuadricNd operator
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
289
	 *
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
290
	 * \param q the QuadricNd to sum
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
291
	 */
292
	QuadricNd& operator+= (const QuadricNd<REAL,N>& q) ;
293

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
294
	/*!
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
295
	 * \brief substract of QuadricNd operator
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
296
	 *
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
297
	 * \param q the QuadricNd to substract
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
298
	 */
299
	QuadricNd& operator -= (const QuadricNd<REAL,N>& q) ;
300

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
301
302
303
	/*!
	 * \brief scalar product operator
	 *
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
304
	 * \param v the scalar to multiply the QuadricNd with
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
305
	 */
306
	QuadricNd& operator *= (REAL v) ;
307

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
308
309
310
311
312
	/*!
	 * \brief scalar division operator
	 *
	 * \param v the scalar to divide the QuadricNd with
	 */
313
	QuadricNd& operator /= (REAL v) ;
314

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
315
316
317
318
319
320
321
	/*!
	 * \brief error evaluation operator
	 *
	 * \param v a point expressed in homogeneous coordinates in nD space
	 *
	 * \return the error
	 */
322
	REAL operator() (const VECNp& v) const ;
323

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
324
325
326
327
328
329
330
	/*!
	 * \brief error evaluation operator
	 *
	 * \param v a point in nD space
	 *
	 * \param the error
	 */
331
	REAL operator() (const VECN& v) const ;
332

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
333
334
335
336
337
338
339
340
	/*!
	 * \brief Write to stream operator
	 *
	 * \param out the stream to write to
	 * \param q the QuadricNd to write in the stream
	 *
	 * \return the stream reference
	 */
341
342
	friend std::ostream& operator<<(std::ostream& out, const QuadricNd<REAL,N>& q)
	{
343
		out << "(" << q.A << ", " << q.b << ", " << q.c << ")" ;
344
		return out ;
345
	} ;
346

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
347
348
349
350
351
352
353
354
	/*!
	 * \brief Read from stream operator
	 *
	 * \param int the stream to read from
	 * \param q the QuadricNd to write the data that has been read in
	 *
	 * \return the stream reference
	 */
355
356
	friend std::istream& operator>>(std::istream& in, QuadricNd<REAL,N>& q)
	{
357
358
359
		in >> q.A ;
		in >> q.b ;
		in >> q.c ;
360
		return in ;
361
	} ;
362

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
363
364
365
366
367
368
369
	/*!
	 * \brief Method to deduce a position in space that minimizes the error
	 *
	 * \param v the ideal position (if it can be computed)
	 *
	 * \return true if the ideal position has been computed correctly
	 */
370
	bool findOptimizedVec(VECN& v) ;
371
372

private:
373
	// Double computation is crucial for stability
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
374
375
376
	Geom::Matrix<N,N,double> A ; /*!< The first QuadricNd member matrix A */
	Geom::Vector<N,double> b ; /*!< The second QuadricNd member vector b */
	double c ;/*!< The third QuadricNd member scalar c */
377

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
378
379
380
381
382
383
384
	/*!
	 * \brief method to evaluate the error at a given nD point in space (homogeneous coordinates)
	 *
	 * \param v the given point
	 *
	 * \return the error
	 */
385
	REAL evaluate(const VECN& v) const ;
386

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
387
388
389
390
391
392
393
394
	/*!
	 * \brief method to deduce an optimal position in space (homogeneous coordinates)
	 * w.r.t. the current QuadricNd.
	 *
	 * \param v will contain the optimal position (if it can be computed)
	 *
	 * \return true if an optimal position was correctly computed
	 */
395
	bool optimize(VECN& v) const ;
396
397
} ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
398
/*! \class QuadricHF
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
399
 * \brief quadric used for measuring a lightfield metric.
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
400
401
402
 * This was defined by Vanhoey, Sauvage and Dischler in 2012.
 * This implementation works only for polynomial basis functions.
 */
403
404
405
406
template <typename REAL>
class QuadricHF
{
public:
407
408
409
410
411
	/**
	 * \brief get CGoGN name of current type
	 *
	 * \return name of the CGoGN type
	 */
412
413
	static std::string CGoGNnameOfType() { return "QuadricHF" ; }

414
	typedef Geom::Vector<3,REAL> VEC3 ;
415

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
416
417
418
419
420
	/*!
	 * \brief Constructor
	 *
	 * Initializes empty members
	 */
421
	QuadricHF() ;
422

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
423
424
425
426
427
428
	/*!
	 * \brief Constructor
	 *
	 * Initializes empty members (idem. default constructor)
	 * Exists for compatibility reasons
	 */
429
	QuadricHF(int i) ;
430

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
431
	/*!
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
432
	 * \brief Constructor building a QuadricHF given a lightfield function and the two angles gamma and alpha
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
433
434
435
436
437
	 *
	 * \param v the lightfield function
	 * \param gamma
	 * \param alpha
	 */
438
	QuadricHF(const std::vector<VEC3>& v, const REAL& gamma, const REAL& alpha) ;
439

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
440
	/*!
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
441
	 * \brief Constructor building a QuadricHF given a lightfield function and the two angles gamma and alpha
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
442
443
444
445
446
	 *
	 * \param v the lightfield function expressed as a Geom::Tensor
	 * \param gamma
	 * \param alpha
	 */
447
	QuadricHF(const Geom::Tensor3d* T, const REAL& gamma, const REAL& alpha) ;
448

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
449
450
451
	/*!
	 * Destructor
	 */
452
	~QuadricHF() ;
453

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
454
455
456
	/*!
	 * \brief set members to zero
	 */
457
458
	void zero() ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
459
460
461
462
463
	/*!
	 * \brief affectation operator (by copy)
	 *
	 * \param q the QuadricHF to copy
	 */
464
465
	QuadricHF& operator= (const QuadricHF<REAL>& q) ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
466
467
468
469
470
	/*!
	 * \brief sum of QuadricHF operator
	 *
	 * \param q the QuadricHF to sum
	 */
471
	QuadricHF& operator+= (const QuadricHF<REAL>& q) ;
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
472
473

	/*!
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
474
	 * \brief substract of QuadricHF operator
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
475
476
477
	 *
	 * \param q the QuadricHF to substract
	 */
478
479
	QuadricHF& operator -= (const QuadricHF<REAL>& q) ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
480
481
482
483
484
	/*!
	 * \brief scalar product operator
	 *
	 * \param v the scalar to multiply the QuadricHF with
	 */
485
486
	QuadricHF& operator *= (const REAL& v) ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
487
488
489
490
491
	/*!
	 * \brief scalar division operator
	 *
	 * \param v the scalar to divide the QuadricHF with
	 */
492
493
	QuadricHF& operator /= (const REAL& v) ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
494
495
496
497
498
499
500
	/*!
	 * \brief error evaluation operator
	 *
	 * \param coefs a lightfield function
	 *
	 * \param the error
	 */
501
	REAL operator() (const std::vector<VEC3>& coefs) const ;
502

503
504
505
506
507
508
509
510
511
512

	/*!
	 * \brief method to evaluate the error for a given lightfield function
	 *
	 * \param coefs the given function
	 *
	 * \return the squared error per color channel
	 */
	VEC3 evalR3(const std::vector<VEC3>& coefs) const ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
513
514
515
516
	/*!
	 * \brief Write to stream operator
	 *
	 * \param out the stream to write to
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
517
	 * \param q the QuadricHF to write in the stream
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
518
519
520
	 *
	 * \return the stream reference
	 */
521
522
	friend std::ostream& operator<<(std::ostream& out, const QuadricHF<REAL>& q)
	{
523
        out << "(" << q.m_A << ", " << q.m_b << ", " << q.m_c << ")" ;
524
		return out ;
525
    }
526

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
527
528
529
530
531
532
533
534
	/*!
	 * \brief Read from stream operator
	 *
	 * \param int the stream to read from
	 * \param q the QuadricHF to write the data that has been read in
	 *
	 * \return the stream reference
	 */
Sylvain Thery's avatar
Sylvain Thery committed
535
	friend std::istream& operator>>(std::istream& in, QuadricHF<REAL>& /*q*/)
536
	{
537
		// TODO
538
539
540
		//		in >> q.A ;
		//		in >> q.b ;
		//		in >> q.c ;
541
		return in ;
542
	} ;
543

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
544
545
546
547
548
549
550
	/*!
	 * \brief Method to deduce a position in space that minimizes the error
	 *
	 * \param v the ideal position (if it can be computed)
	 *
	 * \return true if the ideal position has been computed correctly
	 */
551
	bool findOptimizedCoefs(std::vector<VEC3>& coefs) ;
552

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
	/*!
	 * \brief method to convert a lightfield in tensor format to a coefficient vector format
	 *
	 * \param coefs vector of coefficients representing a lightfield function
	 *
	 * \return a tensor representing the same lightfield function
	 *
	 */
	static Geom::Tensor3d* tensorsFromCoefs(const std::vector<VEC3>& coefs) ;

	/*!
	 * \brief method to convert a lightfield in coefficient vector format to a tensor format
	 *
	 * \param T the tensor to convert
	 *
	 * \return a vector of coefficients representing the same lightfield function
	 */
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
570
	static std::vector<VEC3> coefsFromTensors(Geom::Tensor3d* T) ;
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
571
572

	/*!
573
574
	 * \brief method to complete a symmetric matrix that was
	 * only filled in its first half (line >= column)
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
575
	 *
576
	 * \param M the matrix to fill
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
577
	 */
578
579
580
581
582
583
584
585
586
587
588
	static void fillSymmetricMatrix(Eigen::MatrixXd& M) ;

	/*!
	 * \brief method to rotate a tensor representing a polynomial light field
	 *
	 * \param T the tensor representing a polynomial light field
	 * \param R the 3x3 matrix representing a rotation in (u,v,1)-space
	 *
	 * \return a new rotated tensor representing a polynomial light field.
	 */
	static Geom::Tensor3d rotate(const Geom::Tensor3d& T, const Geom::Matrix33d& R) ;
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
589

590
591
private:
	// Double computation is crucial for stability
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
592
593
594
	Eigen::MatrixXd m_A ; /*!< The first QuadricHF member matrix A */
	Eigen::VectorXd m_b[3] ; /*!< The second QuadricHF member vector b */
	double m_c[3] ; /*!< The third QuadricHF member scalar c */
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
595
596
	std::vector<VEC3> m_coefs ; /*!< The coefficients in cas optim fails */
	bool m_noAlphaRot ; /*!< If alpha = 0 then optim will fail */
597

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
598
599
600
601
602
	/*!
	 * \brief method to evaluate the error for a given lightfield function
	 *
	 * \param coefs the given function
	 *
603
	 * \return the norm of the squared error per color channel
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
604
	 */
605
	REAL evaluate(const std::vector<VEC3>& coefs) const ;
606

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
	/*!
	 * \brief method to build a rotate matrix (rotation in tangent plane)
	 * given angle gamma
	 *
	 * \param gamma the rotation angle
	 *
	 * \return the rotation matrix
	 */
	Geom::Matrix33d buildRotateMatrix(const REAL& gamma) ;

	/*!
	 * \brief method to build the first integral matrix A
	 * given angle alpha
	 *
	 * \param alpha angle
	 * \param size the amount of monomes in a function
	 *
	 * \return the integral of product of monomes
	 */
626
	Eigen::MatrixXd buildIntegralMatrix_A(const REAL& alpha, unsigned int size) ;
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
627
628
629
630
631
632
633
634
635
636

	/*!
	 * \brief method to build the first integral matrix B
	 * given angle alpha
	 *
	 * \param alpha angle
	 * * \param size the amount of monomes in a function
	 *
	 * \return the integral of product of monomes
	 */
637
	Eigen::MatrixXd buildIntegralMatrix_B(const REAL& alpha, unsigned int size) ;
638

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
639
640
641
642
643
644
645
646
647
	/*!
	 * \brief method to build the third integral matrix C
	 * given angle alpha
	 *
	 * \param alpha angle
	 * \param size the amount of monomes in a function
	 *
	 * \return the integral of product of monomes
	 */
648
	Eigen::MatrixXd buildIntegralMatrix_C(const REAL& alpha, unsigned int size) ;
649
650
651

	Eigen::MatrixXd buildLowerLeftIntegralMatrix_A(const REAL& alpha, unsigned int size) ;
	Eigen::MatrixXd buildLowerLeftIntegralMatrix_C(const REAL& alpha, unsigned int size) ;
652
653
} ;

654
} // Utils
655
656
657

} // CGOGN

658
#include "Utils/qem.hpp"
659

Pierre Kraemer's avatar
Pierre Kraemer committed
660
#endif