Simbody  3.4 (development)
MobilizedBody_SphericalCoords.h
Go to the documentation of this file.
00001 #ifndef SimTK_SIMBODY_MOBILIZED_BODY_SPHERICALCOORDS_H_
00002 #define SimTK_SIMBODY_MOBILIZED_BODY_SPHERICALCOORDS_H_
00003 
00004 /* -------------------------------------------------------------------------- *
00005  *                               Simbody(tm)                                  *
00006  * -------------------------------------------------------------------------- *
00007  * This is part of the SimTK biosimulation toolkit originating from           *
00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00010  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody.  *
00011  *                                                                            *
00012  * Portions copyright (c) 2007-13 Stanford University and the Authors.        *
00013  * Authors: Michael Sherman                                                   *
00014  * Contributors: Christopher Bruns                                            *
00015  *                                                                            *
00016  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
00017  * not use this file except in compliance with the License. You may obtain a  *
00018  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
00019  *                                                                            *
00020  * Unless required by applicable law or agreed to in writing, software        *
00021  * distributed under the License is distributed on an "AS IS" BASIS,          *
00022  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
00023  * See the License for the specific language governing permissions and        *
00024  * limitations under the License.                                             *
00025  * -------------------------------------------------------------------------- */
00026 
00030 #include "simbody/internal/MobilizedBody.h"
00031 
00032 namespace SimTK {
00033 
00077 class SimTK_SIMBODY_EXPORT MobilizedBody::SphericalCoords : public MobilizedBody {
00078 public:
00081     SphericalCoords() {}
00082 
00091     SphericalCoords(MobilizedBody& parent, const Transform& X_PF,
00092                     const Body& bodyInfo,  const Transform& X_BM, 
00093                     Direction=Forward);
00094 
00097     SphericalCoords(MobilizedBody& parent, const Body& bodyInfo, 
00098                     Direction=Forward);
00099 
00100 
00102     SphericalCoords(MobilizedBody& parent,      const Transform& X_PF,
00103                     const Body& bodyInfo,       const Transform& X_BM,
00104                     Real azimuthOffset,         bool azimuthNegated,
00105                     Real zenithOffset,          bool zenithNegated,
00106                     CoordinateAxis radialAxis,  bool radialNegated,
00107                     Direction=Forward);
00108 
00109     SphericalCoords& addBodyDecoration(const Transform& X_BD, const DecorativeGeometry& g) {
00110         (void)MobilizedBody::addBodyDecoration(X_BD,g); return *this;
00111     }
00112     SphericalCoords& addOutboardDecoration(const Transform& X_MD,  const DecorativeGeometry& g) {
00113         (void)MobilizedBody::addOutboardDecoration(X_MD,g); return *this;
00114     }
00115     SphericalCoords& addInboardDecoration (const Transform& X_FD, const DecorativeGeometry& g) {
00116         (void)MobilizedBody::addInboardDecoration(X_FD,g); return *this;
00117     }
00118 
00119     SphericalCoords& setDefaultInboardFrame(const Transform& X_PF) {
00120         (void)MobilizedBody::setDefaultInboardFrame(X_PF); return *this;
00121     }
00122 
00123     SphericalCoords& setDefaultOutboardFrame(const Transform& X_BM) {
00124         (void)MobilizedBody::setDefaultOutboardFrame(X_BM); return *this;
00125     }
00126 
00127     // Friendly, mobilizer-specific access to coordinates and speeds.
00128     SphericalCoords& setDefaultAngles(const Vec2& a) {
00129         Vec3 q = getDefaultQ(); q.updSubVec<2>(0) = a; setDefaultQ(q);
00130         return *this;
00131     }
00132     SphericalCoords& setDefaultRadius(Real r) {
00133         Vec3 q = getDefaultQ(); q[2] = r; setDefaultQ(q);
00134         return *this;
00135     }
00136     SphericalCoords& setRadialAxis(CoordinateAxis);
00137     SphericalCoords& setNegateAzimuth(bool);
00138     SphericalCoords& setNegateZenith(bool);
00139     SphericalCoords& setNegateRadial(bool);
00140 
00141     const Vec2&    getDefaultAngles()      const {return getDefaultQ().getSubVec<2>(0);}
00142     Real           getDefaultTranslation() const {return getDefaultQ()[2];}
00143     
00144     CoordinateAxis getRadialAxis()    const;
00145     bool           isAzimuthNegated() const;
00146     bool           isZenithNegated()  const;
00147     bool           isRadialNegated()  const;
00148 
00149     void setAngles(State& s, const Vec2& a) {setOneQ(s,0,a[0]); setOneQ(s,1,a[1]);}
00150     void setRadius(State& s, Real        r) {setOneQ(s,2,r);}
00151 
00152     const Vec2& getAngles(const State& s) const {return getQ(s).getSubVec<2>(0);}
00153     Real        getRadius(const State& s) const {return getQ(s)[2];}
00154 
00155     // Generic default state Topology methods.
00156     const Vec3& getDefaultQ() const;
00157     SphericalCoords& setDefaultQ(const Vec3& q);
00158 
00159     const Vec3& getQ(const State&) const;
00160     const Vec3& getQDot(const State&) const;
00161     const Vec3& getQDotDot(const State&) const;
00162     const Vec3& getU(const State&) const;
00163     const Vec3& getUDot(const State&) const;
00164 
00165     void setQ(State&, const Vec3&) const;
00166     void setU(State&, const Vec3&) const;
00167 
00168     const Vec3& getMyPartQ(const State&, const Vector& qlike) const;
00169     const Vec3& getMyPartU(const State&, const Vector& ulike) const;
00170    
00171     Vec3& updMyPartQ(const State&, Vector& qlike) const;
00172     Vec3& updMyPartU(const State&, Vector& ulike) const;
00173  // hide from Doxygen
00175     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(SphericalCoords, 
00176                                              SphericalCoordsImpl, MobilizedBody);
00178 };
00179 
00180 } // namespace SimTK
00181 
00182 #endif // SimTK_SIMBODY_MOBILIZED_BODY_SPHERICALCOORDS_H_
00183 
00184 
00185 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines