@@ -18,56 +18,56 @@ struct Point
1818 double x{0.0 };
1919 double y{0.0 };
2020
21- static Point Invalid () { return {NAN, NAN}; }
21+ [[nodiscard]] static Point Invalid () { return {NAN, NAN}; }
2222
23- static Point Max ()
23+ [[nodiscard]] static Point Max ()
2424 {
2525 return {std::numeric_limits<double >::max (),
2626 std::numeric_limits<double >::max ()};
2727 }
2828
29- static Point Min ()
29+ [[nodiscard]] static Point Min ()
3030 {
3131 return {std::numeric_limits<double >::lowest (),
3232 std::numeric_limits<double >::lowest ()};
3333 }
3434
35- static Point Ident (bool horizontal)
35+ [[nodiscard]] static Point Ident (bool horizontal)
3636 {
3737 return {horizontal ? 1.0 : 0.0 , horizontal ? 0.0 : 1.0 };
3838 }
3939
40- static Point Polar (double radius, double angle)
40+ [[nodiscard]] static Point Polar (double radius, double angle)
4141 {
4242 return {radius * cos (angle), radius * sin (angle)};
4343 }
4444
45- static Point X (double x) { return {x, 0 }; }
45+ [[nodiscard]] static Point X (double x) { return {x, 0 }; }
4646
47- static Point Y (double y) { return {0 , y}; }
47+ [[nodiscard]] static Point Y (double y) { return {0 , y}; }
4848
49- Point operator *(double factor) const
49+ [[nodiscard]] Point operator *(double factor) const
5050 {
5151 return {x * factor, y * factor};
5252 }
5353
54- Point operator /(double divisor) const
54+ [[nodiscard]] Point operator /(double divisor) const
5555 {
5656 if (Math::Floating::is_zero (divisor)) return Invalid ();
5757 return {x / divisor, y / divisor};
5858 }
5959
60- Point operator +(const Point &other) const
60+ [[nodiscard]] Point operator +(const Point &other) const
6161 {
6262 return {x + other.x , y + other.y };
6363 }
6464
65- Point operator -(const Point &other) const
65+ [[nodiscard]] Point operator -(const Point &other) const
6666 {
6767 return {x - other.x , y - other.y };
6868 }
6969
70- Point operator *(const Point &other) const
70+ [[nodiscard]] Point operator *(const Point &other) const
7171 {
7272 return {x * other.x , y * other.y };
7373 }
@@ -77,18 +77,65 @@ struct Point
7777 return x * other.x + y * other.y ;
7878 }
7979
80- Point operator /(const Point &other) const
80+ [[nodiscard]] Point operator /(const Point &other) const
8181 {
8282 using Math::Floating::is_zero;
8383 if (is_zero (other.x ) || is_zero (other.y )) return Invalid ();
8484 return {x / other.x , y / other.y };
8585 }
8686
87- double operator ^(const Point &p) const
87+ [[nodiscard]] double operator ^(const Point &p) const
8888 {
8989 return x * p.y - y * p.x ;
9090 }
9191
92+ Point &operator +=(const Point &other)
93+ {
94+ x += other.x ;
95+ y += other.y ;
96+ return *this ;
97+ }
98+
99+ Point &operator -=(const Point &other)
100+ {
101+ x -= other.x ;
102+ y -= other.y ;
103+ return *this ;
104+ }
105+
106+ Point &operator *=(double factor)
107+ {
108+ x *= factor;
109+ y *= factor;
110+ return *this ;
111+ }
112+
113+ Point &operator /=(double divisor)
114+ {
115+ if (Math::Floating::is_zero (divisor))
116+ return *this = Invalid ();
117+ x /= divisor;
118+ y /= divisor;
119+ return *this ;
120+ }
121+
122+ Point &operator *=(const Point &other)
123+ {
124+ x *= other.x ;
125+ y *= other.y ;
126+ return *this ;
127+ }
128+
129+ Point &operator /=(const Point &other)
130+ {
131+ using Math::Floating::is_zero;
132+ if (is_zero (other.x ) || is_zero (other.y ))
133+ return *this = Invalid ();
134+ x /= other.x ;
135+ y /= other.y ;
136+ return *this ;
137+ }
138+
92139 [[nodiscard]] Point flip () const { return {y, x}; }
93140
94141 [[nodiscard]] Point flipX () const { return {-x, y}; }
@@ -214,7 +261,7 @@ struct Size : Point
214261 std::min (s1.y , s2.y , less)};
215262 }
216263
217- [[nodiscard]] bool isSquare (double toleranceFactor = 0.0 ) const
264+ [[nodiscard]] bool isSquare (double toleranceFactor) const
218265 {
219266 using Math::Floating::is_zero;
220267 if (is_zero (y)) return false ;
0 commit comments