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>
129 std::string
ToString(
double number);
131 int FileSize(
const std::string& filePath);
133 int StrPos(
const std::string& haystack,
const std::string& needle);
143 inline bool StrEnds(std::string
const& fullString, std::string
const& ending)
145 if (fullString.length() >= ending.length())
147 return (0 == fullString.compare(fullString.length() - ending.length(), ending.length(), ending));
162 return rmax * std::sqrt(
Random());
176 return std::numeric_limits<double>::infinity();
182 return (b >= 0) ? std::abs(a) : -std::abs(a);
187 return (b >= 0) ? std::abs(a) : -std::abs(a);
192 return (b >= 0) ? std::abs(a) : -std::abs(a);
197 return (b >= 0) ? std::abs(a) : -std::abs(a);
202 return (b >= 0) ? std::abs(a) : -std::abs(a);
209 if (x < -1.)
return -
kPi / 2;
210 if (x > 1.)
return kPi / 2;
216 if (x < -1.)
return kPi;
217 if (x > 1.)
return 0;
224 if (x != 0)
return std::atan2(y, x);
225 if (y == 0)
return 0;
226 if (y > 0)
return kPi / 2;
227 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)
void Exception(const char *originOfException, const char *exceptionCode, UExceptionSeverity severity, int level, const char *description)
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
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)