42 U
interpolate(
const U & v0,
const U & v1,
const U & v2 )
const
43 {
return ( 1 -
a -
b ) * v0 +
a * v1 +
b * v2; }
63 return s << tp.
a <<
' ' << tp.
b;
83 const Vector3<T> * v[3] = { &v0, &v1, &v2 };
84 const auto & org = *v[( edge + 1 ) % 3];
85 const auto d = *v[( edge + 2 ) % 3] - org;
86 const T dSq = d.lengthSq();
87 const T s = dSq > 0 ? std::clamp(
dot( p - org, d ) / dSq, T(0), T(1) ) : T(0);
105 const auto n =
cross( v1, v2 );
106 const T nSq = n.lengthSq();
113 const T inv = 1 / nSq;
114 a = std::clamp( inv *
dot( n,
cross( p, v2 ) ), T(0), T(1) );
115 b = std::clamp( inv *
dot( n,
cross( v1, p ) ), T(0), T(1) - a );
121 if ( a <= eps && b <= eps )
123 if ( 1 - a - b <= eps )
136 if ( 1 - a - b <= eps )
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:33
TriPoint lnext() const
represents the same point relative to next edge in the same triangle
Definition MRTriPoint.h:46
constexpr TriPoint() noexcept
Definition MRTriPoint.h:27
static constexpr auto eps
Definition MRSegmPoint.h:20
constexpr TriPoint(T a, T b) noexcept
Definition MRTriPoint.h:29
auto dot(const Matrix2< T > &a, const Matrix2< T > &b) -> decltype(dot(a.x, b.x))
double-dot product: x = a : b
Definition MRMatrix2.h:142
U interpolate(const U &v0, const U &v1, const U &v2) const
given three values in three vertices, computes interpolated value at this barycentric coordinates
Definition MRTriPoint.h:42
friend std::ostream & operator<<(std::ostream &s, const TriPoint &tp)
Definition MRTriPoint.h:61
constexpr int inVertex() const
returns [0,2] if the point is in a vertex or -1 otherwise
TriPoint(const Vector3< T > &p, const Vector3< T > &v1, const Vector3< T > &v2, int edge=-1)
TriPoint(const Vector3< T > &p, const Vector3< T > &v0, const Vector3< T > &v1, const Vector3< T > &v2, int edge=-1)
Definition MRTriPoint.h:35
static constexpr auto eps
Definition MRTriPoint.h:25
T b
b in [0,1], b=0 => point is on [v0,v1] edge, b=1 => point is in v2
Definition MRTriPoint.h:23
T a
a in [0,1], a=0 => point is on [v2,v0] edge, a=1 => point is in v1
Definition MRTriPoint.h:22
constexpr int onEdge() const
friend std::istream & operator>>(std::istream &s, TriPoint &tp)
Definition MRTriPoint.h:66
constexpr bool operator==(const TriPoint &rhs) const =default
returns true if two points have equal (a,b) representation
TriPoint(NoInit) noexcept
Definition MRTriPoint.h:28
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRMeshFwd.h:102
auto cross(const Vector2< T > &a, const Vector2< T > &b) -> decltype(a.x *b.x)
cross product
Definition MRVector2.h:160
Definition MRVector3.h:33