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

Revision 1097, 2.1 KB checked in by mattausch, 18 years ago (diff)
Line 
1#ifndef MXQMETRIC2_INCLUDED // -*- C++ -*-
2#define MXQMETRIC2_INCLUDED
3#if !defined(__GNUC__)
4#  pragma once
5#endif
6
7/************************************************************************
8
9  2D Quadric Error Metric
10
11  Copyright (C) 1998 Michael Garland.  See "COPYING.txt" for details.
12
13  $Id: MxQMetric2.h,v 1.1 2002/09/24 16:53:54 wimmer Exp $
14
15 ************************************************************************/
16
17#include "MxMath.h"
18#include "MxMat2.h"
19#include "MxMat3.h"
20
21class MxQuadric2
22{
23private:
24    double a2, ab, ac;
25    double     b2, bc;
26    double         c2;
27
28    double r;
29
30    void init(double a, double b, double c, double len);
31
32public:
33    MxQuadric2() { clear(); }
34    MxQuadric2(double a, double b, double c, double len=1.0)
35        { init(a, b, c, len); }
36    MxQuadric2(const float *n, double c, double len=1.0)
37        { init(n[X], n[Y], c, len); }
38    MxQuadric2(const double *n, double c, double len=1.0)
39        { init(n[X], n[Y], c, len); }
40    MxQuadric2(const MxQuadric2& Q) { *this = Q; }
41
42    Mat2 tensor() const;
43    Vec2 vector() const { return Vec2(ac, bc); }
44    double offset() const { return c2; }
45    double length() const { return r; }
46    Mat3 homogeneous() const;
47
48    void clear(double val=0.0) { a2=ab=ac=b2=bc=c2=r=val; }
49    MxQuadric2& operator=(const MxQuadric2& Q);
50    MxQuadric2& operator+=(const MxQuadric2& Q);
51    MxQuadric2& operator-=(const MxQuadric2& Q);
52    MxQuadric2& operator*=(double s);
53
54    double evaluate(double x, double y) const;
55    double evaluate(const double *v) const { return evaluate(v[X], v[Y]); }
56    double evaluate(const float *v) const { return evaluate(v[X], v[Y]); }
57
58    double operator()(double x, double y) const { return evaluate(x,y); }
59    double operator()(const double *v) const  { return evaluate(v[X], v[Y]); }
60    double operator()(const float *v) const  { return evaluate(v[X], v[Y]); }
61
62    bool optimize(Vec2& v) const;
63    bool optimize(float *x, float *y) const;
64
65    //    bool optimize(Vec2& v, const Vec2& v1, const Vec2& v2) const;
66};
67
68// MXQMETRIC2_INCLUDED
69#endif
Note: See TracBrowser for help on using the repository browser.