PyShape.cpp
Go to the documentation of this file.
00001 #include "PyShape.h"
00002 #include "PyUtil.h"
00003 
00004 PyObject *PyShape::getRelPosition()
00005 {
00006     boost::python::list retval;
00007     VectorToPyList(getPosition(), retval);
00008     return boost::python::incref(retval.ptr());
00009 }
00010 
00011 void PyShape::setRelPosition(PyObject *v)
00012 {
00013     if (PySequence_Size(v) != 3) return;
00014     hrp::Vector3 b;
00015     PyListToVector(v, b);
00016     GLcoordinates::setPosition(b);
00017 }
00018 
00019 PyObject *PyShape::getRelRotation()
00020 {
00021     boost::python::list retval;
00022     hrp::Matrix33 Rs = getRotation();
00023     Matrix33ToPyList(Rs, retval);
00024     return boost::python::incref(retval.ptr());
00025 }
00026 
00027 void PyShape::setRelRotation(PyObject *v)
00028 {
00029     int n = PySequence_Size(v);
00030     hrp::Matrix33 Rs;
00031     if (n == 9){
00032         PyListToMatrix33(v, Rs);
00033     }else if (n == 4){
00034         hrp::Vector3 axis;
00035         for (int i=0; i<3; i++) {
00036             axis(i) = boost::python::extract<double>(PySequence_GetItem(v, i));
00037         }
00038         double angle = boost::python::extract<double>(PySequence_GetItem(v, 3));
00039         hrp::calcRodrigues(Rs, axis, angle);
00040     }else if (n == 3){
00041         hrp::Vector3 rpy;
00042         PyListToVector(v, rpy);
00043         hrp::calcRotFromRpy(Rs, rpy[0], rpy[1], rpy[2]);
00044     }else{
00045         return;
00046     }
00047     GLcoordinates::setRotation(Rs);
00048 }
00049 
00050 PyObject *PyShape::getDiffuseColor()
00051 {
00052     boost::python::list retval;
00053     for (int i=0; i<4; i++) retval.append(m_diffuse[i]);
00054     return boost::python::incref(retval.ptr());
00055 }
00056 
00057 void PyShape::setDiffuseColor(PyObject *v)
00058 {
00059     if (PySequence_Size(v) != 4) return;
00060 
00061     for (int i=0; i<PySequence_Size(v); i++) {
00062         m_diffuse[i] = boost::python::extract<double>(PySequence_GetItem(v, i));
00063     }
00064     compile();
00065 }
00066 
00067 GLshape *createPyShape()
00068 {
00069     return new PyShape();
00070 }


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