-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* changed cmakelists and ellipse class * package is successfully imported by other packages * Committing clang-format changes --------- Co-authored-by: Clang Robot <[email protected]>
- Loading branch information
1 parent
96c78a2
commit e6d7487
Showing
11 changed files
with
175 additions
and
68 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
96 changes: 96 additions & 0 deletions
96
vortex-filtering/include/vortex_filtering/utils/ellipse.hpp
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,96 @@ | ||
/** | ||
* @file ellipse.hpp | ||
* @author Eirik Kolås | ||
* @brief Ellipse class and ellipsoid class | ||
* @version 0.1 | ||
* @date 2024-02-29 | ||
* | ||
* @copyright Copyright (c) 2024 | ||
* | ||
*/ | ||
|
||
#pragma once | ||
#include <Eigen/Dense> | ||
#include <vortex_filtering/probability/multi_var_gauss.hpp> | ||
|
||
namespace vortex { | ||
namespace utils { | ||
|
||
/** Class for representing an ellipse. | ||
* | ||
*/ | ||
class Ellipse { | ||
public: | ||
/** Construct a new Ellipse object | ||
* @param center | ||
* @param a | ||
* @param b | ||
* @param angle | ||
*/ | ||
Ellipse(const Eigen::Vector2d ¢er, double a, double b, double angle); | ||
|
||
/** Construct a new Ellipse object from a Gaussian | ||
* @param gauss | ||
* @param scale_factor | ||
*/ | ||
Ellipse(const vortex::prob::Gauss2d &gauss, double scale_factor = 1.0); | ||
|
||
/** Get the center of the ellipse | ||
* @return Eigen::Vector2d | ||
*/ | ||
Eigen::Vector2d center() const; | ||
|
||
/** Get x coordinate of the center | ||
* @return double | ||
*/ | ||
double x() const; | ||
|
||
/** Get y coordinate of the center | ||
* @return double | ||
*/ | ||
double y() const; | ||
|
||
/** Get the a parameter of the ellipse | ||
* @return double | ||
*/ | ||
double a() const; | ||
|
||
/** Get the b parameter of the ellipse | ||
* @return double | ||
*/ | ||
double b() const; | ||
|
||
/** Get the major axis length of the ellipse | ||
* @return double | ||
*/ | ||
double major_axis() const; | ||
|
||
/** Get the minor axis length of the ellipse | ||
* @return double | ||
*/ | ||
double minor_axis() const; | ||
|
||
/** Get the axes lengths of the ellipse | ||
* @return Eigen::Vector2d | ||
*/ | ||
Eigen::Vector2d axes() const; | ||
|
||
/** Get the angle of the ellipse with respect to the x-axis | ||
* @return double | ||
*/ | ||
double angle_rad() const; | ||
|
||
/** Get the angle in degrees | ||
* @return double | ||
*/ | ||
double angle_deg() const; | ||
|
||
private: | ||
Eigen::Vector2d center_; | ||
double a_; | ||
double b_; | ||
double angle_; | ||
}; | ||
|
||
} // namespace utils | ||
} // namespace vortex |
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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
#include <vortex_filtering/utils/ellipse.hpp> | ||
|
||
namespace vortex { | ||
namespace utils { | ||
|
||
Ellipse::Ellipse(const Eigen::Vector2d ¢er, double a, double b, double angle) : center_(center), a_(a), b_(b), angle_(angle) {} | ||
|
||
Ellipse::Ellipse(const vortex::prob::Gauss2d &gauss, double scale_factor) | ||
{ | ||
Eigen::SelfAdjointEigenSolver<Eigen::Matrix2d> eigenSolver(gauss.cov()); | ||
Eigen::Vector2d eigenValues = eigenSolver.eigenvalues(); | ||
Eigen::Matrix2d eigenVectors = eigenSolver.eigenvectors(); | ||
|
||
a_ = scale_factor * sqrt(eigenValues(1)); | ||
b_ = scale_factor * sqrt(eigenValues(0)); | ||
angle_ = atan2(eigenVectors(1, 1), eigenVectors(0, 1)); | ||
center_ = gauss.mean(); | ||
} | ||
|
||
Eigen::Vector2d Ellipse::center() const { return center_; } | ||
double Ellipse::x() const { return center_(0); } | ||
double Ellipse::y() const { return center_(1); } | ||
double Ellipse::a() const { return a_; } | ||
double Ellipse::b() const { return b_; } | ||
double Ellipse::major_axis() const { return 2 * a_; } | ||
double Ellipse::minor_axis() const { return 2 * b_; } | ||
Eigen::Vector2d Ellipse::axes() const { return Eigen::Vector2d(2 * a_, 2 * b_); } | ||
double Ellipse::angle_rad() const { return angle_; } | ||
double Ellipse::angle_deg() const { return angle_ * 180 / M_PI; } | ||
|
||
} // namespace utils | ||
} // namespace vortex |
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,10 @@ | ||
#include <vortex_filtering/utils/ellipse.hpp> | ||
#include <vortex_filtering/utils/plotting.hpp> | ||
|
||
namespace vortex { | ||
namespace plotting { | ||
|
||
utils::Ellipse gauss_to_ellipse(const vortex::prob::Gauss2d &gauss, double scale_factor) { return utils::Ellipse(gauss, scale_factor); } | ||
|
||
} // namespace plotting | ||
} // namespace vortex |
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