-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to sum values to all cells within a given shape
- Loading branch information
1 parent
1c90971
commit 759669b
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef WAVEMAP_CORE_UTILS_GEOMETRY_SPHERE_H_ | ||
#define WAVEMAP_CORE_UTILS_GEOMETRY_SPHERE_H_ | ||
|
||
#include <algorithm> | ||
#include <string> | ||
#include <utility> | ||
|
||
#include "wavemap/core/common.h" | ||
#include "wavemap/core/utils/print/eigen.h" | ||
|
||
namespace wavemap { | ||
template <typename PointT> | ||
struct Sphere { | ||
static constexpr int kDim = dim_v<PointT>; | ||
using PointType = PointT; | ||
using ScalarType = typename PointType::Scalar; | ||
|
||
PointType center; | ||
ScalarType radius; | ||
|
||
Sphere() = default; | ||
Sphere(const PointT& center, ScalarType radius) | ||
: center(center), radius(radius) {} | ||
Sphere(PointT&& center, ScalarType radius) | ||
: center(std::move(center)), radius(radius) {} | ||
|
||
operator AABB<PointT>() const { | ||
return AABB<PointT>(center.array() - radius, center.array() + radius); | ||
} | ||
|
||
bool contains(const PointType& point) const { | ||
return (point - center).squaredNorm() <= radius * radius; | ||
} | ||
|
||
std::string toString() const { | ||
std::stringstream ss; | ||
ss << "[center =" << print::eigen::oneLine(center) | ||
<< ", radius = " << radius << "]"; | ||
return ss.str(); | ||
} | ||
}; | ||
} // namespace wavemap | ||
|
||
#endif // WAVEMAP_CORE_UTILS_GEOMETRY_SPHERE_H_ |