Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpImagePoint.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
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 https://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
* 2D point useful for image processing
32
*/
33
34
#include <visp3/core/vpConfig.h>
35
#include <visp3/core/vpImagePoint.h>
36
#include <visp3/core/vpMath.h>
37
#include <visp3/core/vpRect.h>
38
39
#include <limits>
// numeric_limits
40
41
BEGIN_VISP_NAMESPACE
50
bool
vpImagePoint::inRectangle
(
const
vpRect
&rect)
const
51
{
52
return
((this->i <= rect.
getBottom
()) && (this->i >= rect.
getTop
()) && (this->j <= rect.
getRight
()) &&
53
(this->j >= rect.
getLeft
()));
54
}
55
86
vpImagePoint
&
vpImagePoint::operator+=
(
const
vpImagePoint
&ip)
87
{
88
this->i += ip.i;
89
this->j += ip.j;
90
return
*
this
;
91
}
92
122
vpImagePoint
&
vpImagePoint::operator/=
(
double
scale)
123
{
124
this->i /= scale;
125
this->j /= scale;
126
return
*
this
;
127
}
128
134
VISP_EXPORT
bool
operator==
(
const
vpImagePoint
&ip1,
const
vpImagePoint
&ip2)
135
{
136
// --comment: return ip1 dot get_i() eq ip2 dot get_i() and ip1 dot get_j() eq ip2 dot get_j()
137
138
double
i1 = ip1.
get_i
();
139
double
j1 = ip1.
get_j
();
140
double
i2 = ip2.
get_i
();
141
double
j2 = ip2.
get_j
();
142
143
return
((std::fabs(i1 - i2) <= (std::fabs(
vpMath::maximum
(i1, i2)) * std::numeric_limits<double>::epsilon())) &&
144
(std::fabs(j1 - j2) <= (std::fabs(
vpMath::maximum
(j1, j2)) * std::numeric_limits<double>::epsilon())));
145
}
146
152
VISP_EXPORT
bool
operator!=
(
const
vpImagePoint
&ip1,
const
vpImagePoint
&ip2)
153
{
154
// --comment: return ip1 dot get_i() diff ip2 dot get_i() or ip1 dot get_j() diff ip2 dot get_j()
155
double
i1 = ip1.
get_i
();
156
double
j1 = ip1.
get_j
();
157
double
i2 = ip2.
get_i
();
158
double
j2 = ip2.
get_j
();
159
160
return
((std::fabs(i1 - i2) > (std::fabs(
vpMath::maximum
(i1, i2)) * std::numeric_limits<double>::epsilon())) ||
161
(std::fabs(j1 - j2) > (std::fabs(
vpMath::maximum
(j1, j2)) * std::numeric_limits<double>::epsilon())));
162
}
163
169
VISP_EXPORT
vpImagePoint
operator+
(
const
vpImagePoint
&ip1,
const
vpImagePoint
&ip2)
170
{
171
return
(
vpImagePoint
(ip1.
get_i
() + ip2.
get_i
(), ip1.
get_j
() + ip2.
get_j
()));
172
}
173
179
VISP_EXPORT
vpImagePoint
operator+=
(
const
vpImagePoint
&ip1,
const
vpImagePoint
&ip2)
180
{
181
return
(
vpImagePoint
(ip1.
get_i
() + ip2.
get_i
(), ip1.
get_j
() + ip2.
get_j
()));
182
}
183
207
VISP_EXPORT
vpImagePoint
operator+
(
const
vpImagePoint
&ip1,
int
offset)
208
{
209
return
(
vpImagePoint
(ip1.
get_i
() + offset, ip1.
get_j
() + offset));
210
}
211
235
VISP_EXPORT
vpImagePoint
operator+
(
const
vpImagePoint
&ip1,
unsigned
int
offset)
236
{
237
return
(
vpImagePoint
(ip1.
get_i
() + offset, ip1.
get_j
() + offset));
238
}
239
263
VISP_EXPORT
vpImagePoint
operator+
(
const
vpImagePoint
&ip1,
double
offset)
264
{
265
return
(
vpImagePoint
(ip1.
get_i
() + offset, ip1.
get_j
() + offset));
266
}
267
274
VISP_EXPORT
vpImagePoint
operator-
(
const
vpImagePoint
&ip1,
const
vpImagePoint
&ip2)
275
{
276
return
(
vpImagePoint
(ip1.
get_i
() - ip2.
get_i
(), ip1.
get_j
() - ip2.
get_j
()));
277
}
278
302
VISP_EXPORT
vpImagePoint
operator-
(
const
vpImagePoint
&ip1,
int
offset)
303
{
304
return
(
vpImagePoint
(ip1.
get_i
() - offset, ip1.
get_j
() - offset));
305
}
306
330
VISP_EXPORT
vpImagePoint
operator-
(
const
vpImagePoint
&ip1,
unsigned
int
offset)
331
{
332
return
(
vpImagePoint
(ip1.
get_i
() - offset, ip1.
get_j
() - offset));
333
}
334
358
VISP_EXPORT
vpImagePoint
operator-
(
const
vpImagePoint
&ip1,
double
offset)
359
{
360
return
(
vpImagePoint
(ip1.
get_i
() - offset, ip1.
get_j
() - offset));
361
}
362
386
VISP_EXPORT
vpImagePoint
operator*
(
const
vpImagePoint
&ip1,
double
scale)
387
{
388
return
(
vpImagePoint
(ip1.
get_i
() * scale, ip1.
get_j
() * scale));
389
}
390
414
VISP_EXPORT
vpImagePoint
operator/
(
const
vpImagePoint
&ip1,
double
scale)
415
{
416
return
(
vpImagePoint
(ip1.
get_i
() / scale, ip1.
get_j
() / scale));
417
}
418
455
VISP_EXPORT std::ostream &
operator<<
(std::ostream &os,
const
vpImagePoint
&ip)
456
{
457
os << ip.
get_i
() <<
", "
<< ip.
get_j
();
458
return
os;
459
}
460
466
vpRect
vpImagePoint::getBBox
(
const
std::vector<vpImagePoint> &ipVec)
467
{
468
vpRect
rec(ipVec);
469
470
return
rec;
471
}
472
481
double
vpImagePoint::distance
(
const
vpImagePoint
&iP1,
const
vpImagePoint
&iP2)
482
{
483
return
sqrt(
vpMath::sqr
(iP1.
get_i
() - iP2.
get_i
()) +
vpMath::sqr
(iP1.
get_j
() - iP2.
get_j
()));
484
}
485
494
double
vpImagePoint::sqrDistance
(
const
vpImagePoint
&iP1,
const
vpImagePoint
&iP2)
495
{
496
return
vpMath::sqr
(iP1.
get_i
() - iP2.
get_i
()) +
vpMath::sqr
(iP1.
get_j
() - iP2.
get_j
());
497
}
498
END_VISP_NAMESPACE
vpImagePoint::operator!=
friend VISP_EXPORT bool operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2)
Definition
vpImagePoint.cpp:152
vpImagePoint::operator/=
vpImagePoint & operator/=(double scale)
Definition
vpImagePoint.cpp:122
vpImagePoint::get_j
double get_j() const
Definition
vpImagePoint.h:125
vpImagePoint::distance
static double distance(const vpImagePoint &iP1, const vpImagePoint &iP2)
Definition
vpImagePoint.cpp:481
vpImagePoint::operator==
friend VISP_EXPORT bool operator==(const vpImagePoint &ip1, const vpImagePoint &ip2)
Definition
vpImagePoint.cpp:134
vpImagePoint::operator+=
vpImagePoint & operator+=(const vpImagePoint &ip)
Definition
vpImagePoint.cpp:86
vpImagePoint::inRectangle
bool inRectangle(const vpRect &rect) const
Definition
vpImagePoint.cpp:50
vpImagePoint::operator+
friend VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, const vpImagePoint &ip2)
Definition
vpImagePoint.cpp:169
vpImagePoint::getBBox
static vpRect getBBox(const std::vector< vpImagePoint > &ipVec)
Definition
vpImagePoint.cpp:466
vpImagePoint::operator*
friend VISP_EXPORT vpImagePoint operator*(const vpImagePoint &ip1, double scale)
Definition
vpImagePoint.cpp:386
vpImagePoint::operator/
friend VISP_EXPORT vpImagePoint operator/(const vpImagePoint &ip1, double scale)
Definition
vpImagePoint.cpp:414
vpImagePoint::operator<<
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpImagePoint &ip)
Definition
vpImagePoint.cpp:455
vpImagePoint::sqrDistance
static double sqrDistance(const vpImagePoint &iP1, const vpImagePoint &iP2)
Definition
vpImagePoint.cpp:494
vpImagePoint::operator-
friend VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, const vpImagePoint &ip2)
Definition
vpImagePoint.cpp:274
vpImagePoint::vpImagePoint
vpImagePoint()
Definition
vpImagePoint.h:88
vpImagePoint::get_i
double get_i() const
Definition
vpImagePoint.h:114
vpMath::maximum
static Type maximum(const Type &a, const Type &b)
Definition
vpMath.h:257
vpMath::sqr
static double sqr(double x)
Definition
vpMath.h:203
vpRect
Defines a rectangle in the plane.
Definition
vpRect.h:79
vpRect::getLeft
double getLeft() const
Definition
vpRect.h:173
vpRect::getRight
double getRight() const
Definition
vpRect.h:179
vpRect::getBottom
double getBottom() const
Definition
vpRect.h:97
vpRect::getTop
double getTop() const
Definition
vpRect.h:192
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
core
src
image
vpImagePoint.cpp
Generated by
1.17.0