Skip to content

Commit bddacdb

Browse files
Try again.
1 parent 68951b6 commit bddacdb

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

source/MRMesh/MRVector2.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

source/MRMesh/MRVector4.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,37 +124,37 @@ struct Vector4
124124

125125

126126
/// squared distance between two points, which is faster to compute than just distance
127-
[[nodiscard]] T distanceSq( const Vector4& a, const Vector4& b )
127+
[[nodiscard]] friend T distanceSq( const Vector4& a, const Vector4& b )
128128
{
129129
return ( a - b ).lengthSq();
130130
}
131131

132132
/// distance between two points, better use distanceSq for higher performance
133-
[[nodiscard]] T distance( const Vector4& a, const Vector4& b ) MR_REQUIRES_IF_SUPPORTED( std::floating_point )
133+
[[nodiscard]] friend T distance( const Vector4& a, const Vector4& b ) MR_REQUIRES_IF_SUPPORTED( std::floating_point )
134134
{
135135
return ( a - b ).length();
136136
}
137137

138138
/// dot product
139-
[[nodiscard]] auto dot( const Vector4& a, const Vector4& b ) -> decltype( a.x * b.x )
139+
[[nodiscard]] friend auto dot( const Vector4& a, const Vector4& b ) -> decltype( a.x * b.x )
140140
{
141141
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
142142
}
143143

144144
/// squared length
145-
[[nodiscard]] T sqr( const Vector4& a )
145+
[[nodiscard]] friend T sqr( const Vector4& a )
146146
{
147147
return a.lengthSq();
148148
}
149149

150150
/// per component multiplication
151-
[[nodiscard]] Vector4 mult( const Vector4& a, const Vector4& b )
151+
[[nodiscard]] friend Vector4 mult( const Vector4& a, const Vector4& b )
152152
{
153153
return { a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w };
154154
}
155155

156156
/// per component division
157-
[[nodiscard]] Vector4 div( const Vector4& a, const Vector4& b )
157+
[[nodiscard]] friend Vector4 div( const Vector4& a, const Vector4& b )
158158
{
159159
return { a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w };
160160
}

0 commit comments

Comments
 (0)