ViSP
Main Page
Related Pages
Modules
Classes
Examples
All
Classes
Functions
Variables
Enumerations
Enumerator
Friends
Groups
Pages
vpTranslationVector.cpp
1
/****************************************************************************
2
*
3
* $Id: vpTranslationVector.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
* Translation vector.
36
*
37
* Authors:
38
* Eric Marchand
39
* Fabien Spindler
40
*
41
*****************************************************************************/
42
43
44
#include <visp/vpTranslationVector.h>
45
#include <stdio.h>
46
#include <string.h>
47
48
// Exception
49
#include <visp/vpException.h>
50
#include <visp/vpMatrixException.h>
51
52
// Debug trace
53
#include <visp/vpDebug.h>
54
60
61
void
vpTranslationVector::init()
62
{
63
resize
(3) ;
64
}
65
72
vpTranslationVector::vpTranslationVector
(
const
double
tx,
73
const
double
ty,
74
const
double
tz)
75
{
76
init() ;
77
(*this)[0] = tx ;
78
(*this)[1] = ty ;
79
(*this)[2] = tz ;
80
}
81
94
vpTranslationVector::vpTranslationVector
(
const
vpTranslationVector
&t) :
vpColVector
(t)
95
{
96
}
97
104
void
105
vpTranslationVector::set
(
const
double
tx,
106
const
double
ty,
107
const
double
tz)
108
{
109
(*this)[0] = tx ;
110
(*this)[1] = ty ;
111
(*this)[2] = tz ;
112
}
113
131
vpTranslationVector
132
vpTranslationVector::operator+
(
const
vpTranslationVector
&t)
const
133
{
134
vpTranslationVector
sum ;
135
136
for
(
unsigned
int
i=0;i<3;i++) sum[i] = (*
this
)[i]+t[i] ;
137
138
return
sum;
139
}
140
158
vpTranslationVector
159
vpTranslationVector::operator-
(
const
vpTranslationVector
&t)
const
160
{
161
vpTranslationVector
sub ;
162
163
for
(
unsigned
int
i=0;i<3;i++) sub[i] = (*
this
)[i]-t[i] ;
164
165
return
sub;
166
}
167
168
183
vpTranslationVector
vpTranslationVector::operator-
() const
//negate
184
{
185
vpTranslationVector
t
;
186
for
(
unsigned
int
i=0;i<
dsize
;i++)
187
{
188
*(t.
data
+ i) = -*(
data
+ i) ;
189
}
190
191
return
t
;
192
}
193
209
vpTranslationVector
vpTranslationVector::operator*
(
const
double
x)
const
210
{
211
vpTranslationVector
t
;
212
for
(
unsigned
int
i=0;i<
dsize
;i++)
213
{
214
*(t.
data
+ i) = (*(
data
+ i)) * x ;
215
}
216
217
return
t
;
218
}
219
233
vpTranslationVector
&
vpTranslationVector::operator=
(
const
vpTranslationVector
&t)
234
{
235
236
unsigned
int
k = t.
rowNum
;
237
if
(
rowNum
!= k){
238
try
{
239
resize
(k);
240
}
241
catch
(
vpException
me)
242
{
243
vpERROR_TRACE
(
"Error caught"
) ;
244
throw ;
245
}
246
}
247
248
memcpy(
data
, t.
data
,
rowNum
*
sizeof
(
double
)) ;
249
250
return
*
this
;
251
}
252
264
vpTranslationVector
&
vpTranslationVector::operator=
(
double
x)
265
{
266
267
double
*d =
data
;
268
269
for
(
int
i=0;i<3;i++)
270
*(d++)= x ;
271
272
return
*
this
;
273
}
274
295
void
296
vpTranslationVector::skew
(
const
vpTranslationVector
&t,
vpMatrix
&M)
297
{
298
M.
resize
(3,3) ;
299
M[0][0] = 0 ; M[0][1] = -t[2] ; M[0][2] = t[1] ;
300
M[1][0] = t[2] ; M[1][1] = 0 ; M[1][2] = -t[0] ;
301
M[2][0] = -t[1] ; M[2][1] = t[0] ; M[2][2] = 0 ;
302
}
303
324
vpMatrix
325
vpTranslationVector::skew
(
const
vpTranslationVector
&t)
326
{
327
vpMatrix
M(3, 3);
328
skew
(t,M);
329
return
M;
330
}
331
350
vpMatrix
351
vpTranslationVector::skew
()
const
352
{
353
vpMatrix
M(3, 3);
354
skew
(*
this
,M);
355
return
M;
356
}
357
358
368
vpTranslationVector
369
vpTranslationVector::cross
(
const
vpTranslationVector
&a,
370
const
vpTranslationVector
&b)
371
{
372
vpMatrix
skew_a =
vpTranslationVector::skew
(a) ;
373
return
(
vpTranslationVector
)(skew_a * b);
374
}
375
376
/*
377
* Local variables:
378
* c-basic-offset: 4
379
* End:
380
*/
src
math
transformation
vpTranslationVector.cpp
Generated on Wed Jun 12 2013 05:39:46 for ViSP by
1.8.1.2