IAP GITLAB

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

Merge branch 'geometry_improvement' into 'master'

Some improvements regarding coordinate systems

Closes #488 und #489

See merge request !420
parents 8a317705 67b77365
No related branches found
No related tags found
1 merge request!420Some improvements regarding coordinate systems
Pipeline #6220 passed with warnings
...@@ -75,7 +75,7 @@ namespace corsika { ...@@ -75,7 +75,7 @@ namespace corsika {
inline CoordinateSystemPtr make_translation(CoordinateSystemPtr const& cs, inline CoordinateSystemPtr make_translation(CoordinateSystemPtr const& cs,
QuantityVector<length_d> const& vector) { QuantityVector<length_d> const& vector) {
EigenTransform const translation{EigenTranslation(vector.getEigenVector())}; EigenTransform const translation{EigenTranslation(vector.getEigenVector())};
return std::make_shared<CoordinateSystem const>(CoordinateSystem(cs, translation)); return CoordinateSystemPtr{new CoordinateSystem(cs, translation)};
} }
template <typename TDim> template <typename TDim>
...@@ -105,8 +105,7 @@ namespace corsika { ...@@ -105,8 +105,7 @@ namespace corsika {
0, 0, (a1 * a1 + a2 * a2) * c; // . 0, 0, (a1 * a1 + a2 * a2) * c; // .
} }
return std::make_shared<CoordinateSystem const>( return CoordinateSystemPtr{new CoordinateSystem{cs, EigenTransform{A + B}}};
CoordinateSystem(cs, EigenTransform(A + B)));
} }
template <typename TDim> template <typename TDim>
...@@ -120,7 +119,7 @@ namespace corsika { ...@@ -120,7 +119,7 @@ namespace corsika {
EigenTransform const rotation{ EigenTransform const rotation{
Eigen::AngleAxisd(angle, axis.getEigenVector().normalized())}; Eigen::AngleAxisd(angle, axis.getEigenVector().normalized())};
return std::make_shared<CoordinateSystem const>(CoordinateSystem(cs, rotation)); return CoordinateSystemPtr{new CoordinateSystem{cs, rotation}};
} }
template <typename TDim> template <typename TDim>
...@@ -135,7 +134,7 @@ namespace corsika { ...@@ -135,7 +134,7 @@ namespace corsika {
Eigen::AngleAxisd(angle, axis.getEigenVector().normalized()) * Eigen::AngleAxisd(angle, axis.getEigenVector().normalized()) *
EigenTranslation(translation.getEigenVector())}; EigenTranslation(translation.getEigenVector())};
return std::make_shared<CoordinateSystem const>(CoordinateSystem(cs, transf)); return CoordinateSystemPtr{new CoordinateSystem{cs, transf}};
} }
} // namespace corsika } // namespace corsika
...@@ -24,46 +24,22 @@ namespace corsika { ...@@ -24,46 +24,22 @@ namespace corsika {
} }
inline LengthType Point::getX(CoordinateSystemPtr const& pCS) const { inline LengthType Point::getX(CoordinateSystemPtr const& pCS) const {
CoordinateSystemPtr const& cs = BaseVector<length_d>::getCoordinateSystem(); return getCoordinates(pCS).getX();
if (*pCS == *cs) {
return BaseVector<length_d>::getQuantityVector().getX();
} else {
return QuantityVector<length_d>(
get_transformation(*cs.get(), *pCS.get()) *
BaseVector<length_d>::getQuantityVector().eigenVector_)
.getX();
}
} }
inline LengthType Point::getY(CoordinateSystemPtr const& pCS) const { inline LengthType Point::getY(CoordinateSystemPtr const& pCS) const {
CoordinateSystemPtr const& cs = BaseVector<length_d>::getCoordinateSystem(); return getCoordinates(pCS).getY();
if (*pCS == *cs) {
return BaseVector<length_d>::getQuantityVector().getY();
} else {
return QuantityVector<length_d>(
get_transformation(*cs.get(), *pCS.get()) *
BaseVector<length_d>::getQuantityVector().eigenVector_)
.getY();
}
} }
inline LengthType Point::getZ(CoordinateSystemPtr const& pCS) const { inline LengthType Point::getZ(CoordinateSystemPtr const& pCS) const {
CoordinateSystemPtr const& cs = BaseVector<length_d>::getCoordinateSystem(); return getCoordinates(pCS).getZ();
if (*pCS == *cs) {
return BaseVector<length_d>::getQuantityVector().getZ();
} else {
return QuantityVector<length_d>(
get_transformation(*cs.get(), *pCS.get()) *
BaseVector<length_d>::getQuantityVector().eigenVector_)
.getZ();
}
} }
/// this always returns a QuantityVector as triple /// this always returns a QuantityVector as triple
inline QuantityVector<length_d> Point::getCoordinates( inline QuantityVector<length_d> Point::getCoordinates(
CoordinateSystemPtr const& pCS) const { CoordinateSystemPtr const& pCS) const {
CoordinateSystemPtr const& cs = BaseVector<length_d>::getCoordinateSystem(); CoordinateSystemPtr const& cs = BaseVector<length_d>::getCoordinateSystem();
if (*pCS == *cs) { if (pCS == cs) {
return BaseVector<length_d>::getQuantityVector(); return BaseVector<length_d>::getQuantityVector();
} else { } else {
return QuantityVector<length_d>( return QuantityVector<length_d>(
...@@ -74,7 +50,7 @@ namespace corsika { ...@@ -74,7 +50,7 @@ namespace corsika {
/// this always returns a QuantityVector as triple /// this always returns a QuantityVector as triple
inline QuantityVector<length_d>& Point::getCoordinates(CoordinateSystemPtr const& pCS) { inline QuantityVector<length_d>& Point::getCoordinates(CoordinateSystemPtr const& pCS) {
if (*pCS != *BaseVector<length_d>::getCoordinateSystem()) { rebase(pCS); } if (pCS != BaseVector<length_d>::getCoordinateSystem()) { rebase(pCS); }
return BaseVector<length_d>::getQuantityVector(); return BaseVector<length_d>::getQuantityVector();
} }
...@@ -106,4 +82,4 @@ namespace corsika { ...@@ -106,4 +82,4 @@ namespace corsika {
return (p1 - p2).getNorm(); return (p1 - p2).getNorm();
} }
} // namespace corsika } // namespace corsika
\ No newline at end of file
...@@ -27,7 +27,7 @@ namespace corsika { ...@@ -27,7 +27,7 @@ namespace corsika {
template <typename TDimension> template <typename TDimension>
inline QuantityVector<TDimension> Vector<TDimension>::getComponents( inline QuantityVector<TDimension> Vector<TDimension>::getComponents(
CoordinateSystemPtr const& pCS) const { CoordinateSystemPtr const& pCS) const {
if (*pCS == *BaseVector<TDimension>::getCoordinateSystem()) { if (pCS == BaseVector<TDimension>::getCoordinateSystem()) {
return BaseVector<TDimension>::getQuantityVector(); return BaseVector<TDimension>::getQuantityVector();
} else { } else {
return QuantityVector<TDimension>( return QuantityVector<TDimension>(
......
...@@ -35,7 +35,7 @@ namespace corsika { ...@@ -35,7 +35,7 @@ namespace corsika {
using CoordinateSystemPtr = std::shared_ptr<CoordinateSystem const>; using CoordinateSystemPtr = std::shared_ptr<CoordinateSystem const>;
/// this is the only way to create ONE unique root CS /// this is the only way to create ONE unique root CS
static CoordinateSystemPtr& get_root_CoordinateSystem(); CoordinateSystemPtr const& get_root_CoordinateSystem();
/** /**
* Creates new CoordinateSystemPtr by translation along \a vector * Creates new CoordinateSystemPtr by translation along \a vector
...@@ -109,8 +109,8 @@ namespace corsika { ...@@ -109,8 +109,8 @@ namespace corsika {
public: public:
// default resource allocation // default resource allocation
CoordinateSystem(CoordinateSystem const&) = default; CoordinateSystem(CoordinateSystem const&) = delete;
CoordinateSystem(CoordinateSystem&&) = default; CoordinateSystem(CoordinateSystem&&) = delete;
CoordinateSystem& operator=(CoordinateSystem const& pCS) = CoordinateSystem& operator=(CoordinateSystem const& pCS) =
delete; // avoid making copies delete; // avoid making copies
~CoordinateSystem() = default; ~CoordinateSystem() = default;
...@@ -128,15 +128,13 @@ namespace corsika { ...@@ -128,15 +128,13 @@ namespace corsika {
bool operator!=(CoordinateSystem const&) const; bool operator!=(CoordinateSystem const&) const;
protected: protected:
static CoordinateSystem createCS() { return CoordinateSystem(); }
/** /**
* \name Friends * \name Friends
* Manipulation and creation functions. * Manipulation and creation functions.
* \{ * \{
**/ **/
friend CoordinateSystemPtr& get_root_CoordinateSystem(); friend CoordinateSystemPtr const& get_root_CoordinateSystem();
friend CoordinateSystemPtr make_translation(CoordinateSystemPtr const& cs, friend CoordinateSystemPtr make_translation(CoordinateSystemPtr const& cs,
QuantityVector<length_d> const& vector); QuantityVector<length_d> const& vector);
......
...@@ -27,8 +27,8 @@ namespace corsika { ...@@ -27,8 +27,8 @@ namespace corsika {
* RootCoordinateSystem * RootCoordinateSystem
*/ */
static inline CoordinateSystemPtr& get_root_CoordinateSystem() { inline CoordinateSystemPtr const& get_root_CoordinateSystem() {
static CoordinateSystemPtr rootCS(new CoordinateSystem); // THIS IS IT static CoordinateSystemPtr const rootCS(new CoordinateSystem); // THIS IS IT
return rootCS; return rootCS;
} }
......
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