GLcoordinates.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include "GLcoordinates.h"
00003 
00004 GLcoordinates::GLcoordinates()
00005 {
00006     for (int i=0; i<16; i++) m_trans[i] = 0.0;
00007     m_trans[0] = m_trans[5] = m_trans[10] = m_trans[15] = 1.0;
00008 }
00009 
00010 void GLcoordinates::setTransform(const double i_trans[12]){
00011     for (int i=0; i<3; i++){
00012         for (int j=0; j<4; j++){
00013             m_trans[j*4+i] = i_trans[i*4+j];// transposition for GL
00014         }
00015     }
00016 }
00017 
00018 hrp::Vector3 GLcoordinates::getPosition()
00019 {
00020     return hrp::Vector3(m_trans[12], m_trans[13], m_trans[14]);
00021 }
00022 
00023 void GLcoordinates::setPosition(double x, double y, double z)
00024 {
00025     m_trans[12] = x; m_trans[13] = y; m_trans[14] = z;
00026 }
00027 
00028 void GLcoordinates::getPosition(double& x, double& y, double& z)
00029 {
00030     x = m_trans[12]; y = m_trans[13]; z = m_trans[14];
00031 }
00032 
00033 void GLcoordinates::setRotation(double r, double p, double y)
00034 {
00035     hrp::Matrix33 R = hrp::rotFromRpy(r,p,y);
00036     setRotation(R);
00037 }
00038 
00039 void GLcoordinates::setRotation(double ax, double ay, double az, double th)
00040 {
00041     hrp::Vector3 axis(ax, ay, az);
00042     hrp::Matrix33 R;
00043     hrp::calcRodrigues(R, axis, th);
00044     setRotation(R);
00045 }
00046 
00047 hrp::Matrix33 GLcoordinates::getRotation()
00048 {
00049     hrp::Matrix33 R;
00050     for (int i=0; i<3; i++){
00051         for (int j=0; j<3; j++){
00052             R(j,i) = m_trans[i*4+j];
00053         }
00054     }
00055     return R;
00056 }
00057 
00058 void GLcoordinates::setRotation(const hrp::Matrix33 &R)
00059 {
00060     for (int i=0; i<3; i++){
00061         for (int j=0; j<3; j++){
00062             m_trans[i*4+j] = R(j,i);
00063         }
00064     }
00065 }
00066 
00067 void GLcoordinates::setRotation(const double *R)
00068 {
00069     for (int i=0; i<3; i++){
00070         for (int j=0; j<3; j++){
00071             m_trans[j*4+i] = R[i*3+j];
00072         }
00073     }
00074 }
00075 
00076 void GLcoordinates::getRotation(hrp::Matrix33 &R)
00077 {
00078     for (int i=0; i<3; i++){
00079         for (int j=0; j<3; j++){
00080             R(j,i) = m_trans[i*4+j];
00081         }
00082     }
00083 }
00084 


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed May 15 2019 05:02:17