/****************************************************************************
*
* Copyright (c) 2006 by JIA Pei, all rights reserved.
* Copyright (c) 2006 by Vision Open: http://www.visionopen.com/
*
* Author: JIA Pei
* Contact: jp4work@gmail.com
* URL: http://www.visionopen.com/members/jiapei.php
* The author administrates Vision Open -- http://www.visionopen.com
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation.
*
* This program 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 General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* This software is partly based on the following open source:
*
* - Boost
* - OpenCV
*
* This software is using IMM Face Database, which can be downloaded from
* http://www2.imm.dtu.dk/~aam/.
*
* M. B. Stegmann, B. K. Ersb{\o}ll, and R. Larsen. FAME - a flexible appearance
* modelling environment. IEEE Trans. on Medical Imaging, 22(10):1319-1331, 2003
*
****************************************************************************/
// $Id: lv_triangle2d.h,v 1.1.1.1 2006-09-03 17:49:04 JIA Pei Exp $
#ifndef __lv_triangle2d__
#define __lv_triangle2d__
#include <vector>
#include "cv.h"
#include "highgui.h"
using namespace std;
class lv_triangle2d
{
public:
// Positions of 3 triangle vertexes
vector<CvPoint2D32f> m_vVertexes;
double m_dD;
lv_triangle2d() {this->m_vVertexes.resize (3); this->m_dD = 0;}
lv_triangle2d(const vector<CvPoint2D32f> &iVertexes)
{
assert (iVertexes.size () == 3);
this->m_vVertexes.clear ();
this->m_vVertexes = iVertexes;
this->m_dD = this->Calc_dD ();
}
lv_triangle2d(const CvMat* iVertexes)
{
assert (iVertexes->cols == 3);
this->m_vVertexes.resize (3);
for (unsigned int i = 0; i < this->m_vVertexes.size (); i++)
{
this->m_vVertexes[i] = CV_MAT_ELEM( *iVertexes, CvPoint2D32f, 0, i );
}
this->m_dD = this->Calc_dD ();
}
~lv_triangle2d() {this->m_vVertexes.clear(); }
double Calc_dD()
{
double x1, x2, x3, y1, y2, y3;
x1 = this->m_vVertexes[0].x;
x2 = this->m_vVertexes[1].x;
x3 = this->m_vVertexes[2].x;
y1 = this->m_vVertexes[0].y;
y2 = this->m_vVertexes[1].y;
y3 = this->m_vVertexes[2].y;
return (+x2*y3-x2*y1-x1*y3-x3*y2+x3*y1+x1*y2);
}
// operators
lv_triangle2d& operator=(const lv_triangle2d &s)
{
this->m_vVertexes = s.m_vVertexes;
this->m_dD = s.m_dD;
return (*this);
}
};
#endif // __lv_triangle2d__