ViSP  2.8.0
vpImagePoint.cpp
1 /****************************************************************************
2  *
3  * $Id: vpImagePoint.cpp 4056 2013-01-05 13:04:42Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * 2D point useful for image processing
36  *
37  * Authors:
38  * Nicolas Melchior
39  * Fabien Spindler
40  *
41  *****************************************************************************/
42 
43 
44 #include <visp/vpConfig.h>
45 #include <visp/vpImagePoint.h>
46 #include <visp/vpRect.h>
47 #include <visp/vpHomography.h>
48 
58 bool vpImagePoint::inRectangle( const vpRect &rect ) const
59 {
60  return ( this->i <= rect.getBottom() &&
61  this->i >= rect.getTop() &&
62  this->j <= rect.getRight() &&
63  this->j >= rect.getLeft());
64 }
65 
75 {
76  vpImagePoint ap;
77 
78  double i_a = aHb[0][0] * i + aHb[0][1] * j + aHb[0][2];
79  double j_a = aHb[1][0] * i + aHb[1][1] * j + aHb[1][2];
80  double k_a = aHb[2][0] * i + aHb[2][1] * j + aHb[2][2];
81 
82  if(std::fabs(k_a) > std::numeric_limits<double>::epsilon()){
83  ap.set_i(i_a / k_a);
84  ap.set_j(j_a / k_a);
85  }
86 
87  return ap;
88 }
void set_j(const double j)
Definition: vpImagePoint.h:156
double getTop() const
Definition: vpRect.h:169
bool inRectangle(const vpRect &rect) const
void set_i(const double i)
Definition: vpImagePoint.h:145
double getRight() const
Definition: vpRect.h:162
This class aims to compute the homography wrt.two images.
Definition: vpHomography.h:173
double getBottom() const
Definition: vpRect.h:98
vpImagePoint projection(const vpHomography &aHb)
Defines a rectangle in the plane.
Definition: vpRect.h:82
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92
double getLeft() const
Definition: vpRect.h:156