18 const auto ab = ( b - a ).lengthSq();
19 const auto ca = ( a - c ).lengthSq();
20 const auto bc = ( c - b ).lengthSq();
27 const auto f = cross( b - a, c - a ).lengthSq();
29 return std::numeric_limits<T>::infinity();
30 return ab * ca * bc / f;
45 const auto xabSq = cross( a, b ).
lengthSq();
55 const auto ab = dot( a, b );
56 return ( bb * ( aa - ab ) * a + aa * ( bb - ab ) * b ) / ( 2 * xabSq );
73 const auto rr =
sqr( radius );
78 const auto x = std::sqrt( rr - circRadSq );
79 const auto xn = x *
normal( a, b, c );
81 centerPos = circCenter + xn;
82 centerNeg = circCenter - xn;
92 const auto ab = ( b - a ).
length();
93 const auto ca = ( a - c ).
length();
94 const auto bc = ( c - b ).
length();
95 if ( ab <= 0 || ca <= 0 || bc <= 0 )
97 const auto f = cross( b - a, c - a ).length();
98 return f * std::min( { ab, ca, bc } ) / ( ab * ca * bc );
112 const auto bc = ( c - b ).
length();
113 const auto ca = ( a - c ).
length();
114 const auto ab = ( b - a ).
length();
115 auto halfPerimeter = ( bc + ca + ab ) / 2;
116 auto den = 8 * ( halfPerimeter - bc ) * ( halfPerimeter - ca ) * ( halfPerimeter - ab );
118 return std::numeric_limits<T>::max();
120 return bc * ca * ab / den;
127 return cross( t[1] - t[0], t[2] - t[0] );
134 return cross( q - p, r - p );
169 return std::abs( cross( q - p, r - p ) );
183 const auto c = ( t[0] + t[1] + t[2] ) / T(3);
186 for (
int i = 0; i < 3; ++i )
188 const auto sq = ( t[i] - c ).lengthSq();
189 if ( longestSq >= sq )
194 const auto d = ( t[longest] - c ).normalized();
198 for (
int i = 0; i < 3; ++i )
199 res[i] = c + d * dot( d, t[i] - c );
208 const auto c = ( t[0] + t[1] + t[2] ) / T(3);
210 for (
int i = 0; i < 3; ++i )
211 res[i] = t[i] - n * dot( n, t[i] - c );
227 return dot( edgeDir, cross( leftNorm, rightNorm ) );
238 return dot( leftNorm, rightNorm );
252 return std::atan2( sin, cos );
268 const auto aa =
sqr( a );
269 const auto y = ( aa -
sqr( b ) +
sqr( c ) ) / ( 2 * c );
270 const auto yy =
sqr( y );
273 const auto x = std::sqrt( aa - yy );
290 auto y = ( p->x * p1->y - p1->x * p->y ) / ( p->x - p1->x );
291 if ( y < 0 || y > c )
293 return ( *p - *p1 ).length();
length
Definition MRObjectDimensionsEnum.h:14
T triangleAspectRatio(const Vector3< T > &a, const Vector3< T > &b, const Vector3< T > &c)
Definition MRTriMath.h:110
T dihedralAngle(const Vector3< T > &leftNorm, const Vector3< T > &rightNorm, const Vector3< T > &edgeVec)
Definition MRTriMath.h:248
T dihedralAngleSin(const Vector3< T > &leftNorm, const Vector3< T > &rightNorm, const Vector3< T > &edgeVec)
Definition MRTriMath.h:224
T circumcircleDiameterSq(const Vector3< T > &a, const Vector3< T > &b, const Vector3< T > &c)
Definition MRTriMath.h:16
T dihedralAngleCos(const Vector3< T > &leftNorm, const Vector3< T > &rightNorm)
Definition MRTriMath.h:236
T circumcircleDiameter(const Vector3< T > &a, const Vector3< T > &b, const Vector3< T > &c)
Definition MRTriMath.h:36
T minTriangleAngleSin(const Vector3< T > &a, const Vector3< T > &b, const Vector3< T > &c)
Definition MRTriMath.h:90
Definition MRCameraOrientationPlugin.h:8
constexpr T sqr(T x) noexcept
Definition MRMesh/MRMeshFwd.h:600
Vector3< T > circumcircleCenter(const Vector3< T > &a, const Vector3< T > &b)
Computes the center of the the triangle's 0AB circumcircle.
Definition MRTriMath.h:43
std::optional< T > quadrangleOtherDiagonal(T a, T b, T c, T a1, T b1)
Definition MRTriMath.h:280
Triangle3< T > makeDegenerate(const Triangle3< T > &t)
make degenerate triangle (all 3 points on a line) that maximally resembles the input one and has the ...
Definition MRTriMath.h:181
Triangle3< T > triangleWithNormal(const Triangle3< T > &t, const Vector3< T > &n)
Definition MRTriMath.h:206
T dblArea(const Vector3< T > &p, const Vector3< T > &q, const Vector3< T > &r)
computes twice the area of given triangle
Definition MRTriMath.h:153
bool circumballCenters(const Vector3< T > &a, const Vector3< T > &b, const Vector3< T > &c, T radius, Vector3< T > ¢erPos, Vector3< T > ¢erNeg)
Definition MRTriMath.h:69
Vector3< T > dirDblArea(const Triangle3< T > &t)
computes directed double area of given triangle
Definition MRTriMath.h:125
T minTriangleAngle(const Vector3< T > &a, const Vector3< T > &b, const Vector3< T > &c)
Definition MRTriMath.h:102
T area(const Vector3< T > &p, const Vector3< T > &q, const Vector3< T > &r)
computes twice the area of given triangle
Definition MRTriMath.h:160
std::optional< Vector2< T > > posFromTriEdgeLengths(T a, T b, T c)
Definition MRTriMath.h:259
T dblAreaSq(const Vector3< T > &p, const Vector3< T > &q, const Vector3< T > &r)
computes the square of double area of given triangle
Definition MRTriMath.h:146
Definition MRVector2.h:18
Definition MRMesh/MRVector3.h:19
Vector3 normalized() const MR_REQUIRES_IF_SUPPORTED(std
Definition MRMesh/MRVector3.h:55
T lengthSq() const
Definition MRMesh/MRVector3.h:46