Math tunes

This commit is contained in:
IlyaShurupov 2024-07-17 09:38:46 +03:00 committed by Ilya Shurupov
parent c3b563a032
commit 3b27fe17c1
2 changed files with 6 additions and 4 deletions

View file

@ -120,14 +120,14 @@ namespace tp {
}
// pos
Vec2<Type> p1() { return pos; }
Vec2<Type> p1() const { return pos; }
// pos + size
Vec2<Type> p3() { return pos + size; }
Vec2<Type> p3() const { return pos + size; }
Vec2<Type> p2() { return { pos.x, pos.y + size.y }; }
Vec2<Type> p2() const { return { pos.x, pos.y + size.y }; }
Vec2<Type> p4() { return { pos.x + size.x, pos.y }; }
Vec2<Type> p4() const { return { pos.x + size.x, pos.y }; }
inline bool isAbove(const Rect<Type>& rect) const { return (pos.y + size.y < rect.pos.y); }

View file

@ -360,6 +360,8 @@ namespace tp {
Vec normal() { return { -y, x }; }
[[nodiscard]] alnf length2() const { return (x * x + y * y); }
[[nodiscard]] halnf max() const { return tp::max(x, y); }
[[nodiscard]] halnf min() const { return tp::min(x, y); }
[[nodiscard]] alnf length() const {
Type const tmp = (Type) (x * x + y * y);