source: flair-src/trunk/lib/FlairCore/src/RotationMatrix.cpp@ 2

Last change on this file since 2 was 2, checked in by Sanahuja Guillaume, 7 years ago

flaircore

File size: 1.6 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2016/02/09
6// filename: RotationMatrix.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class defining a rotation matrix
14//
15//
16/*********************************************************************/
17
18#include "RotationMatrix.h"
19#include "Object.h"
20#include "Euler.h"
21#include "math.h"
22
23namespace flair
24{
25namespace core
26{
27
28RotationMatrix::RotationMatrix() {
29 for(int i=0;i<3;i++) {
30 for(int j=0;j<3;j++) {
31 if(i==j) {
32 m[i][j]=1;
33 }else {
34 m[i][j]=0;
35 }
36 }
37 }
38}
39
40RotationMatrix::~RotationMatrix() {
41
42}
43
44void RotationMatrix::ToEuler(Euler &euler) const {
45 euler.roll=atanf(m[1][2]/m[2][2]);
46 euler.pitch=asinf(-m[0][2]);
47 euler.yaw=atan2f(m[0][1],m[0][0]);
48}
49
50Euler RotationMatrix::ToEuler(void) const {
51 Euler euler;
52 ToEuler(euler);
53 return euler;
54}
55
56float& RotationMatrix::operator()(size_t row,size_t col) {
57 if(row<3 && col<3) {
58 return m[row][col];
59 } else {
60 Printf("RotationMatrix: index (%i,%i) out of bound\n",row,col);
61 return m[2][2];
62 }
63}
64
65const float& RotationMatrix::operator()(size_t row,size_t col) const {
66 if(row<3 && col<3) {
67 return m[row][col];
68 } else {
69 Printf("RotationMatrix: index (%i,%i) out of bound\n",row,col);
70 return m[2][2];
71 }
72}
73
74} // end namespace core
75} // end namespace flair
Note: See TracBrowser for help on using the repository browser.