Parasol Planning Library (PPL)
NSphere.h
Go to the documentation of this file.
1 #ifndef N_SPHERE_H_
2 #define N_SPHERE_H_
3 
4 #include <cstddef>
5 #include <iostream>
6 #include <limits>
7 #include <vector>
8 
9 
18 class NSphere {
19 
20  public:
21 
24 
28  explicit NSphere(const size_t _n,
29  const double _r = std::numeric_limits<double>::max());
30 
35  explicit NSphere(const std::vector<double>& _center,
36  const double _r = std::numeric_limits<double>::max());
37 
38  virtual ~NSphere() noexcept;
39 
43 
45  size_t GetDimension() const noexcept;
46 
49  void SetCenter(const std::vector<double>& _c) noexcept;
50 
52  const std::vector<double>& GetCenter() const noexcept;
53 
55  double GetRadius() const noexcept;
56 
58  void SetRadius(const double _r) noexcept;
59 
62  void Translate(const std::vector<double>& _v) noexcept;
63 
65  double GetVolume() const noexcept;
66 
72 
76  bool Contains(const std::vector<double>& _p) const noexcept;
77 
83  double Clearance(std::vector<double> _p) const noexcept;
84 
88  std::vector<double> ClearancePoint(std::vector<double> _p) const noexcept;
89 
93 
96  std::vector<double> Sample() const;
97 
99 
100  private:
101 
104 
105  std::vector<double> m_center;
106  double m_radius;
107 
109 
110  friend std::istream& operator>>(std::istream& _is, NSphere& _sphere);
111 };
112 
113 /*----------------------------------- I/O ------------------------------------*/
114 
115 std::istream&
116 operator>>(std::istream& _is, NSphere& _sphere);
117 
118 std::ostream&
119 operator<<(std::ostream& _os, const NSphere& _sphere);
120 
121 /*----------------------------------------------------------------------------*/
122 
123 #endif
Definition: NSphere.h:18
double GetRadius() const noexcept
Get the radius.
Definition: NSphere.cpp:50
void SetCenter(const std::vector< double > &_c) noexcept
Definition: NSphere.cpp:34
NSphere(const size_t _n, const double _r=std::numeric_limits< double >::max())
Definition: NSphere.cpp:12
double GetVolume() const noexcept
Compute the (hyper)volume or Lebesgue measure.
Definition: NSphere.cpp:73
virtual ~NSphere() noexcept
const std::vector< double > & GetCenter() const noexcept
Get the center point.
Definition: NSphere.cpp:43
std::vector< double > Sample() const
Definition: NSphere.cpp:131
double Clearance(std::vector< double > _p) const noexcept
Definition: NSphere.cpp:91
size_t GetDimension() const noexcept
Get the dimension of this sphere.
Definition: NSphere.cpp:27
std::vector< double > ClearancePoint(std::vector< double > _p) const noexcept
Definition: NSphere.cpp:106
void Translate(const std::vector< double > &_v) noexcept
Definition: NSphere.cpp:64
bool Contains(const std::vector< double > &_p) const noexcept
Definition: NSphere.cpp:84
void SetRadius(const double _r) noexcept
Set the radius.
Definition: NSphere.cpp:57