TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PhysicsFrame.h
Go to the documentation of this file.
1 
10 #ifndef G3D_PhysicsFrame_h
11 #define G3D_PhysicsFrame_h
12 
13 #include "G3D/platform.h"
14 #include "G3D/Vector3.h"
15 #include "G3D/Matrix3.h"
16 #include "G3D/Quat.h"
17 #include "G3D/CoordinateFrame.h"
18 #include <math.h>
19 #include <string>
20 
21 
22 namespace G3D {
23 
30 class PhysicsFrame {
31 public:
32 
34 
39 
43  PhysicsFrame();
44 
48  PhysicsFrame(const Vector3& translation) : translation(translation) {}
49  PhysicsFrame(const Quat& rot, const Vector3& translation) : rotation(rot), translation(translation) {}
50  PhysicsFrame(const Matrix3& rot, const Vector3& translation) : rotation(rot), translation(translation) {}
51  PhysicsFrame(const Matrix3& rot) : rotation(rot), translation(Vector3::zero()) {}
52  PhysicsFrame(const CoordinateFrame& coordinateFrame);
53 
55  rotation = p.rotation;
56  translation = p.translation;
57 
58  return *this;
59  }
60 
67  PhysicsFrame(const class Any& any);
68 
69  Any toAny() const;
70 
72  PhysicsFrame operator*(const PhysicsFrame& other) const;
73 
74  virtual ~PhysicsFrame() {}
75 
80  const PhysicsFrame& other,
81  float alpha) const;
82 
83  void deserialize(class BinaryInput& b);
84 
85  void serialize(class BinaryOutput& b) const;
86 
87  operator CFrame() const;
88 
92  rotation *= f;
93  translation *= f;
94  return *this;
95  }
96 
99  PhysicsFrame operator*(float f) const {
100  return PhysicsFrame(rotation * f, translation * f);
101  }
102 
104  return PhysicsFrame(rotation + f.rotation, translation + f.translation);
105  }
106 
108  rotation += f.rotation;
109  translation += f.translation;
110  return *this;
111  }
112 
113  bool operator==(const PhysicsFrame& other) const {
114  return (translation == other.translation) &&
115  ((rotation == other.rotation) || (rotation == -other.rotation));
116  }
117 
118  bool operator!=(const PhysicsFrame& other) const {
119  return ! ((*this) == other);
120  }
121 
122 };
123 
125 
126 } // namespace
127 
128 #endif
PhysicsFrame()
Definition: PhysicsFrame.cpp:20
PhysicsFrame lerp(const PhysicsFrame &other, float alpha) const
Definition: PhysicsFrame.cpp:100
Definition: BinaryInput.h:69
A rigid body RT (rotation-translation) transformation.
Definition: CoordinateFrame.h:59
void deserialize(class BinaryInput &b)
Definition: PhysicsFrame.cpp:113
Definition: PhysicsFrame.h:30
bool operator!=(const PhysicsFrame &other) const
Definition: PhysicsFrame.h:118
class CoordinateFrame CFrame
Definition: Box2D.h:22
Definition: AABox.h:25
bool any(float x)
Definition: g3dmath.h:424
PhysicsFrame operator*(const PhysicsFrame &other) const
Definition: PhysicsFrame.cpp:80
void serialize(class BinaryOutput &b) const
Definition: PhysicsFrame.cpp:119
PhysicsFrame(const Matrix3 &rot)
Definition: PhysicsFrame.h:51
Definition: Vector3.h:58
PhysicsFrame PFrame
Definition: PhysicsFrame.h:124
virtual ~PhysicsFrame()
Definition: PhysicsFrame.h:74
Easy loading and saving of human-readable configuration files.
Definition: Any.h:184
Definition: Quat.h:49
PhysicsFrame & operator=(const PhysicsFrame &p)
Definition: PhysicsFrame.h:54
PhysicsFrame & operator+=(const PhysicsFrame &f)
Definition: PhysicsFrame.h:107
PhysicsFrame & operator*=(float f)
Definition: PhysicsFrame.h:91
bool operator==(const PhysicsFrame &other) const
Definition: PhysicsFrame.h:113
Definition: Matrix3.h:37
Quat rotation
Definition: PhysicsFrame.h:33
PhysicsFrame(const Quat &rot, const Vector3 &translation)
Definition: PhysicsFrame.h:49
PhysicsFrame operator*(float f) const
Definition: PhysicsFrame.h:99
PhysicsFrame operator+(const PhysicsFrame &f) const
Definition: PhysicsFrame.h:103
static unorm16 zero()
Definition: unorm16.h:82
Definition: BinaryOutput.h:52
PhysicsFrame(const Vector3 &translation)
Definition: PhysicsFrame.h:48
Point3 translation
Definition: PhysicsFrame.h:38
Any toAny() const
Definition: PhysicsFrame.cpp:33
PhysicsFrame(const Matrix3 &rot, const Vector3 &translation)
Definition: PhysicsFrame.h:50