- Timestamp:
- 04/20/20 23:27:35 (5 years ago)
- Location:
- cpp/common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/Convert.h
r691 r913 45 45 static double odleglosc_sq(double x1, double y1, double x2, double y2) //odleglosc do kwadratu, wystarczy do porownywania 46 46 { 47 double dx = x2 - x1, dy = y2 - y1; return dx*dx + dy*dy; 47 double dx = x2 - x1, dy = y2 - y1; 48 return dx*dx + dy*dy; 48 49 } 49 50 static double odleglosc_sq(const Pt2D& p1, const Pt2D& p2) //odleglosc do kwadratu … … 97 98 Angle(Angle &kt) { set(kt.get()); } 98 99 Angle(double dy, double dx) { set(dy, dx); } 100 Angle(const Pt2D& xy) { set(xy); } 99 101 void set(double k) { k = fmod(k, M_PI * 2); if (k < 0) k += M_PI * 2; angle = k; sine = sin(k); cosine = cos(k); angle_deg = Convert::toDegrees(angle); angle_deg_int = roundToInt(angle_deg); angle_deg_int %= 360; } 100 102 void set(double dy, double dx) { set(Convert::atan_2(dy, dx)); } 103 void set(const Pt2D& xy) { set(xy.y, xy.x); } 101 104 void add(double dk) { set(angle + dk); } 102 105 void add(Angle &kt) { set(angle + kt.get()); } -
cpp/common/nonstd_math.h
r899 r913 58 58 #endif 59 59 60 61 60 //handling floating point exceptions 62 61 void fpExceptInit(); //call once, before ...Enable/Disable … … 67 66 template <typename Value, typename Linear> Value universal_lerp(Value a,Value b,Linear t) {return a*(1-t)+b*t;} 68 67 68 template <typename T> T linearTransform(T value, T min_in, T max_in, T min_out, T max_out) 69 { 70 return min_out + (value-min_in)*(max_out-min_out)/(max_in-min_in); 71 } 72 69 73 #endif -
cpp/common/util-string.cpp
r897 r913 77 77 } 78 78 79 bool str_starts_with(const char *str, const char *prefix) 80 { 81 return strncmp(str,prefix,strlen(prefix))==0; 82 } 83 79 84 char* strmove(char *a, char *b) //strcpy that works well for overlapping strings ("Source and destination overlap") 80 85 { -
cpp/common/util-string.h
r840 r913 10 10 11 11 char* strmove(char *a, char *b); //strcpy that works well for overlapping strings ("Source and destination overlap") 12 bool str_starts_with(const char *str, const char *prefix); 13 inline bool starts_with(string& str, const char *prefix) { return str_starts_with(str.c_str(),prefix); } //std::string.starts_with(...) since c++20 12 14 13 15 string ssprintf(const char* format, ...);
Note: See TracChangeset
for help on using the changeset viewer.