Simbody
3.4 (development)
|
00001 #ifndef SimTK_SIMBODY_MOBILIZED_BODY_FREE_H_ 00002 #define SimTK_SIMBODY_MOBILIZED_BODY_FREE_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: Paul Mitiguy, Peter Eastman * 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 00052 class SimTK_SIMBODY_EXPORT MobilizedBody::Free : public MobilizedBody { 00053 public: 00056 Free() {} 00057 00063 Free(MobilizedBody& parent, const Transform& X_PF, 00064 const Body& bodyInfo, const Transform& X_BM, Direction=Forward); 00065 00068 Free(MobilizedBody& parent, const Body& bodyInfo, Direction=Forward); 00069 00070 Free& addBodyDecoration(const Transform& X_BD, const DecorativeGeometry& g) { 00071 (void)MobilizedBody::addBodyDecoration(X_BD,g); return *this; 00072 } 00073 Free& addOutboardDecoration(const Transform& X_MD, const DecorativeGeometry& g) { 00074 (void)MobilizedBody::addOutboardDecoration(X_MD,g); return *this; 00075 } 00076 Free& addInboardDecoration (const Transform& X_FD, const DecorativeGeometry& g) { 00077 (void)MobilizedBody::addInboardDecoration(X_FD,g); return *this; 00078 } 00079 00080 Free& setDefaultInboardFrame(const Transform& X_PF) { 00081 (void)MobilizedBody::setDefaultInboardFrame(X_PF); return *this; 00082 } 00083 00084 Free& setDefaultOutboardFrame(const Transform& X_BM) { 00085 (void)MobilizedBody::setDefaultOutboardFrame(X_BM); return *this; 00086 } 00087 00088 // Leaves rotation unchanged. 00089 Free& setDefaultTranslation(const Vec3&); 00090 00091 // Leaves translation unchanged. The internal representation is a quaternion 00092 // so we guarantee that the stored value is numerically identical to the 00093 // supplied one. 00094 Free& setDefaultQuaternion(const Quaternion&); 00095 00096 // Leaves translation unchanged. The Rotation matrix will be converted to 00097 // a quaternion for storage. 00098 Free& setDefaultRotation(const Rotation&); 00099 // Sets both translation and rotation. The Rotation part of the Transform 00100 // will be converted to a quaternion for storage. 00101 Free& setDefaultTransform(const Transform&); 00102 00103 // These return references to the stored default values. 00104 const Vec3& getDefaultTranslation() const; 00105 const Quaternion& getDefaultQuaternion() const; 00106 00107 // These next two are derived from the stored values. 00108 Rotation getDefaultRotation() const { 00109 return Rotation(getDefaultQuaternion()); 00110 } 00111 Transform getDefaultTransform() const { 00112 return Transform(Rotation(getDefaultQuaternion()), getDefaultTranslation()); 00113 } 00114 00115 // Generic default state Topology methods. 00116 00117 // Returns (Vec4,Vec3) where the Vec4 is a normalized quaternion. 00118 const Vec7& getDefaultQ() const; 00119 00120 // Interprets the supplied q as (Vec4,Vec3) where the Vec4 is a possibly 00121 // unnormalized quaternion. The quaternion will be normalized before it is 00122 // stored here, so you may not get back exactly the value supplied here if 00123 // you call getDefaultQ(). 00124 Free& setDefaultQ(const Vec7& q); 00125 00126 // Note that there is no guarantee that the quaternion part of the returned Q is normalized. 00127 const Vec7& getQ(const State&) const; 00128 const Vec7& getQDot(const State&) const; 00129 const Vec7& getQDotDot(const State&) const; 00130 00131 const Vec6& getU(const State&) const; 00132 const Vec6& getUDot(const State&) const; 00133 00134 // The Q's in the state are set exactly as supplied without normalization. 00135 void setQ(State&, const Vec7&) const; 00136 void setU(State&, const Vec6&) const; 00137 00138 const Vec7& getMyPartQ(const State&, const Vector& qlike) const; 00139 const Vec6& getMyPartU(const State&, const Vector& ulike) const; 00140 00141 Vec7& updMyPartQ(const State&, Vector& qlike) const; 00142 Vec6& updMyPartU(const State&, Vector& ulike) const; 00143 // hide from Doxygen 00145 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(Free, FreeImpl, MobilizedBody); 00147 }; 00148 00149 } // namespace SimTK 00150 00151 #endif // SimTK_SIMBODY_MOBILIZED_BODY_FREE_H_ 00152 00153 00154