source: GTP/trunk/Lib/Vis/Preprocessing/src/mixkit/MxQMetric.h @ 1097

Revision 1097, 1.7 KB checked in by mattausch, 18 years ago (diff)
Line 
1#ifndef MXQMETRIC_INCLUDED // -*- C++ -*-
2#define MXQMETRIC_INCLUDED
3#if !defined(__GNUC__)
4#  pragma once
5#endif
6
7/************************************************************************
8
9  n-D Quadric Error Metric
10
11  Copyright (C) 1998 Michael Garland.  See "COPYING.txt" for details.
12 
13  $Id: MxQMetric.h,v 1.1 2002/09/24 16:53:54 wimmer Exp $
14
15 ************************************************************************/
16
17#include "MxQMetric3.h"
18#include "MxVector.h"
19#include "MxMatrix.h"
20
21class MxQuadric
22{
23private:
24    MxMatrix A;
25    MxVector b;
26    double c;
27
28    double r;
29
30public:
31    MxQuadric(unsigned int N) : A(N), b(N) { clear(); }
32    MxQuadric(const MxVector& p1, const MxVector& p2, const MxVector& p3,
33              double area=1.0);
34    MxQuadric(const MxQuadric3&, unsigned int N);
35    MxQuadric(const MxQuadric& Q)
36        : A(Q.A.dim()), b(Q.b.dim()) { *this = Q; }
37
38    const MxMatrix& tensor() const { return A; }
39    const MxVector& vector() const { return b; }
40    double offset() const { return c; }
41    double area() const { return r; }
42    MxMatrix& homogeneous(MxMatrix& H) const;
43
44    void clear(double val=0.0) { A=val; b=val; c=val; r=val; }
45    MxQuadric& operator=(const MxQuadric& Q)
46        { A=Q.A; b=Q.b; c=Q.c; r=Q.r; return *this; }
47    MxQuadric& operator+=(const MxQuadric& Q)
48        { A+=Q.A; b+=Q.b; c+=Q.c; r+=Q.r; return *this; }
49    MxQuadric& operator-=(const MxQuadric& Q)
50        { A-=Q.A; b-=Q.b; c-=Q.c; r-=Q.r; return *this; }
51    MxQuadric& operator*=(double s)
52        { A*=s; b*=s; c*=s; return *this; }
53
54    double evaluate(const MxVector& v) const;
55    double operator()(const MxVector& v) const { return evaluate(v); }
56
57    bool optimize(MxVector& v) const;
58};
59
60// MXQMETRIC_INCLUDED
61#endif
Note: See TracBrowser for help on using the repository browser.