/*==================================================================================== ! Purpose(s): ! ! Contain(s): ! ! Author(s): Javier Lopez Lara (jav.lopez@unican.es) ! Gabriel Barajas (barajasg@unican.es) !====================================================================================*/ #include "CArrayMasks.h" #include "math.h" const double EM6=1e-6; // Returns the maximum of the arguments. inline double max2(double AVal1, double AVal2) {if (AVal1>AVal2) return AVal1; else return AVal2;}; inline double max3(double AVal1, double AVal2, double AVal3) {return max2(AVal1, max2(AVal2, AVal3));}; inline double max4(double AVal1, double AVal2, double AVal3, double AVal4) {return max2(max2(AVal1, AVal2), max2(AVal3, AVal4));}; inline double min2(double AVal1, double AVal2) {if (AVal1=0)?1.0:(-1.0);}; //inline double copysign(double AVal, double ASign) {return (ASign*AVal>=0)?AVal:(-AVal);}; //---------------------------------------------------------------------------------------- // Compute the cube of the argument. inline double Cube(double AVal) {return AVal*AVal*AVal;}; inline TIntCMask Cube(const TIntCMask &AM) {return TIntCMask(AM.tr*AM.tr*AM.tr);}; inline TIntCMask Cube(const TCMask &AM) {return TIntCMask(AM.tr()*AM.tr()*AM.tr());}; //inline Tcrt Cube(const Tcrt &AVal) {return Tcrt(AVal.t*AVal.t*AVal.t, AVal.tr*AVal.tr*AVal.tr, AVal.c*AVal.c*AVal.c, AVal.r*AVal.r*AVal.r);}; //---------------------------------------------------------------------------------------- // Compute the module of a vector. inline double Module(double AX, double AY) {return sqrt(AX*AX+AY*AY);}; inline double Module(const TVector &AV) {return sqrt(AV.x*AV.x+AV.y*AV.y);}; // Compute the squared module of a vector. inline double SqrMod(double AX, double AY) {return AX*AX+AY*AY;}; inline double SqrMod(const TVector &AV) {return AV.x*AV.x+AV.y*AV.y;}; //---------------------------------------------------------------------------------------- // Compute the dot product of two vectors. inline double DotProduct(const TVector &AV1, const TVector &AV2) {return AV1.x*AV2.x+AV1.y*AV2.y;}; // Returns a vector rotated 90º to the right of AV. inline TVector NormalVector(const TVector &AV) {return TVector(AV.y, -AV.x);};