- 3.0.2 core module.
Ellipsoid.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 namespace ct {
9 namespace core {
10 namespace tpl {
11 
12 
13 template <typename SCALAR>
14 class Ellipsoid
15 {
16 public:
17  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
18 
19  typedef Eigen::Matrix<SCALAR, 3, 1> Vector3s;
20  typedef Eigen::Matrix<SCALAR, 3, 3> Matrix3s;
21  typedef Eigen::Quaternion<SCALAR> Quaternions;
22 
30  Ellipsoid(const Vector3s& x0, const Matrix3s& A, const Matrix3s& S) : x0_(x0), A_(A), S_(S) {}
31  void setFromQuaterion(const Quaternions& quat) { S_ = Matrix3s(quat); }
40  SCALAR insideEllipsoid(const Vector3s& x)
41  {
42  return (x - x0_).transpose() * S_ * A_.transpose() * A_ * S_.transpose() * (x - x0_) - SCALAR(1.0);
43  }
44 
45  const Vector3s& x0() const { return x0_; }
46  Vector3s& x0() { return x0_; }
47  const Matrix3s& A() const { return A_; }
48  Matrix3s& A() { return A_; }
49  const Matrix3s& S() const { return S_; }
50  Matrix3s& S() { return S_; }
51 private:
52  Vector3s x0_; // The center of the ellipsoid
53  Matrix3s A_; // The matrix of halfaxes
54  Matrix3s S_; // The orientation of the ellipsoid
55 };
56 }
57 
59 
60 } // namespace optcon
61 } // namespace ct
void setFromQuaterion(const Quaternions &quat)
Definition: Ellipsoid.h:31
Definition: Ellipsoid.h:14
SCALAR insideEllipsoid(const Vector3s &x)
Returns a value =< 1 if point x is inside the ellpsoid, > 1 otherwise.
Definition: Ellipsoid.h:40
const Vector3s & x0() const
Definition: Ellipsoid.h:45
const Matrix3s & S() const
Definition: Ellipsoid.h:49
Eigen::Quaternion< SCALAR > Quaternions
Definition: Ellipsoid.h:21
CppAD::AD< CppAD::cg::CG< double > > SCALAR
Eigen::Matrix< SCALAR, 3, 3 > Matrix3s
Definition: Ellipsoid.h:20
Ellipsoid(const Vector3s &x0, const Matrix3s &A, const Matrix3s &S)
Default constructor.
Definition: Ellipsoid.h:30
Vector3s & x0()
Definition: Ellipsoid.h:46
const Matrix3s & A() const
Definition: Ellipsoid.h:47
Matrix3s & S()
Definition: Ellipsoid.h:50
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Eigen::Matrix< SCALAR, 3, 1 > Vector3s
Definition: Ellipsoid.h:19
Matrix3s & A()
Definition: Ellipsoid.h:48