Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testRect.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Test vpRect.
32  *
33  *****************************************************************************/
34 
35 #include <iostream>
36 #include <visp3/core/vpConfig.h>
37 #include <visp3/core/vpRect.h>
38 
39 int main() {
40  vpRect c(10.1, 15.05, 19.63, 7.84);
41  vpRect a(c.getLeft() - 12.456, c.getTop() - 7.75, c.getWidth() + 12.456, c.getHeight() + 7.75);
42  vpRect b(c.getLeft(), c.getTop(), c.getWidth() + 8.81, c.getHeight() + 14.57);
43 
44  vpRect intersect = a & b;
45 
46  std::cout << "Test intersection." << std::endl;
47  std::cout << "a=" << a << std::endl;
48  std::cout << "b=" << b << std::endl;
49  std::cout << "c=" << c << std::endl;
50  std::cout << "intersect=" << intersect << std::endl;
51 
52  if (intersect != c) {
53  std::cerr << "Problem with the intersection function!" << std::endl;
54  return EXIT_FAILURE;
55  }
56 
57  a &= b;
58  std::cout << "a=" << a << std::endl;
59 
60  if (a != c) {
61  std::cerr << "Problem with the intersection function!" << std::endl;
62  return EXIT_FAILURE;
63  }
64 
65  a = vpRect(11.45, 15.67, 3.5, 7.81);
66  b = vpRect(24.78, 31.46, 7.48, 11.28);
67  intersect = a & b;
68 
69  std::cout << "\nTest no intersection." << std::endl;
70  std::cout << "a=" << a << std::endl;
71  std::cout << "b=" << b << std::endl;
72  std::cout << "intersect=" << intersect << std::endl;
73 
74  if (intersect != vpRect()) {
75  std::cerr << "Problem with the intersection function!" << std::endl;
76  return EXIT_FAILURE;
77  }
78 
79  a &= b;
80  std::cout << "a=" << a << std::endl;
81 
82  if (a != vpRect()) {
83  std::cerr << "Problem with the intersection function!" << std::endl;
84  return EXIT_FAILURE;
85  }
86 
87  std::cout << "vpRect is ok." << std::endl;
88  return EXIT_SUCCESS;
89 }
Defines a rectangle in the plane.
Definition: vpRect.h:82