Changeset 913

Ignore:
Timestamp:
04/20/20 23:27:35 (4 years ago)
Message:

Location:
cpp/common
Files:
4 edited

Unmodified
Removed
• cpp/common/Convert.h

 r691 static double odleglosc_sq(double x1, double y1, double x2, double y2) //odleglosc do kwadratu, wystarczy do porownywania { double dx = x2 - x1, dy = y2 - y1; return dx*dx + dy*dy; double dx = x2 - x1, dy = y2 - y1; return dx*dx + dy*dy; } static double odleglosc_sq(const Pt2D& p1, const Pt2D& p2) //odleglosc do kwadratu Angle(Angle &kt) { set(kt.get()); } Angle(double dy, double dx) { set(dy, dx); } Angle(const Pt2D& xy) { set(xy); } 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; } void set(double dy, double dx) { set(Convert::atan_2(dy, dx)); } void set(const Pt2D& xy) { set(xy.y, xy.x); } void add(double dk) { set(angle + dk); } void add(Angle &kt) { set(angle + kt.get()); }
• cpp/common/nonstd_math.h

 r899 #endif //handling floating point exceptions void fpExceptInit(); //call once, before ...Enable/Disable template Value universal_lerp(Value a,Value b,Linear t) {return a*(1-t)+b*t;} template T linearTransform(T value, T min_in, T max_in, T min_out, T max_out) { return min_out + (value-min_in)*(max_out-min_out)/(max_in-min_in); } #endif
• cpp/common/util-string.cpp

 r897 } bool str_starts_with(const char *str, const char *prefix) { return strncmp(str,prefix,strlen(prefix))==0; } char* strmove(char *a, char *b) //strcpy that works well for overlapping strings ("Source and destination overlap") {
• cpp/common/util-string.h

 r840 char* strmove(char *a, char *b); //strcpy that works well for overlapping strings ("Source and destination overlap") bool str_starts_with(const char *str, const char *prefix); inline bool starts_with(string& str, const char *prefix) { return str_starts_with(str.c_str(),prefix); } //std::string.starts_with(...) since c++20 string ssprintf(const char* format, ...);
Note: See TracChangeset for help on using the changeset viewer.