// ellipsoid.h // // Copyright (C) 2002-2008, Chris Laurel // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. #pragma once #include namespace celmath { template class Ellipsoid { public: /*! Default Ellipsoid constructor. Create a unit sphere centered * at the origin. */ Ellipsoid() : center(Eigen::Matrix::Zero()), axes(Eigen::Matrix::Ones()) { } /*! Created an ellipsoid with the specified semiaxes, centered * at the origin. */ Ellipsoid(const Eigen::Matrix& _axes) : center(Eigen::Matrix::Zero()), axes(_axes) { } /*! Create an ellipsoid with the specified center and semiaxes. */ Ellipsoid(const Eigen::Matrix& _center, const Eigen::Matrix& _axes) : center(_center), axes(_axes) { } /*! Test whether the point p lies inside the ellipsoid. */ bool contains(const Eigen::Matrix& p) const { Eigen::Matrix v = p - center; v = v.cwise() / axes; return v * v <= static_cast(1); } public: Eigen::Matrix center; Eigen::Matrix axes; }; using Ellipsoidf = Ellipsoid; using Ellipsoidd = Ellipsoid; } // namespace celmath