//////////////////////////////////////////////////////////////////// // Line.h // // Copyright 2023 cDc@seacave // Distributed under the Boost Software License, Version 1.0 // (See http://www.boost.org/LICENSE_1_0.txt) #ifndef __SEACAVE_LINE_H__ #define __SEACAVE_LINE_H__ // I N C L U D E S ///////////////////////////////////////////////// // D E F I N E S /////////////////////////////////////////////////// namespace SEACAVE { // S T R U C T S /////////////////////////////////////////////////// // Generic line class represented as two points template class TLine { STATIC_ASSERT(DIMS > 1 && DIMS <= 3); public: typedef Eigen::Matrix VECTOR; typedef Eigen::Matrix POINT; typedef SEACAVE::TAABB AABB; typedef SEACAVE::TRay RAY; enum { numScalar = (2*DIMS) }; enum { numParams = numScalar-1 }; POINT pt1, pt2; // line description //--------------------------------------- inline TLine() {} inline TLine(const POINT& pt1, const POINT& pt2); template inline TLine(const TLine&); inline void Set(const POINT& pt1, const POINT& pt2); int Optimize(const POINT*, size_t, int maxIters=100); template int Optimize(const POINT*, size_t, const RobustNormFunctor& robust, int maxIters=100); inline TYPE GetLength() const; inline TYPE GetLengthSq() const; inline POINT GetCenter() const; inline VECTOR GetDir() const; inline VECTOR GetNormDir() const; inline RAY GetRay() const; inline bool IsSame(const TLine&, TYPE th) const; bool Intersects(const AABB& aabb) const; bool Intersects(const AABB& aabb, TYPE& t) const; inline TYPE DistanceSq(const POINT&) const; inline TYPE Distance(const POINT&) const; inline TYPE Classify(const POINT&) const; inline POINT ProjectPoint(const POINT&) const; inline TYPE& operator [] (BYTE i) { ASSERT(i void serialize(Archive& ar, const unsigned int /*version*/) { ar & pt1; ar & pt2; } #endif }; // class TLine /*----------------------------------------------------------------*/ template struct FitLineOnline : FitPlaneOnline { template TPoint3 GetLine(TLine& line) const; }; /*----------------------------------------------------------------*/ #include "Line.inl" /*----------------------------------------------------------------*/ } // namespace SEACAVE #endif // __SEACAVE_LINE_H__