diff --git a/Framework/Geometry/QuantityVector.h b/Framework/Geometry/QuantityVector.h index c874f2277768231a2bef48fce9d5cee28f8d5f2f..a4cab185d9d56198cc6d936523962cb45d42ec6a 100644 --- a/Framework/Geometry/QuantityVector.h +++ b/Framework/Geometry/QuantityVector.h @@ -11,6 +11,7 @@ class QuantityVector { protected: using Quantity = phys::units::quantity<dim, double>; + using QuantitySquared = decltype(Quantity(phys::units::detail::magnitude_tag, 0) * Quantity(phys::units::detail::magnitude_tag, 0)); public: Eigen::Vector3d eVector; @@ -25,16 +26,21 @@ public: { } - Quantity operator[](size_t index) const + auto operator[](size_t index) const { return Quantity(phys::units::detail::magnitude_tag, eVector[index]); } - Quantity norm() const + auto norm() const { return Quantity(phys::units::detail::magnitude_tag, eVector.norm()); } + auto squaredNorm() const + { + return QuantitySquared(phys::units::detail::magnitude_tag, eVector.squaredNorm()); + } + auto operator+(QuantityVector<dim> const& pQVec) const { return QuantityVector<dim>(eVector + pQVec.eVector); diff --git a/Framework/Geometry/Sphere.h b/Framework/Geometry/Sphere.h new file mode 100644 index 0000000000000000000000000000000000000000..2a3ecf1af55c3099982504214dc6b328e23f3392 --- /dev/null +++ b/Framework/Geometry/Sphere.h @@ -0,0 +1,27 @@ +#ifndef SPHERE_H_ +#define SPHERE_H_ + +#include "Point.h" +#include <phys/units/quantity.hpp> + +class Sphere +{ + using Length = phys::units::quantity<phys::units::length_d, double>; + Point center; + Length const radius; + +public: + Sphere(Point const& pCenter, Length const pRadius) : + center(pCenter), radius(pRadius) + { + + } + + auto isInside(Point const& p) const + { + return radius*radius > (center - p).squaredNorm(); + } + +}; + +#endif diff --git a/Framework/Geometry/Vector.h b/Framework/Geometry/Vector.h index 6e8b7fbbc38d1526950a15e1a53ae9b2f05e1b85..d6fff9842598800918620755dbffa0a57788f48f 100644 --- a/Framework/Geometry/Vector.h +++ b/Framework/Geometry/Vector.h @@ -49,6 +49,28 @@ public: return BaseVector<dim>::qVector.norm(); } + auto squaredNorm() const + { + return BaseVector<dim>::qVector.squaredNorm(); + } + + template <typename dim2> + auto parallelProjectionOnto(BaseVector<dim2> const& pVec, CoordinateSystem const& pCS) const + { + auto const ourCompVec = getComponents(pCS); + auto const otherCompVec = pVec.getComponents(pVec); + auto const& a = ourCompVec.eVector; + auto const& b = otherCompVec.eVector; + + return Vector<dim>(pCS, (a * b) / b.squaredNorm() * b); + } + + template <typename dim2> + auto parallelProjectionOnto(BaseVector<dim2> const& pVec) + { + return parallelProjectionOnto<dim2>(pVec, *BaseVector<dim>::cs); + } + //~ template <typename dim2> //~ auto operator*(Vector<dim2> const& pVec) //~ {