--- a +++ b/Tools/GRFPrediction/ConditionalContactDistanceAndVelocityDepClass.any @@ -0,0 +1,72 @@ + + +#class_template ConditionalContactDistanceAndVelocityDepClass (AnyRefFrame &BaseObject, AnyRefFrame &TargetObject, DisplayTriggerVolume = 0, DisplayTargetNode=0) + { + AnyComponentDefinition obj = {}; + AnyRefFrame &StrengthObject=TargetObject; //Node used for strength measurement, occasionally this is different from the target object + + AnyFolder &DrawRef=Main.DrawSettings; //reference to the folder which contains drawsettings + //low limit for the strength measure function, if the distance measured along Direction[0] is below this val. the strength will be zero (negative) + #var AnyVar UserDefinedDistLimitLow; + //high limit for the strength measure function, if the distance measured along Direction[0] is above this val. the strength will be zero + #var AnyVar UserDefinedDistLimitHigh ; + + //high limit for the strength measure function, if the radius measured along the plane with Direction[0] as normal is above this val. the strength will be zero + #var AnyVar UserDefinedRadiusLimit; + + //high limit for the strength measure function, if the velocity measured is above this val. the strength will be zero + #var AnyVar UserDefinedVelLimitHigh; + + #var AnyVec3 UserDefinedGroundVel = {0,0,0}; + + #if (DisplayTriggerVolume) + BaseObject = { + AnyRefNode CylRotNode = { + sRel = {0,0,0}; + ARel = RotMat(..RotCoefY*..GlobalRotCoef*pi/2,y)*RotMat(..RotCoefX*..GlobalRotCoef*pi/2,x); + AnyRefNode CylNode = { + sRel = {0,0,...UserDefinedDistLimitLow}; + AnySurfCylinder TriggerCyl = + { + Radius = ....UserDefinedRadiusLimit; + Length = - ....UserDefinedDistLimitLow + ....UserDefinedDistLimitHigh; + CapRatio = 0.001; + AnyDrawParamSurf Draw = + { + Visible = On; + Opacity = 0.5; + }; + }; + }; + }; + }; + #endif + + #if (DisplayTargetNode) + TargetObject = { + AnyDrawNode DrawContactTarget = { + ScaleXYZ = {1,1,1}*0.015; + }; + }; + #endif + + #var AnyVar Strength; //strength of muscles + #var AnyVar StaticFrictionCoefficient; //Friction coefficient + #var AnyVar ScaleFactor =1; //scale factor for draw vectors it can be set differently than by the drawsettings + + #var AnyInt NormalDirection = Z; + #var AnyInt FrictionDirection1 = X; + #var AnyInt FrictionDirection2 = Y; + + AnyInt X = 0; + AnyInt Y = 1; + AnyInt Z = 2; + + AnyVar GlobalRotCoef = iffun(2-NormalDirection,1,0); // 0 if z is normal, if not 1 + AnyVar RotCoefY = iffun(NormalDirection,0,1); + AnyVar RotCoefX = iffun(NormalDirection,-1,0); + + AnyIntArray Direction = {NormalDirection,FrictionDirection1,FrictionDirection2}; //first element gives normal direction + + #include "ContactSurfaceDistanceAndVelocityDepLinPush.any" + }; \ No newline at end of file