Visual Servoing Platform  version 3.0.0
vpRzyxVector.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 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  * Rzyx angle parameterization for the rotation.
32  * Rzyx(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(x,psi)
33  *
34  * Authors:
35  * Eric Marchand
36  * Fabien Spindler
37  *
38  *****************************************************************************/
39 
40 
41 #include <visp3/core/vpRzyxVector.h>
42 #include <math.h>
52  : vpRotationVector(3)
53 {}
54 
57  : vpRotationVector(rzyx)
58 {}
59 
66 vpRzyxVector::vpRzyxVector(const double phi, const double theta, const double psi)
67  : vpRotationVector (3)
68 {
69  buildFrom(phi, theta, psi);
70 }
71 
78  : vpRotationVector (3)
79 {
80  buildFrom(R) ;
81 }
82 
90  : vpRotationVector (3)
91 {
92  buildFrom(tu) ;
93 }
94 
107 {
108  double nx = R[0][0];
109  double ny = R[1][0];
110 
111  double phi = atan2(ny,nx) ;
112  double si = sin(phi) ;
113  double co = cos(phi) ;
114 
115  double nz = R[2][0];
116  double theta = atan2(-nz, co*nx+si*ny) ;
117 
118  double ax = R[0][2];
119  double ay = R[1][2];
120  double ox = R[0][1];
121  double oy = R[1][1];
122 
123  double psi = atan2(si*ax-co*ay,-si*ox+co*oy);
124 
125  buildFrom(phi, theta, psi);
126 
127  return *this ;
128 }
129 
130 
140 {
141  vpRotationMatrix R ;
142  R.buildFrom(tu) ;
143  buildFrom(R) ;
144 
145  return *this ;
146 }
147 
154 void
155 vpRzyxVector::buildFrom(const double phi, const double theta, const double psi)
156 {
157  data[0] = phi ;
158  data[1] = theta ;
159  data[2] = psi ;
160 }
161 
182 {
183  for (unsigned int i=0; i< dsize; i++)
184  data[i] = v;
185 
186  return *this;
187 }
Implementation of a generic rotation vector.
double * data
Address of the first element of the data array.
Definition: vpArray2D.h:84
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRzyxVector.h:152
Implementation of a rotation matrix and operations on such kind of matrices.
vpRotationMatrix buildFrom(const vpHomogeneousMatrix &M)
vpRzyxVector buildFrom(const vpRotationMatrix &R)
unsigned int dsize
Current array size (rowNum * colNum)
Definition: vpArray2D.h:80
Implementation of a rotation vector as axis-angle minimal representation.
vpRzyxVector & operator=(double x)