RiboseMobilizer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef SimTK_RIBOSE_MOBILIZER_H_
00033 #define SimTK_RIBOSE_MOBILIZER_H_
00034
00035 #include "SimTKsimbody.h"
00036 #include "molmodel/internal/common.h"
00037 #include "molmodel/internal/units.h"
00038 #include <cmath>
00039
00040 namespace SimTK {
00041
00043 class ZeroFunction : public Function::Constant {
00044 public:
00045 ZeroFunction() : Function::Constant(0, 0) {}
00046 };
00047
00049 class SimTK_MOLMODEL_EXPORT SinusoidFunction : public Function {
00050 private:
00051 Angle amplitude;
00052 Angle phase;
00053 public:
00054
00055
00056 SinusoidFunction()
00057 : amplitude(1.0), phase(0.0*Deg2Rad) {}
00058
00059
00060 SinusoidFunction(Angle amp, Angle phi)
00061 : amplitude(amp), phase(phi) {}
00062
00063 Real calcValue(const Vector& x) const{
00064 return amplitude*std::sin(x[0] - phase);
00065 }
00066
00067 Real calcDerivative(const Array_<int>& derivComponents, const Vector& x) const{
00068 Real deriv = 0;
00069
00070 assert(1 == x.size());
00071
00072
00073 if ( 1 == (derivComponents.size() % 4) ){
00074 deriv = amplitude*std::cos(x[0] - phase);
00075 }
00076
00077 else if ( 2 == (derivComponents.size() % 4) ){
00078 deriv = -amplitude*std::sin(x[0] - phase);
00079 }
00080
00081 else if ( 3 == (derivComponents.size() % 4) ){
00082 deriv = -amplitude*std::cos(x[0] - phase);
00083 }
00084
00085 else if ( 0 == (derivComponents.size() % 4) ){
00086 deriv = amplitude*std::sin(x[0] - phase);
00087 }
00088 else assert(false);
00089
00090 return deriv;
00091 }
00092
00093 int getArgumentSize() const{
00094 return 1;
00095 }
00096
00097 int getMaxDerivativeOrder() const{
00098 return 1000;
00099 }
00100 };
00101
00102 class SimTK_MOLMODEL_EXPORT PseudorotationMobilizer : public MobilizedBody::FunctionBased
00103 {
00104 public:
00105 PseudorotationMobilizer(
00106 MobilizedBody& parent,
00107 const Transform& inbFrame,
00108 const Body& body,
00109 const Transform& outbFrame,
00110 Angle amplitude,
00111 Angle phase
00112 )
00113 : MobilizedBody::FunctionBased(
00114 parent,
00115 inbFrame,
00116 body,
00117 outbFrame,
00118 1,
00119 createFunctions(amplitude, phase),
00120 createCoordIndices()
00121 )
00122 {}
00123
00124 private:
00125
00126 static std::vector< const Function* > createFunctions(Angle amplitude, Angle phase);
00127 static std::vector< std::vector<int> > createCoordIndices();
00128
00129 };
00130
00131
00132 class SimTK_MOLMODEL_EXPORT RiboseNu3Mobilizer : public PseudorotationMobilizer
00133 {
00134 public:
00135 RiboseNu3Mobilizer(
00136 MobilizedBody& parent,
00137 const Transform& inbFrame,
00138 const Body& body,
00139 const Transform& outbFrame)
00140 : PseudorotationMobilizer(
00141 parent,
00142 inbFrame,
00143 body,
00144 outbFrame,
00145 36.4*Deg2Rad,
00146 124.8*Deg2Rad)
00147 {}
00148
00149 };
00150
00151 }
00152
00153 #endif