Blender V2.61 - r43446

jntarrayvel.cpp

Go to the documentation of this file.
00001 
00004 // Copyright  (C)  2007  Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
00005 
00006 // Version: 1.0
00007 // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
00008 // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
00009 // URL: http://www.orocos.org/kdl
00010 
00011 // This library is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU Lesser General Public
00013 // License as published by the Free Software Foundation; either
00014 // version 2.1 of the License, or (at your option) any later version.
00015 
00016 // This library is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00024 
00025 
00026 #include "jntarrayacc.hpp"
00027 
00028 namespace KDL
00029 {
00030     JntArrayVel::JntArrayVel(unsigned int size):
00031         q(size),qdot(size)
00032     {
00033     }
00034     JntArrayVel::JntArrayVel(const JntArray& qin, const JntArray& qdotin):
00035         q(qin),qdot(qdotin)
00036     {
00037         assert(q.rows()==qdot.rows());
00038     }
00039     JntArrayVel::JntArrayVel(const JntArray& qin):
00040         q(qin),qdot(q.rows())
00041     {
00042     }
00043 
00044     JntArray JntArrayVel::value()const
00045     {
00046         return q;
00047     }
00048 
00049     JntArray JntArrayVel::deriv()const
00050     {
00051         return qdot;
00052     }
00053 
00054     void Add(const JntArrayVel& src1,const JntArrayVel& src2,JntArrayVel& dest)
00055     {
00056         Add(src1.q,src2.q,dest.q);
00057         Add(src1.qdot,src2.qdot,dest.qdot);
00058     }
00059     void Add(const JntArrayVel& src1,const JntArray& src2,JntArrayVel& dest)
00060     {
00061         Add(src1.q,src2,dest.q);
00062         dest.qdot=src1.qdot;
00063     }
00064 
00065     void Subtract(const JntArrayVel& src1,const JntArrayVel& src2,JntArrayVel& dest)
00066     {
00067         Subtract(src1.q,src2.q,dest.q);
00068         Subtract(src1.qdot,src2.qdot,dest.qdot);
00069     }
00070     void Subtract(const JntArrayVel& src1,const JntArray& src2,JntArrayVel& dest)
00071     {
00072         Subtract(src1.q,src2,dest.q);
00073         dest.qdot=src1.qdot;
00074     }
00075 
00076     void Multiply(const JntArrayVel& src,const double& factor,JntArrayVel& dest)
00077     {
00078         Multiply(src.q,factor,dest.q);
00079         Multiply(src.qdot,factor,dest.qdot);
00080     }
00081     void Multiply(const JntArrayVel& src,const doubleVel& factor,JntArrayVel& dest)
00082     {
00083         Multiply(src.q,factor.grad,dest.q);
00084         Multiply(src.qdot,factor.t,dest.qdot);
00085         Add(dest.qdot,dest.q,dest.qdot);
00086         Multiply(src.q,factor.t,dest.q);
00087     }
00088 
00089     void Divide(const JntArrayVel& src,const double& factor,JntArrayVel& dest)
00090     {
00091         Divide(src.q,factor,dest.q);
00092         Divide(src.qdot,factor,dest.qdot);
00093     }
00094     void Divide(const JntArrayVel& src,const doubleVel& factor,JntArrayVel& dest)
00095     {
00096         Multiply(src.q,(factor.grad/factor.t/factor.t),dest.q);
00097         Divide(src.qdot,factor.t,dest.qdot);
00098         Subtract(dest.qdot,dest.q,dest.qdot);
00099         Divide(src.q,factor.t,dest.q);
00100     }
00101 
00102     void SetToZero(JntArrayVel& array)
00103     {
00104         SetToZero(array.q);
00105         SetToZero(array.qdot);
00106     }
00107 
00108     bool Equal(const JntArrayVel& src1,const JntArrayVel& src2,double eps)
00109     {
00110         return Equal(src1.q,src2.q,eps)&&Equal(src1.qdot,src2.qdot,eps);
00111     }
00112 }
00113 
00114