@@ -19,56 +19,56 @@ struct Point
1919 double x{0.0 };
2020 double y{0.0 };
2121
22- static Point Invalid () { return {NAN, NAN}; }
22+ [[nodiscard]] static Point Invalid () { return {NAN, NAN}; }
2323
24- static Point Max ()
24+ [[nodiscard]] static Point Max ()
2525 {
2626 return {std::numeric_limits<double >::max (),
2727 std::numeric_limits<double >::max ()};
2828 }
2929
30- static Point Min ()
30+ [[nodiscard]] static Point Min ()
3131 {
3232 return {std::numeric_limits<double >::lowest (),
3333 std::numeric_limits<double >::lowest ()};
3434 }
3535
36- static Point Ident (bool horizontal)
36+ [[nodiscard]] static Point Ident (bool horizontal)
3737 {
3838 return {horizontal ? 1.0 : 0.0 , horizontal ? 0.0 : 1.0 };
3939 }
4040
41- static Point Polar (double radius, double angle)
41+ [[nodiscard]] static Point Polar (double radius, double angle)
4242 {
4343 return {radius * cos (angle), radius * sin (angle)};
4444 }
4545
46- static Point X (double x) { return {x, 0 }; }
46+ [[nodiscard]] static Point X (double x) { return {x, 0 }; }
4747
48- static Point Y (double y) { return {0 , y}; }
48+ [[nodiscard]] static Point Y (double y) { return {0 , y}; }
4949
50- Point operator *(double factor) const
50+ [[nodiscard]] Point operator *(double factor) const
5151 {
5252 return {x * factor, y * factor};
5353 }
5454
55- Point operator /(double divisor) const
55+ [[nodiscard]] Point operator /(double divisor) const
5656 {
5757 if (Math::Floating::is_zero (divisor)) return Invalid ();
5858 return {x / divisor, y / divisor};
5959 }
6060
61- Point operator +(const Point &other) const
61+ [[nodiscard]] Point operator +(const Point &other) const
6262 {
6363 return {x + other.x , y + other.y };
6464 }
6565
66- Point operator -(const Point &other) const
66+ [[nodiscard]] Point operator -(const Point &other) const
6767 {
6868 return {x - other.x , y - other.y };
6969 }
7070
71- Point operator *(const Point &other) const
71+ [[nodiscard]] Point operator *(const Point &other) const
7272 {
7373 return {x * other.x , y * other.y };
7474 }
@@ -78,18 +78,65 @@ struct Point
7878 return x * other.x + y * other.y ;
7979 }
8080
81- Point operator /(const Point &other) const
81+ [[nodiscard]] Point operator /(const Point &other) const
8282 {
8383 using Math::Floating::is_zero;
8484 if (is_zero (other.x ) || is_zero (other.y )) return Invalid ();
8585 return {x / other.x , y / other.y };
8686 }
8787
88- double operator ^(const Point &p) const
88+ [[nodiscard]] double operator ^(const Point &p) const
8989 {
9090 return x * p.y - y * p.x ;
9191 }
9292
93+ Point &operator +=(const Point &other)
94+ {
95+ x += other.x ;
96+ y += other.y ;
97+ return *this ;
98+ }
99+
100+ Point &operator -=(const Point &other)
101+ {
102+ x -= other.x ;
103+ y -= other.y ;
104+ return *this ;
105+ }
106+
107+ Point &operator *=(double factor)
108+ {
109+ x *= factor;
110+ y *= factor;
111+ return *this ;
112+ }
113+
114+ Point &operator /=(double divisor)
115+ {
116+ if (Math::Floating::is_zero (divisor))
117+ return *this = Invalid ();
118+ x /= divisor;
119+ y /= divisor;
120+ return *this ;
121+ }
122+
123+ Point &operator *=(const Point &other)
124+ {
125+ x *= other.x ;
126+ y *= other.y ;
127+ return *this ;
128+ }
129+
130+ Point &operator /=(const Point &other)
131+ {
132+ using Math::Floating::is_zero;
133+ if (is_zero (other.x ) || is_zero (other.y ))
134+ return *this = Invalid ();
135+ x /= other.x ;
136+ y /= other.y ;
137+ return *this ;
138+ }
139+
93140 [[nodiscard]] Point flip () const { return {y, x}; }
94141
95142 [[nodiscard]] Point flipX () const { return {-x, y}; }
@@ -215,7 +262,7 @@ struct Size : Point
215262 std::min (s1.y , s2.y , less)};
216263 }
217264
218- [[nodiscard]] bool isSquare (double toleranceFactor = 0.0 ) const
265+ [[nodiscard]] bool isSquare (double toleranceFactor) const
219266 {
220267 using Math::Floating::is_zero;
221268 if (is_zero (y)) return false ;
0 commit comments