00001 /**************************************************************************** 00002 Copyright (C)2003 David Jung <opensim@pobox.com> 00003 00004 This program/file is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. (http://www.gnu.org) 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 $Id: PositionableOrientable.cpp 1031 2004-02-11 20:46:36Z jungd $ 00019 $Revision: 1.4 $ 00020 $Date: 2004-02-11 15:46:36 -0500 (Wed, 11 Feb 2004) $ 00021 $Author: jungd $ 00022 00023 ****************************************************************************/ 00024 00025 #include <physics/PositionableOrientable> 00026 00027 #include <base/Math> 00028 00029 00030 using physics::PositionableOrientable; 00031 00032 using base::Math; 00033 using base::Point3; 00034 using base::Quat4; 00035 using base::Orient; 00036 using base::Vector3; 00037 using base::Transform; 00038 00039 00040 00041 void PositionableOrientable::setPosition2D(const base::Point2& p, Real theta) 00042 { 00043 Point3 pos( getPosition() ); 00044 pos.x = p.x; pos.y = p.y; 00045 00046 // convert the orientation to EulerZYXs, whos first component is the rotation about the Z axis 00047 Orient orient( getOrientation() ); orient.changeRepresentation(Orient::EulerZYXs); 00048 orient[0] = theta; // reset it with our new rotation about Z 00049 Transform configuration(orient); 00050 configuration.setTranslationComponent(pos); 00051 setConfiguration(configuration); 00052 00053 //!!! temporarily just ignore the other orientation components 00054 /* 00055 Transform rotZTheta = Quat4(Vector3(0,0,1), theta); 00056 Transform configuration(rotZTheta); 00057 configuration.setTranslationComponent(pos); 00058 setConfiguration(configuration); 00059 */ 00060 00061 } 00062 00063 00064 Real PositionableOrientable::getOrientation2D() const 00065 { 00066 // convert the orientation to EulerZYXs, whos first component is the rotation about the Z axis 00067 return Math::normalizeAngle(getOrientation().getVector(Orient::EulerZYXs)[0]); 00068 } 00069