Chipmunk++
 All Classes Functions Variables Pages
vect.hpp
1 #pragma once
2 
3 #include "types.hpp"
4 
5 #include <iosfwd>
6 
7 #pragma GCC visibility push(default)
8 namespace cp {
10  class Vect {
11  public:
13  Vect(Float x, Float y);
14 
16  Vect();
17 
19  Vect(const cpVect&);
20 
22  operator cpVect() const;
23 
24  Vect& operator/=(const Float v);
25  Vect& operator*=(const Float v);
26  Vect& operator-=(const Vect& rhs);
27  Vect& operator-=(const Float v);
28  Vect& operator+=(const Float v);
29  Vect& operator+=(const Vect& rhs);
30  Vect& operator++();
31  Vect& operator--();
32 
34  Float length() const;
35 
37  Float lengthSq() const;
38 
40  Vect perp() const;
41 
43  Vect rperp() const;
44 
46  Vect normalize() const;
47 
50  Vect normalizeSafe() const;
51 
53  Vect clamp(Float len) const;
54 
56  Float toAngle() const;
57 
59  Vect rotate(Vect v) const;
60 
62  Vect unrotate(Vect v) const;
63 
65  Float x;
66 
68  Float y;
69 
71  static Vect forAngle(Float a);
72 
74  static Float dot(Vect v1, Vect v2);
75 
78  static Float cross(Vect v1, Vect v2);
79 
81  static Vect project(Vect v1, Vect v2);
82 
84  static Vect lerp(Vect v1, Vect v2, Float t);
85 
87  static Vect lerpconst(Vect v1, Vect v2, Float d);
88 
90  static Vect slerp(Vect v1, Vect v2, Float t);
91 
93  static Vect slerpconst(Vect v1, Vect v2, Float a);
94 
96  static Float dist(Vect v1, Vect v2);
97 
100  static Float distSq(Vect v1, Vect v2);
101 
103  static bool near(Vect v1, Vect v2, Float dist);
104  };
105 
106  bool operator==(const Vect& lhs, const Vect& rhs);
107  bool operator!=(const Vect& lhs, const Vect& rhs);
108  Vect operator*(const Vect& lhs, const Float v);
109  Vect operator/(const Vect& lhs, const Float v);
110  Vect operator*(const Float v, const Vect& rhs);
111  Vect operator/(const Float v, const Vect& rhs);
112  Float operator*(const Vect& lhs, const Vect& rhs);
113  Vect operator-(const Vect& lhs, const Vect& rhs);
114  Vect operator+(const Vect& lhs, const Vect& rhs);
115  bool operator<(const Vect& lhs, const Vect& rhs);
116  bool operator>(const Vect& lhs, const Vect& rhs);
117 }
118 
119 std::ostream& operator<<(std::ostream&, const cp::Vect&);
120 
121 #pragma GCC visibility pop