SphericalJoint.h

00001 /****************************************************************************
00002  * Copyright 2007 Evan Drumwright
00003  * This library is distributed under the terms of the GNU General Public 
00004  * License (found in COPYING).
00005  ****************************************************************************/
00006 
00007 #ifndef _SPHERICAL_JOINT_H
00008 #define _SPHERICAL_JOINT_H
00009 
00010 #include <Physsim/Joint.h>
00011 
00012 namespace Physsim {
00013 
00015 class SphericalJoint : public Joint
00016 {
00017         public:
00018                 enum Axis { eAxis1, eAxis2, eAxis3 };
00019 
00020                 SphericalJoint();
00021                 virtual ~SphericalJoint() {}
00022                 virtual void clone(BasePtr& cloned, bimap<BasePtr, BasePtr>* obj_map = NULL) const;
00023                 virtual void load_state(BaseConstPtr object, bimap<BasePtr, BasePtr>* correspondence = NULL);
00024                 virtual void save_state(BasePtr object, bimap<BasePtr, BasePtr>* correspondence = NULL) const;
00025                 SphericalJoint(boost::weak_ptr<RigidBody> inboard, boost::weak_ptr<RigidBody> outboard);
00026                 Vector3 get_axis_global(Axis a) const;
00027                 void set_axis_global(const Vector3& axis, Axis a);
00028                 void set_axis_local(const Vector3& axis, Axis a);
00029                 virtual void update_spatial_axes();             
00030                 virtual void determine_Q();
00031                 virtual const Matrix4& get_transform();
00032                 virtual const SMatrixN& get_spatial_axes(ReferenceFrameType type);
00033                 virtual const SMatrixN& get_spatial_axes_deriv(ReferenceFrameType type);
00034                 virtual void load_from_xml(XMLTreeConstPtr node, std::map<std::string, BasePtr>& id_map);
00035                 virtual void save_to_xml(XMLTreePtr node, std::list<BaseConstPtr>& shared_objects) const;
00036                 virtual unsigned get_num_dof() const { return 3; }
00037 
00039                 virtual bool is_singular_config() const { return std::fabs(std::sin(get_q()[DOF_1])) < _SINGULAR_TOL && std::fabs(std::cos(get_q()[DOF_2])) < _SINGULAR_TOL; }
00040                         
00042 
00049                 const Vector3& get_axis_local(Axis a) const { return _u[a]; }
00050 
00051         private:
00052                 virtual void update_visualization();
00053                 Matrix3 get_rotation() const;
00054 
00056 
00061                 static const Real _SINGULAR_TOL = 1e-2;
00062 
00064                 Matrix3 _R;
00065 
00067                 bool _si_computed;
00068 
00070                 bool _si_dot_computed;
00071 
00073                 Real _last_q2, _last_q1;
00074 
00076                 Real _last_sid_q2, _last_sid_q1, _last_qd2, _last_qd1;
00077 
00079                 std::vector<Vector3> _u;
00080 
00082                 Matrix4 _T;
00083 
00085                 SMatrixN _si_dot_i;
00086 
00088                 SMatrixN _si_dot_0;
00089 }; // end class
00090 } // end namespace
00091 
00092 #endif
00093 

Generated on Wed Oct 24 14:54:22 2007 for Physsim by  doxygen 1.5.1