git-svn-id: svn://db.shs.com.ru/pip@563 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-11-27 13:28:01 +00:00
parent b648e3637e
commit 050d6d0347
2 changed files with 7 additions and 7 deletions

View File

@@ -20,7 +20,7 @@
#ifndef PIGEOMETRY_H #ifndef PIGEOMETRY_H
#define PIGEOMETRY_H #define PIGEOMETRY_H
#include "pimath.h" #include "pimathbase.h"
template<typename Type> template<typename Type>
class PIP_EXPORT PIPoint { class PIP_EXPORT PIPoint {
@@ -28,14 +28,14 @@ public:
Type x; Type x;
Type y; Type y;
PIPoint() {x = y = 0;}; PIPoint() {x = y = 0;}
PIPoint(Type x_, Type y_) {set(x_, y_);} PIPoint(Type x_, Type y_) {set(x_, y_);}
PIPoint<Type> & set(Type x_, Type y_) {x = x_; y = y_; return *this;} PIPoint<Type> & set(Type x_, Type y_) {x = x_; y = y_; return *this;}
PIPoint<Type> & move(Type x_, Type y_) {x += x_; y += y_; return *this;} PIPoint<Type> & move(Type x_, Type y_) {x += x_; y += y_; return *this;}
PIPoint<Type> & move(const PIPoint<Type> & p) {x += p.x; y += p.y; return *this;} PIPoint<Type> & move(const PIPoint<Type> & p) {x += p.x; y += p.y; return *this;}
double angleRad() const {return atan2(y, x);} double angleRad() const {return atan2(y, x);}
int angleDeg() const {return round(atan2(y, x) * 180. / M_PI);} int angleDeg() const {return round(atan2(y, x) * rad2deg);}
PIPoint<Type> toPolar(bool isDeg = false) const {return PIPoint<Type>(sqrt(x*x + y*y), isDeg ? angleDeg() : angleRad());} PIPoint<Type> toPolar(bool isDeg = false) const {return PIPoint<Type>(sqrt(x*x + y*y), isDeg ? angleDeg() : angleRad());}
static PIPoint<Type> fromPolar(const PIPoint<Type> & p) {return PIPoint<Type>(p.y * cos(p.x), p.y * sin(p.x));} static PIPoint<Type> fromPolar(const PIPoint<Type> & p) {return PIPoint<Type>(p.y * cos(p.x), p.y * sin(p.x));}
@@ -52,7 +52,7 @@ public:
}; };
template<typename Type> template<typename Type>
std::ostream & operator <<(std::ostream & s, const PIPoint<Type> & v) {s << '{' << v.x << ", " << v.y << '}'; return s;} PICout operator <<(PICout & s, const PIPoint<Type> & v) {s.setControl(0, true); s << '{' << v.x << ", " << v.y << '}'; s.restoreControl(); return s;}
template<typename Type> template<typename Type>
class PIP_EXPORT PIRect { class PIP_EXPORT PIRect {
@@ -62,7 +62,7 @@ public:
Type x1; Type x1;
Type y1; Type y1;
PIRect() {x0 = y0 = x1 = y1 = 0;}; PIRect() {x0 = y0 = x1 = y1 = 0;}
PIRect(Type x, Type y, Type w, Type h) {set(x, y, w, h);} PIRect(Type x, Type y, Type w, Type h) {set(x, y, w, h);}
PIRect(const PIPoint<Type> & tl, const PIPoint<Type> & br) {set(tl.x, tl.y, br.x, br.y);} PIRect(const PIPoint<Type> & tl, const PIPoint<Type> & br) {set(tl.x, tl.y, br.x, br.y);}
PIRect(const PIPoint<Type> & p0, const PIPoint<Type> & p1, const PIPoint<Type> & p2) {set(piMin<Type>(p0.x, p1.x, p2.x), piMin<Type>(p0.y, p1.y, p2.y), PIRect(const PIPoint<Type> & p0, const PIPoint<Type> & p1, const PIPoint<Type> & p2) {set(piMin<Type>(p0.x, p1.x, p2.x), piMin<Type>(p0.y, p1.y, p2.y),
@@ -122,7 +122,7 @@ public:
}; };
template<typename Type> template<typename Type>
std::ostream & operator <<(std::ostream & s, const PIRect<Type> & v) {s << '{' << v.x0 << ", " << v.y0 << "; " << v.x1 - v.x0 << ", " << v.y1 - v.y0 << '}'; return s;} PICout operator <<(PICout & s, const PIRect<Type> & v) {s.setControl(0, true); s << '{' << v.x0 << ", " << v.y0 << "; " << v.x1 - v.x0 << ", " << v.y1 - v.y0 << '}'; s.restoreControl(); return s;}
typedef PIPoint<int> PIPointi; typedef PIPoint<int> PIPointi;
typedef PIPoint<uint> PIPointu; typedef PIPoint<uint> PIPointu;

View File

@@ -3,7 +3,7 @@
#define PIVERSION_H #define PIVERSION_H
#define PIP_VERSION_MAJOR 1 #define PIP_VERSION_MAJOR 1
#define PIP_VERSION_MINOR 2 #define PIP_VERSION_MINOR 3
#define PIP_VERSION_REVISION 0 #define PIP_VERSION_REVISION 0
#define PIP_VERSION_SUFFIX "_alpha" #define PIP_VERSION_SUFFIX "_alpha"