20 #ifndef USOLIDS_UUtils
21 #define USOLIDS_UUtils
42 inline short Sign(
short a,
short b);
43 inline int Sign(
int a,
int b);
44 inline long Sign(
long a,
long b);
45 inline float Sign(
float a,
float b);
46 inline double Sign(
double a,
double b);
49 static const double kPi = 3.14159265358979323846;
53 static const double kSqrt2 = 1.4142135623730950488016887242097;
62 inline double ASin(
double);
63 inline double ACos(
double);
64 inline double ATan(
double);
65 inline double ATan2(
double,
double);
68 void Exception(
const char* originOfException,
69 const char* exceptionCode,
72 const char* description);
79 return std::abs(af - bf) < epsilon;
84 return std::abs(af - bf) <= 0.5 * relPrec * (std::abs(af) + std::abs(bf));
88 long LocMin(
long n,
const double* a);
89 long LocMax(
long n,
const double* a);
104 template<
typename Index>
119 template<
typename Index>
133 std::string
ToString(
double number);
135 int FileSize(
const std::string& filePath);
137 int StrPos(
const std::string& haystack,
const std::string& needle);
147 inline bool StrEnds(std::string
const& fullString, std::string
const& ending)
149 if (fullString.length() >= ending.length())
151 return (0 == fullString.compare(fullString.length() - ending.length(), ending.length(), ending));
166 return rmax * std::sqrt(
Random());
180 return std::numeric_limits<double>::infinity();
186 return (b >= 0) ? std::abs(a) : -std::abs(a);
191 return (b >= 0) ? std::abs(a) : -std::abs(a);
196 return (b >= 0) ? std::abs(a) : -std::abs(a);
201 return (b >= 0) ? std::abs(a) : -std::abs(a);
206 return (b >= 0) ? std::abs(a) : -std::abs(a);
213 if (x < -1.)
return -
kPi / 2;
214 if (x > 1.)
return kPi / 2;
220 if (x < -1.)
return kPi;
221 if (x > 1.)
return 0;
228 if (x != 0)
return std::atan2(y, x);
229 if (y == 0)
return 0;
230 if (y > 0)
return kPi / 2;
231 else return -
kPi / 2;
static const double kDegToRad
bool operator()(Index i1, Index i2)
bool AreEqualAbs(double af, double bf, double epsilon)
static const double kRadToDeg
int FileSize(const std::string &filePath)
static const int kMaxMeshSections
bool AreEqualRel(double af, double bf, double relPrec)
static const double kInfinity
static const double kTwoPi
bool StrEnds(std::string const &fullString, std::string const &ending)
double ATan2(double, double)
double GetRadiusInRing(double rmin, double rmax)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
bool operator()(Index i1, Index i2)
static const double kMeshAngleDefault
static const double kSqrt2
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
int SaveVectorToExternalFile(const std::vector< double > &vector, const std::string &filename)
static const int kMinMeshSections
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
std::string ToString(int number)
short Sign(short a, short b)
long LocMin(long n, const double *a)
int StrPos(const std::string &haystack, const std::string &needle)
double Random(double min=0.0, double max=1.0)
void TransformLimits(UVector3 &min, UVector3 &max, const UTransform3D &transformation)
long LocMax(long n, const double *a)