O --- O
libPEDSIM Documentation
[HOME] [EXAMPLES] [ECOSYSTEM] [DOCUMENTATION] [DOWNLOAD]
O --- O
ped_vector.h
1 //
2 // pedsim - A microscopic pedestrian simulation system.
3 // Copyright (c) by Christian Gloor
4 //
5 
6 #ifndef _ped_vector_h_
7 #define _ped_vector_h_ 1
8 
9 //disable warnings on 255 char debug symbols
10 #pragma warning (disable : 4786)
11 //disable warnings on extern before template instantiation
12 #pragma warning (disable : 4231)
13 
14 #ifdef _WIN32
15 #ifdef _DLL
16 # define LIBEXPORT __declspec(dllexport)
17 # define EXPIMP_TEMPLATE
18 #else
19 # define LIBEXPORT __declspec(dllimport)
20 # define EXPIMP_TEMPLATE extern
21 #endif
22 #else
23 # define LIBEXPORT
24 # define EXPIMP_TEMPLATE
25 #endif
26 
27 #include <string>
28 
29 namespace Ped {
32  class LIBEXPORT Tvector {
33  public:
34  // Default constructor
35  Tvector();
36 
37  // Initializing constructor
38  Tvector(double px, double py, double pz = 0) : x(px), y(py), z(pz) {};
39 
40  // Methods
41  double length() const;
42  double lengthSquared() const;
43  void normalize();
44  Tvector normalized() const;
45  void scale(double factor);
46  Tvector scaled(double factor) const;
47 
48  Tvector leftNormalVector() const;
49  Tvector rightNormalVector() const;
50 
51  double polarRadius() const;
52  double polarAngle() const;
53 
54  double angleTo(const Tvector &other) const;
55  void rotate(double theta);
56  Ped::Tvector rotated(double theta) const;
57 
58  static double scalar(const Tvector &a, const Tvector &b);
59  static double dotProduct(const Tvector &a, const Tvector &b);
60  static Tvector crossProduct(const Tvector &a, const Tvector &b);
61 
62  std::string to_string() const;
63 
64  static bool lineIntersection(const Ped::Tvector &p0, const Ped::Tvector &p1, const Ped::Tvector &p2, const Ped::Tvector &p3, Ped::Tvector *intersection);
65 
66  // Operators
67  Tvector operator+(const Tvector& other) const;
68  Tvector operator-(const Tvector& other) const;
69  Tvector operator*(double factor) const;
70  Tvector operator/(double divisor) const;
71  Tvector& operator+=(const Tvector& vectorIn);
72  Tvector& operator-=(const Tvector& vectorIn);
73  Tvector& operator*=(double factor);
74  Tvector& operator*=(const Tvector& vectorIn);
75  Tvector& operator/=(double divisor);
76 
77  // Attributes
78  double x;
79  double y;
80  double z;
81  };
82 }
83 
84 bool operator==(const Ped::Tvector& vector1In, const Ped::Tvector& vector2In);
85 bool operator!=(const Ped::Tvector& vector1In, const Ped::Tvector& vector2In);
86 Ped::Tvector operator-(const Ped::Tvector& vectorIn);
87 Ped::Tvector operator*(double factor, const Ped::Tvector& vector);
88 
89 
90 #endif
O --- O

⁠(c) Christian Gloor [ c|h|g|l|o|o|r|@|s|i|l|m|a|r|i|l|.|o|r|g| ]