@@ -130,49 +130,49 @@ struct Vector2
130130
131131
132132 // / squared distance between two points, which is faster to compute than just distance
133- [[nodiscard]] T distanceSq ( const Vector2& a, const Vector2& b )
133+ [[nodiscard]] friend T distanceSq ( const Vector2& a, const Vector2& b )
134134 {
135135 return ( a - b ).lengthSq ();
136136 }
137137
138138 // / distance between two points, better use distanceSq for higher performance
139- [[nodiscard]] T distance ( const Vector2& a, const Vector2& b ) MR_REQUIRES_IF_SUPPORTED( std::floating_point<T> )
139+ [[nodiscard]] friend T distance ( const Vector2& a, const Vector2& b ) MR_REQUIRES_IF_SUPPORTED( std::floating_point<T> )
140140 {
141141 return ( a - b ).length ();
142142 }
143143
144144 // / cross product
145- [[nodiscard]] T cross ( const Vector2& a, const Vector2& b )
145+ [[nodiscard]] friend T cross ( const Vector2& a, const Vector2& b )
146146 {
147147 return a.x * b.y - a.y * b.x ;
148148 }
149149
150150 // / dot product
151- [[nodiscard]] auto dot ( const Vector2& a, const Vector2& b ) -> decltype( a.x * b.x )
151+ [[nodiscard]] friend auto dot ( const Vector2& a, const Vector2& b ) -> decltype( a.x * b.x )
152152 {
153153 return a.x * b.x + a.y * b.y ;
154154 }
155155
156156 // / squared length
157- [[nodiscard]] T sqr ( const Vector2& a )
157+ [[nodiscard]] friend T sqr ( const Vector2& a )
158158 {
159159 return a.lengthSq ();
160160 }
161161
162162 // / per component multiplication
163- [[nodiscard]] Vector2 mult ( const Vector2& a, const Vector2& b )
163+ [[nodiscard]] friend Vector2 mult ( const Vector2& a, const Vector2& b )
164164 {
165165 return { a.x * b.x ,a.y * b.y };
166166 }
167167
168168 // / per component division
169- [[nodiscard]] Vector2 div ( const Vector2& a, const Vector2& b )
169+ [[nodiscard]] friend Vector2 div ( const Vector2& a, const Vector2& b )
170170 {
171171 return { a.x / b.x , a.y / b.y };
172172 }
173173
174174 // / angle in radians between two vectors
175- [[nodiscard]] T angle ( const Vector2& a, const Vector2& b ) MR_REQUIRES_IF_SUPPORTED( std::floating_point<T> )
175+ [[nodiscard]] friend T angle ( const Vector2& a, const Vector2& b ) MR_REQUIRES_IF_SUPPORTED( std::floating_point<T> )
176176 {
177177 return std::atan2 ( std::abs ( cross ( a, b ) ), dot ( a, b ) );
178178 // this version is slower and less precise
0 commit comments