Skip to content
Snippets Groups Projects
Commit 54ef91e0 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

clang-format Base/

parent a19bda45
No related branches found
No related tags found
1 merge request!486Merge BasicVector3D into Vectors3D.h, make it header only, and decouple from Complex.h
...@@ -51,7 +51,7 @@ double Math::cot(double x) ...@@ -51,7 +51,7 @@ double Math::cot(double x)
double Math::sinc(double x) // Sin(x)/x double Math::sinc(double x) // Sin(x)/x
{ {
if (x==0) if (x == 0)
return 1; return 1;
return std::sin(x) / x; return std::sin(x) / x;
} }
......
...@@ -27,9 +27,9 @@ using C3 = Vec3<complex_t>; ...@@ -27,9 +27,9 @@ using C3 = Vec3<complex_t>;
//! Three-dimensional vector template, for use with integer, double, or complex components. //! Three-dimensional vector template, for use with integer, double, or complex components.
template <class T> class Vec3 : public std::array<T,3> { template <class T> class Vec3 : public std::array<T, 3> {
private: private:
using super = std::array<T,3>; using super = std::array<T, 3>;
public: public:
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
Vec3() : super{0., 0., 0.} {} Vec3() : super{0., 0., 0.} {}
//! Constructs a vector from cartesian components. //! Constructs a vector from cartesian components.
Vec3(const T x, const T y, const T z) : super{x,y,z} {} Vec3(const T x, const T y, const T z) : super{x, y, z} {}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Component access // Component access
...@@ -162,10 +162,7 @@ public: ...@@ -162,10 +162,7 @@ public:
double angle(const Vec3<T>& v) const; double angle(const Vec3<T>& v) const;
//! Returns projection of this onto other vector: (this*v)*v/|v|^2. //! Returns projection of this onto other vector: (this*v)*v/|v|^2.
Vec3<T> project(const Vec3<T>& v) const Vec3<T> project(const Vec3<T>& v) const { return dot(v) * v / v.mag2(); }
{
return dot(v) * v / v.mag2();
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Rotations // Rotations
...@@ -219,16 +216,14 @@ template <class T> inline Vec3<T> operator-(const Vec3<T>& v) ...@@ -219,16 +216,14 @@ template <class T> inline Vec3<T> operator-(const Vec3<T>& v)
//! Addition of two vectors. //! Addition of two vectors.
//! @relates Vec3 //! @relates Vec3
template <class T> template <class T> inline Vec3<T> operator+(const Vec3<T>& a, const Vec3<T>& b)
inline Vec3<T> operator+(const Vec3<T>& a, const Vec3<T>& b)
{ {
return {a.x() + b.x(), a.y() + b.y(), a.z() + b.z()}; return {a.x() + b.x(), a.y() + b.y(), a.z() + b.z()};
} }
//! Subtraction of two vectors. //! Subtraction of two vectors.
//! @relates Vec3 //! @relates Vec3
template <class T> template <class T> inline Vec3<T> operator-(const Vec3<T>& a, const Vec3<T>& b)
inline Vec3<T> operator-(const Vec3<T>& a, const Vec3<T>& b)
{ {
return {a.x() - b.x(), a.y() - b.y(), a.z() - b.z()}; return {a.x() - b.x(), a.y() - b.y(), a.z() - b.z()};
} }
...@@ -269,9 +264,7 @@ template <class T, class U> inline Vec3<T> operator/(const Vec3<T>& v, U a) ...@@ -269,9 +264,7 @@ template <class T, class U> inline Vec3<T> operator/(const Vec3<T>& v, U a)
//! Returns dot product of (complex) vectors (antilinear in the first [=self] argument). //! Returns dot product of (complex) vectors (antilinear in the first [=self] argument).
#ifndef SWIG #ifndef SWIG
template <class T> template <class T> template <class U> inline auto Vec3<T>::dot(const Vec3<U>& v) const
template <class U>
inline auto Vec3<T>::dot(const Vec3<U>& v) const
{ {
Vec3<T> left_star = this->conj(); Vec3<T> left_star = this->conj();
return left_star.x() * v.x() + left_star.y() * v.y() + left_star.z() * v.z(); return left_star.x() * v.x() + left_star.y() * v.y() + left_star.z() * v.z();
...@@ -280,12 +273,10 @@ inline auto Vec3<T>::dot(const Vec3<U>& v) const ...@@ -280,12 +273,10 @@ inline auto Vec3<T>::dot(const Vec3<U>& v) const
//! Returns cross product of (complex) vectors. //! Returns cross product of (complex) vectors.
#ifndef SWIG #ifndef SWIG
template <class T> template <class T> template <class U> inline auto Vec3<T>::cross(const Vec3<U>& v) const
template <class U>
inline auto Vec3<T>::cross(const Vec3<U>& v) const
{ {
return Vec3<decltype(this->x() * v.x())>( return Vec3<decltype(this->x() * v.x())>(y() * v.z() - v.y() * z(), z() * v.x() - v.z() * x(),
y() * v.z() - v.y() * z(), z() * v.x() - v.z() * x(), x() * v.y() - v.x() * y()); x() * v.y() - v.x() * y());
} }
#endif // USER_API #endif // USER_API
......
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