vector_types.h
1 #pragma once
2 
3 #include <array>
4 #include <cmath>
5 #include <iostream>
6 #include <sstream>
7 #include <string> // std::string
8 #include <vector>
9 
10 namespace morphio {
11 #ifdef MORPHIO_USE_DOUBLE
12 using floatType = double;
13 constexpr floatType epsilon = 1e-6;
14 constexpr floatType PI = M_PI;
15 #else
16 using floatType = float;
17 constexpr floatType epsilon = 1e-6f;
18 constexpr floatType PI = static_cast<floatType>(M_PI);
19 #endif
20 
21 using Point = std::array<morphio::floatType, 3>;
22 using Points = std::vector<Point>;
23 
24 Point operator+(const Point& left, const Point& right);
25 Point operator-(const Point& left, const Point& right);
26 Point operator+=(Point& left, const Point& right);
27 Point operator-=(Point& left, const Point& right);
28 Point operator/=(Point& left, const floatType factor);
29 
30 Points operator+(const Points& points, const Point& right);
31 Points operator-(const Points& points, const Point& right);
32 Points operator+=(Points& points, const Point& right);
33 Points operator-=(Points& points, const Point& right);
34 
35 template <typename T>
36 Point operator*(const Point& from, T factor);
37 template <typename T>
38 Point operator*(T factor, const Point& from);
39 template <typename T>
40 Point operator/(const Point& from, T factor);
41 template <typename T>
42 Point centerOfGravity(const T& points);
43 template <typename T>
44 floatType maxDistanceToCenterOfGravity(const T& points);
45 
46 extern template Point centerOfGravity(const Points&);
47 extern template floatType maxDistanceToCenterOfGravity(const Points&);
48 
49 std::string dumpPoint(const Point& point);
50 std::string dumpPoints(const Points& point);
51 
52 
53 char my_tolower(char ch);
54 
58 floatType distance(const Point& left, const Point& right);
59 
60 std::ostream& operator<<(std::ostream& os, const morphio::Point& point);
61 std::ostream& operator<<(std::ostream& os, const Points& points);
62 
63 } // namespace morphio
64 std::ostream& operator<<(std::ostream& os, const morphio::Point& point);
65 std::ostream& operator<<(std::ostream& os, const morphio::Points& points);
Definition: endoplasmic_reticulum.h:5
floatType distance(const Point &left, const Point &right)