UtilsLite
Utilities for C++ programming
Loading...
Searching...
No Matches
Utils::Point2D< Real > Class Template Reference

A class representing a 2D point in space. More...

#include <Utils_GG2D.hh>

Inheritance diagram for Utils::Point2D< Real >:

Public Member Functions

 Point2D ()=default
 
Real x () const
 
Real y () const
 
P2D const & to_eigen () const
 
P2D & to_eigen ()
 

Detailed Description

template<typename Real>
class Utils::Point2D< Real >

A class representing a 2D point in space.

The Point2D class extends the Eigen::Matrix class to provide a convenient representation of a point in a two-dimensional space. It encapsulates operations related to 2D points, allowing easy access to the x and y coordinates. This class leverages the Eigen library for efficient matrix and vector computations.

Template Parameters
RealThe data type used for the point coordinates, typically a floating-point type (e.g., float, double).

Features

  • Coordinate Access: Provides methods to access the x and y coordinates of the point easily.
  • Eigen Compatibility: Supports seamless conversion to and from Eigen's matrix representation, allowing users to leverage Eigen's functionalities directly with the Point2D class.

Methods

  • Default Constructor:
    • Initializes a Point2D object with default values.
  • Real x() const:
    • Returns the x-coordinate of the point.
  • Real y() const:
    • Returns the y-coordinate of the point.
  • P2D const & to_eigen() const:
    • Returns a constant reference to the underlying Eigen matrix representation of the point.
  • P2D & to_eigen():
    • Returns a reference to the underlying Eigen matrix representation of the point, allowing for modifications.

Usage

#include <Eigen/Dense>
// Create a Point2D object
// Set coordinates
point.to_eigen() << 3.0, 4.0;
// Access coordinates
double x = point.x(); // x = 3.0
double y = point.y(); // y = 4.0
// Convert to Eigen matrix
Eigen::Matrix<double, 2, 1> eigen_point = point.to_eigen();
Real x() const
Definition Utils_GG2D.hh:103
Point2D()=default
P2D const & to_eigen() const
Definition Utils_GG2D.hh:106
Real y() const
Definition Utils_GG2D.hh:104

Constructor & Destructor Documentation

◆ Point2D()

template<typename Real>
Utils::Point2D< Real >::Point2D ( )
default

Member Function Documentation

◆ to_eigen() [1/2]

template<typename Real>
P2D & Utils::Point2D< Real >::to_eigen ( )
inline

◆ to_eigen() [2/2]

template<typename Real>
P2D const & Utils::Point2D< Real >::to_eigen ( ) const
inline

◆ x()

template<typename Real>
Real Utils::Point2D< Real >::x ( ) const
inline

◆ y()

template<typename Real>
Real Utils::Point2D< Real >::y ( ) const
inline

The documentation for this class was generated from the following file: