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
00034 #ifndef _HAPTIC_RENDERING_FUNX_H
00035 #define _HAPTIC_RENDERING_FUNX_H
00036
00037
00038
00039
00040 #include <HD/hd.h>
00041 #include <HDU/hduVector.h>
00042 #include <HDU/hduError.h>
00043 #include <HL/hl.h>
00044
00045 #include <types.h>
00046 #include <miscellaneous.h>
00047
00048 #include <hd_hl_apis_aux.h>
00049
00055 hduVector3Dd CalculateWorkspaceDemoForce(void *pUserData);
00056
00062 hduVector3Dd CalculatePlaneDrawingDemoForce(void *pUserData);
00063
00069 void Demo2_BuildPlane(void *pUserData);
00070
00076 template <typename Type>
00077 Type CalculateTanhForceMagnitude(Type x)
00078 {
00079
00080 static Type overlap = 30.0;
00081 static Type limit = 0.25 * overlap;
00082 static Type Fmax = 2.5;
00083 static Type k = Fmax / overlap;
00084 static Type gamma = 0.2;
00085 static Type k2 = 10.0;
00086
00087
00088 Type F;
00089
00090 if(x<overlap && x>=limit)
00091 F = k * gamma * x;
00092 else if(x>0.0 && x<limit)
00093 {
00094 Type beta = log(-(-exp(limit*3.0)+exp(limit)+Fmax*exp(limit)-exp(limit)*sqrt((exp(limit)+1.0)*(Fmax+gamma*k*limit-gamma*k*overlap)*(Fmax-exp(limit)*2.0+Fmax*exp(limit)+gamma*k*limit-gamma*k*overlap+gamma*k*limit*exp(limit)-gamma*k*overlap*exp(limit)+2.0))+Fmax*exp(limit*3.0)+exp(limit*2.0)*sqrt((exp(limit)+1.0)*(Fmax+gamma*k*limit-gamma*k*overlap)*(Fmax-exp(limit)*2.0+Fmax*exp(limit)+gamma*k*limit-gamma*k*overlap+gamma*k*limit*exp(limit)-gamma*k*overlap*exp(limit)+2.0))+gamma*k*limit*exp(limit)-gamma*k*overlap*exp(limit)+gamma*k*limit*exp(limit*3.0)-gamma*k*overlap*exp(limit*3.0))/(-exp(limit*2.0)+Fmax*exp(limit)*2.0+gamma*k*limit*exp(limit)*2.0-gamma*k*overlap*exp(limit)*2.0+1.0))*(1.0/2.0);
00095
00096 Type alpha = pow(cosh(beta - (limit/2.0)),2.0);
00097
00098 Type theta = Fmax + tanh(beta)/(pow(tanh(beta - (limit/2.0)),2.0)-1.0);
00099
00100 F = alpha * tanh(beta - x) + theta;
00101 }
00102 else if(x<=0.)
00103 F = Fmax + k2 * -x;
00104 else
00105 F = 0.;
00106
00107 return F;
00108 }
00109
00115 hduVector3Dd Leg_COP_Monitoring(void *pUserData);
00116
00122 template <typename Type>
00123 Type CalculatePolyForceMagnitude(Type x)
00124 {
00125
00126 static Type overlap_zone = 5.0;
00127
00128
00129 static Type Fmax = 3.3;
00130 static const Type k = Fmax / overlap_zone;
00131 static const Type k2 = 100.0*k;
00132 static Type a = 2.0 * Fmax / pow(overlap_zone,3.0);
00133 static Type b = -1.0 * 3.0 * Fmax / pow(overlap_zone,2.0);
00134
00135 Type F;
00136
00137 if(x<=overlap_zone && x>0.0)
00138 {
00139 F = (a * pow(x,3.) + b * pow(x,2.) + Fmax);
00140 }
00141 else if(x<=0.0)
00142 {
00143 F = Fmax + k2 * (-x);
00144 }
00145 else
00146 {
00147 F = 0.0;
00148 }
00149
00150 return F;
00151 }
00152
00158 template <typename Type>
00159 Type CalculateExponentialForceMagnitude(Type x)
00160 {
00161 return exp(-x+1.0);
00162 }
00163
00169 template <typename Type>
00170 Type CalculatePlaneForceMagnitude(Type x)
00171 {
00172 return CalculateTanhForceMagnitude(x);
00173 }
00174
00175 #endif
00176