12 using T =
typename V::ValueType;
15 [[nodiscard]]
constexpr LineSegm() noexcept = default;
16 [[nodiscard]] constexpr
LineSegm( const V &
a, const V &
b ) noexcept :
a(
a ),
b(
b ) { }
20 [[nodiscard]] V
dir()
const {
return b -
a; }
24 [[nodiscard]]
T length()
const {
return dir().length(); }
26 [[nodiscard]] V
operator()(
T param )
const {
return ( 1 - param ) *
a + param *
b; }
32 return a.
a == b.
a && a.
b == b.
b;
39 auto dt = dot( pt - l.
a, ab );
40 auto abLengthSq = ab.lengthSq();
43 if ( dt >= abLengthSq )
45 auto ratio = dt / abLengthSq;
46 return l.
a * ( 1 - ratio ) + l.
b * ratio;
53 typename V::ValueType * xPos =
nullptr,
typename V::ValueType * yPos =
nullptr )
56 const auto xvec = x.
b - x.
a;
57 const auto ya = cross( xvec, y.
a - x.
a );
58 const auto yb = cross( xvec, y.
b - x.
a );
63 const auto yvec = y.
b - y.
a;
64 const auto xa = cross( yvec, x.
a - y.
a );
65 const auto xb = cross( yvec, x.
b - y.
a );
72 const auto denom = xa - xb;
73 *xPos = denom == 0 ? 0 : xa / denom;
78 const auto denom = ya - yb;
79 *yPos = denom == 0 ? 0 : ya / denom;
88 typename V::ValueType * xPos =
nullptr,
typename V::ValueType * yPos =
nullptr )
91 const auto xa = cross( y.
d, x.
a - y.
p );
92 const auto xb = cross( y.
d, x.
b - y.
p );
99 const auto denom = xa - xb;
100 *xPos = denom == 0 ? 0 : xa / denom;
105 const auto xvec = x.
b - x.
a;
106 const auto ya = cross( xvec, y.
p - x.
a );
107 const auto yb = cross( xvec, y.
p + y.
d - x.
a );
109 const auto denom = ya - yb;
110 *yPos = denom == 0 ? 0 : ya / denom;
MRMESH_API bool operator==(const BitSet &a, const BitSet &b)
compare that two bit sets have the same set bits (they can be equal even if sizes are distinct but la...
Definition MRCameraOrientationPlugin.h:7
V closestPointOnLineSegm(const V &pt, const LineSegm< V > &l)
Definition MRLineSegm.h:36
bool doSegmentLineIntersect(const LineSegm< V > &x, const Line< V > &y, typename V::ValueType *xPos=nullptr, typename V::ValueType *yPos=nullptr)
Definition MRLineSegm.h:87
bool doSegmentsIntersect(const LineSegm< V > &x, const LineSegm< V > &y, typename V::ValueType *xPos=nullptr, typename V::ValueType *yPos=nullptr)
Definition MRLineSegm.h:52
Definition MRLineSegm.h:11
constexpr LineSegm() noexcept=default
T length() const
returns the length of this line segment
Definition MRLineSegm.h:24
typename V::ValueType T
Definition MRLineSegm.h:12
V a
Definition MRLineSegm.h:13
constexpr LineSegm(const LineSegm< U > &p) noexcept
Definition MRLineSegm.h:18
T lengthSq() const
returns squared length of this line segment
Definition MRLineSegm.h:22
V operator()(T param) const
returns point on the line, where param=0 returns a and param=1 returns b
Definition MRLineSegm.h:26
V dir() const
returns directional vector of the line
Definition MRLineSegm.h:20
V b
Definition MRLineSegm.h:13
V d
Definition MRLine.h:15
V p
Definition MRLine.h:15