PIRect complete

This commit is contained in:
Andrey
2022-03-21 10:35:34 +03:00
parent 2596b119ac
commit 3dd0d0b6cf
7 changed files with 160 additions and 57 deletions

View File

@@ -65,8 +65,28 @@ public:
y += p.y;
return *this;
}
PIPoint<Type> translated(Type x_, Type y_) const {
PIPoint<Type> rp(*this);
rp.translate(x_, y_);
return rp;
}
PIPoint<Type> translated(const PIPoint<Type> & p) const {
PIPoint<Type> rp(*this);
rp.translate(p);
return rp;
}
PIPoint<Type> & move(Type x_, Type y_) {return translate(x_, y_);}
PIPoint<Type> & move(const PIPoint<Type> & p) {return translate(p);}
PIPoint<Type> moved(Type x_, Type y_) const {
PIPoint<Type> rp(*this);
rp.translate(x_, y_);
return rp;
}
PIPoint<Type> moved(const PIPoint<Type> & p) const {
PIPoint<Type> rp(*this);
rp.translate(p);
return rp;
}
double angleRad() const {return atan2(y, x);}
double angleDeg() const {return toDeg(atan2(y, x));}
PIPoint<Type> toPolar(bool isDeg = false) const {return PIPoint<Type>(sqrt(x*x + y*y), isDeg ? angleDeg() : angleRad());}