IAP GITLAB

Skip to content
Snippets Groups Projects
Commit e201d83e authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan:
Browse files

some documentation for geometry

parent 38250275
No related branches found
No related tags found
No related merge requests found
...@@ -23,5 +23,6 @@ INCLUDE_GRAPH = YES ...@@ -23,5 +23,6 @@ INCLUDE_GRAPH = YES
GRAPHICAL_HIERARCHY = YES GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES DIRECTORY_GRAPH = YES
GENERATE_LEGEND = YES GENERATE_LEGEND = YES
USE_MATHJAX = YES
SEARCHENGINE = YES SEARCHENGINE = YES
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#include <Geometry/QuantityVector.h> #include <Geometry/QuantityVector.h>
#include <Geometry/CoordinateSystem.h> #include <Geometry/CoordinateSystem.h>
/*!
* Common base class for Vector and Point. Currently it does basically nothing.
*/
template <typename dim> template <typename dim>
class BaseVector class BaseVector
{ {
......
...@@ -6,10 +6,12 @@ ...@@ -6,10 +6,12 @@
#include <Geometry/Vector.h> #include <Geometry/Vector.h>
#include <Units/PhysicalUnits.h> #include <Units/PhysicalUnits.h>
/*!
* A Point represents a point in position space. It is defined by its
* coordinates with respect to some CoordinateSystem.
*/
class Point : public BaseVector<phys::units::length_d> class Point : public BaseVector<phys::units::length_d>
{ {
using Length = phys::units::quantity<phys::units::length_d, double>;
public: public:
Point(CoordinateSystem const& pCS, QuantityVector<phys::units::length_d> pQVector) : Point(CoordinateSystem const& pCS, QuantityVector<phys::units::length_d> pQVector) :
BaseVector<phys::units::length_d>(pCS, pQVector) BaseVector<phys::units::length_d>(pCS, pQVector)
...@@ -38,6 +40,10 @@ public: ...@@ -38,6 +40,10 @@ public:
} }
} }
/*!
* transforms the Point into another CoordinateSystem by changing its
* coordinates interally
*/
void rebase(CoordinateSystem const& pCS) void rebase(CoordinateSystem const& pCS)
{ {
BaseVector<phys::units::length_d>::qVector = getCoordinates(pCS); BaseVector<phys::units::length_d>::qVector = getCoordinates(pCS);
...@@ -49,6 +55,9 @@ public: ...@@ -49,6 +55,9 @@ public:
return Point(*BaseVector<phys::units::length_d>::cs, getCoordinates() + pVec.getComponents(*BaseVector<phys::units::length_d>::cs)); return Point(*BaseVector<phys::units::length_d>::cs, getCoordinates() + pVec.getComponents(*BaseVector<phys::units::length_d>::cs));
} }
/*!
* returns the distance Vector between two points
*/
Vector<phys::units::length_d> operator-(Point const& pB) const Vector<phys::units::length_d> operator-(Point const& pB) const
{ {
auto& cs = *BaseVector<phys::units::length_d>::cs; auto& cs = *BaseVector<phys::units::length_d>::cs;
......
...@@ -7,17 +7,22 @@ ...@@ -7,17 +7,22 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
/*!
* A QuantityVector is a three-component container based on Eigen::Vector3d
* with a phys::units::dimension. Arithmethic operators are defined that
* propagate the dimensions by dimensional analysis.
*/
template <typename dim> template <typename dim>
class QuantityVector class QuantityVector
{ {
protected: protected:
using Quantity = phys::units::quantity<dim, double>; using Quantity = phys::units::quantity<dim, double>; //< the phys::units::quantity corresponding to the dimension
//using QuantitySquared = decltype(std::declval<Quantity>() * std::declval<Quantity>());
public: public:
Eigen::Vector3d eVector; Eigen::Vector3d eVector; //!< the actual container where the raw numbers are stored
typedef dim dimension; typedef dim dimension; //!< should be a phys::units::dimension
QuantityVector(Quantity a, Quantity b, Quantity c) : QuantityVector(Quantity a, Quantity b, Quantity c) :
eVector{a.magnitude(), b.magnitude(), c.magnitude()} eVector{a.magnitude(), b.magnitude(), c.magnitude()}
......
...@@ -5,6 +5,16 @@ ...@@ -5,6 +5,16 @@
#include <Geometry/QuantityVector.h> #include <Geometry/QuantityVector.h>
#include <Units/PhysicalUnits.h> #include <Units/PhysicalUnits.h>
/*!
* A Vector represents a 3-vector in Euclidean space. It is defined by components
* given in a specific CoordinateSystem. It has a physical dimension ("unit")
* as part of its type, so you cannot mix up e.g. electric with magnetic fields
* (but you could calculate their cross-product to get an energy flux vector).
*
* When transforming coordinate systems, a Vector is subject to the rotational
* part only and invariant under translations.
*/
template <typename dim> template <typename dim>
class Vector : public BaseVector<dim> class Vector : public BaseVector<dim>
{ {
...@@ -21,11 +31,19 @@ public: ...@@ -21,11 +31,19 @@ public:
{ {
} }
/*!
* returns a QuantityVector with the components given in the "home"
* CoordinateSystem of the Vector
*/
auto getComponents() const auto getComponents() const
{ {
return BaseVector<dim>::qVector; return BaseVector<dim>::qVector;
} }
/*!
* returns a QuantityVector with the components given in an arbitrary
* CoordinateSystem
*/
auto getComponents(CoordinateSystem const& pCS) const auto getComponents(CoordinateSystem const& pCS) const
{ {
if (&pCS == BaseVector<dim>::cs) if (&pCS == BaseVector<dim>::cs)
...@@ -38,22 +56,41 @@ public: ...@@ -38,22 +56,41 @@ public:
} }
} }
/*!
* transforms the Vector into another CoordinateSystem by changing
* its components internally
*/
void rebase(CoordinateSystem const& pCS) void rebase(CoordinateSystem const& pCS)
{ {
BaseVector<dim>::qVector = getComponents(pCS); BaseVector<dim>::qVector = getComponents(pCS);
BaseVector<dim>::cs = &pCS; BaseVector<dim>::cs = &pCS;
} }
/*!
* returns the norm/length of the Vector. Before using this method,
* think about whether squaredNorm() might be cheaper for your computation.
*/
auto norm() const auto norm() const
{ {
return BaseVector<dim>::qVector.norm(); return BaseVector<dim>::qVector.norm();
} }
/*!
* returns the squared norm of the Vector. Before using this method,
* think about whether norm() might be cheaper for your computation.
*/
auto squaredNorm() const auto squaredNorm() const
{ {
return BaseVector<dim>::qVector.squaredNorm(); return BaseVector<dim>::qVector.squaredNorm();
} }
/*!
* returns a Vector \f$ \vec{v}_{\parallel} \f$ which is the parallel projection
* of this vector \f$ \vec{v}_1 \f$ along another Vector \f$ \vec{v}_2 \f$ given by
* \f[
* \vec{v}_{\parallel} = \frac{\vec{v}_1 \cdot \vec{v}_2}{\vec{v}_2^2} \vec{v}_2
* \f]
*/
template <typename dim2> template <typename dim2>
auto parallelProjectionOnto(Vector<dim2> const& pVec, CoordinateSystem const& pCS) const auto parallelProjectionOnto(Vector<dim2> const& pVec, CoordinateSystem const& pCS) const
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment