25#ifndef UTILS_GG2D_dot_HH
26#define UTILS_GG2D_dot_HH
97 template <
typename Real>
98 class Point2D :
public Eigen::Matrix<Real,2,1> {
99 using P2D = Eigen::Matrix<Real,2,1>;
103 Real
x()
const {
return this->coeff(0); }
104 Real
y()
const {
return this->coeff(1); }
106 P2D
const &
to_eigen()
const {
return *
static_cast<P2D
const *
>(
this); }
107 P2D &
to_eigen() {
return *
static_cast<P2D*
>(
this); }
211 template <
typename Real>
265 setup( Real
const A[], Real
const B[] ) {
266 m_Pa.coeffRef(0) = A[0]; m_Pa.coeffRef(1) = A[1];
267 m_Pb.coeffRef(0) = B[0]; m_Pb.coeffRef(1) = B[1];
367 template <
typename Real>
403 template <
typename Real>
440 template <
typename Real>
441 class Polygon2D :
public Eigen::Matrix<Real, 2, Eigen::Dynamic> {
456 #ifndef UTILS_OS_WINDOWS
457 extern template class Point2D<float>;
458 extern template class Point2D<double>;
460 extern template class Segment2D<float>;
461 extern template class Segment2D<double>;
463 extern template class Box2D<float>;
464 extern template class Box2D<double>;
466 extern template class Triangle2D<float>;
467 extern template class Triangle2D<double>;
469 extern template class Polygon2D<float>;
470 extern template class Polygon2D<double>;
Box2D()
Default constructor for the bounding box.
Definition Utils_GG2D.hh:379
A class representing a 2D point in space.
Definition Utils_GG2D.hh:98
Real x() const
Definition Utils_GG2D.hh:103
P2D const & to_eigen() const
Definition Utils_GG2D.hh:106
Real y() const
Definition Utils_GG2D.hh:104
P2D & to_eigen()
Definition Utils_GG2D.hh:107
Polygon2D()
Default constructor for the polygon.
Definition Utils_GG2D.hh:449
A class representing a 2D line segment defined by two endpoints.
Definition Utils_GG2D.hh:212
Segment2D(Segment2D< Real > const &S)
Copy constructor for the segment.
Definition Utils_GG2D.hh:230
Segment2D(Point2D< Real > const &A, Point2D< Real > const &B)
Constructor to create a segment from two points.
Definition Utils_GG2D.hh:241
bool projection(Point2D< Real > const &P, Real &s) const
Projects a point onto the segment.
Definition Utils_GG2D.cc:57
void setup(Real const A[], Real const B[])
Setup the endpoints of the segment using arrays.
Definition Utils_GG2D.hh:265
Point2D< Real > const & Pa() const
Returns the first endpoint of the segment.
Definition Utils_GG2D.hh:317
bool intersect(Segment2D< Real > const &S, Real &s, Real &t) const
Checks for intersection with another segment.
Definition Utils_GG2D.cc:125
Point2D< Real > const & Pb() const
Returns the second endpoint of the segment.
Definition Utils_GG2D.hh:325
Segment2D()=default
Default constructor for the segment.
void bbox(Point2D< Real > &pmin, Point2D< Real > &pmax) const
Computes the bounding box of the segment.
Definition Utils_GG2D.cc:118
Point2D< Real > eval(Real &s) const
Evaluates the segment at a given parameter s.
Definition Utils_GG2D.cc:97
void setup(Point2D< Real > const &A, Point2D< Real > const &B)
Setup the endpoints of the segment using Point2D objects.
Definition Utils_GG2D.hh:253
Triangle2D()
Default constructor for the triangle.
Definition Utils_GG2D.hh:416
Definition SystemUtils.cc:39