20 #ifndef USOLIDS_UUtils
21 #define USOLIDS_UUtils
41 inline short Sign(
short a,
short b);
42 inline int Sign(
int a,
int b);
43 inline long Sign(
long a,
long b);
44 inline float Sign(
float a,
float b);
45 inline double Sign(
double a,
double b);
48 static const double kPi = 3.14159265358979323846;
52 static const double kSqrt2 = 1.4142135623730950488016887242097;
61 inline double ASin(
double);
62 inline double ACos(
double);
63 inline double ATan(
double);
64 inline double ATan2(
double,
double);
67 void Exception(
const char* originOfException,
68 const char* exceptionCode,
71 const char* description);
78 return std::abs(af - bf) < epsilon;
83 return std::abs(af - bf) <= 0.5 * relPrec * (std::abs(af) + std::abs(bf));
87 long LocMin(
long n,
const double* a);
88 long LocMax(
long n,
const double* a);
103 template<
typename Index>
118 template<
typename Index>
128 std::string
ToString(
double number);
130 int FileSize(
const std::string& filePath);
132 int StrPos(
const std::string& haystack,
const std::string& needle);
142 inline bool StrEnds(std::string
const& fullString, std::string
const& ending)
144 if (fullString.length() >= ending.length())
146 return (0 == fullString.compare(fullString.length() - ending.length(), ending.length(), ending));
161 return rmax * std::sqrt(
Random());
175 return std::numeric_limits<double>::infinity();
181 return (b >= 0) ? std::abs(a) : -std::abs(a);
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);
208 if (x < -1.)
return -
kPi / 2;
209 if (x > 1.)
return kPi / 2;
215 if (x < -1.)
return kPi;
216 if (x > 1.)
return 0;
223 if (x != 0)
return std::atan2(y, x);
224 if (y == 0)
return 0;
225 if (y > 0)
return kPi / 2;
226 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
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)