Visual Servoing Platform  version 3.0.0
vpRzyzVector.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  * Euler angles parameterization for the rotation.
32  * Rzyz(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(z,psi)
33  *
34  * Authors:
35  * Eric Marchand
36  * Fabien Spindler
37  *
38  *****************************************************************************/
39 
40 
41 #include <visp3/core/vpRzyzVector.h>
42 #include <math.h>
43 
52  : vpRotationVector (3)
53 {}
56  : vpRotationVector(rzyz)
57 {}
58 
65 vpRzyzVector::vpRzyzVector(const double phi, const double theta, const double psi)
66  : vpRotationVector (3)
67 {
68  buildFrom(phi, theta, psi);
69 }
70 
77  : vpRotationVector (3)
78 {
79  buildFrom(R) ;
80 }
81 
89  : vpRotationVector (3)
90 {
91  buildFrom(tu) ;
92 }
93 
103 {
104  double phi ;
105  if ((fabs(R[1][2]) < 1e-6) &&(fabs(R[0][2]) < 1e-6))
106  phi = 0 ;
107  else
108  phi = atan2(R[1][2],R[0][2]) ;
109  double cphi = cos(phi) ;
110  double sphi = sin(phi) ;
111 
112  double theta = atan2(cphi*R[0][2]+sphi*R[1][2],R[2][2]);
113 
114  double psi = atan2(-sphi*R[0][0]+cphi*R[1][0],-sphi*R[0][1]+cphi*R[1][1]) ;
115 
116  buildFrom(phi, theta, psi);
117 
118  return *this ;
119 }
120 
121 
131 {
132  vpRotationMatrix R ;
133  R.buildFrom(tu) ;
134  buildFrom(R) ;
135 
136  return *this ;
137 }
138 
159 {
160  for (unsigned int i=0; i< dsize; i++)
161  data[i] = v;
162 
163  return *this;
164 }
165 
172 void
173 vpRzyzVector::buildFrom(const double phi, const double theta, const double psi)
174 {
175  data[0] = phi ;
176  data[1] = theta ;
177  data[2] = psi ;
178 }
Implementation of a generic rotation vector.
vpRzyzVector buildFrom(const vpRotationMatrix &R)
double * data
Address of the first element of the data array.
Definition: vpArray2D.h:84
Implementation of a rotation matrix and operations on such kind of matrices.
vpRotationMatrix buildFrom(const vpHomogeneousMatrix &M)
unsigned int dsize
Current array size (rowNum * colNum)
Definition: vpArray2D.h:80
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRzyzVector.h:151
Implementation of a rotation vector as axis-angle minimal representation.
vpRzyzVector & operator=(double x)