TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::PhysicsFrame Class Reference

#include <PhysicsFrame.h>

Public Member Functions

 PhysicsFrame ()
 
 PhysicsFrame (const Vector3 &translation)
 
 PhysicsFrame (const Quat &rot, const Vector3 &translation)
 
 PhysicsFrame (const Matrix3 &rot, const Vector3 &translation)
 
 PhysicsFrame (const Matrix3 &rot)
 
 PhysicsFrame (const CoordinateFrame &coordinateFrame)
 
PhysicsFrameoperator= (const PhysicsFrame &p)
 
 PhysicsFrame (const class Any &any)
 
Any toAny () const
 
PhysicsFrame operator* (const PhysicsFrame &other) const
 
virtual ~PhysicsFrame ()
 
PhysicsFrame lerp (const PhysicsFrame &other, float alpha) const
 
void deserialize (class BinaryInput &b)
 
void serialize (class BinaryOutput &b) const
 
 operator CFrame () const
 
PhysicsFrameoperator*= (float f)
 
PhysicsFrame operator* (float f) const
 
PhysicsFrame operator+ (const PhysicsFrame &f) const
 
PhysicsFrameoperator+= (const PhysicsFrame &f)
 
bool operator== (const PhysicsFrame &other) const
 
bool operator!= (const PhysicsFrame &other) const
 

Public Attributes

Quat rotation
 
Point3 translation
 

Detailed Description

An RT transformation using a quaternion; suitable for physics integration.

This interface is in "Beta" and will change in the next release.

Constructor & Destructor Documentation

G3D::PhysicsFrame::PhysicsFrame ( )

Initializes to the identity frame.

20  {
22  rotation = Quat();
23 }
static const Vector3 & zero()
Definition: Vector3.cpp:119
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

G3D::PhysicsFrame::PhysicsFrame ( const Vector3 translation)
inline

Purely translational.

Point3 translation
Definition: PhysicsFrame.h:38
G3D::PhysicsFrame::PhysicsFrame ( const Quat rot,
const Vector3 translation 
)
inline
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38
G3D::PhysicsFrame::PhysicsFrame ( const Matrix3 rot,
const Vector3 translation 
)
inline
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38
G3D::PhysicsFrame::PhysicsFrame ( const Matrix3 rot)
inline
static const Vector3 & zero()
Definition: Vector3.cpp:119
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38
G3D::PhysicsFrame::PhysicsFrame ( const CoordinateFrame coordinateFrame)
27  {
28  translation = coordinateFrame.translation;
29  rotation = Quat(coordinateFrame.rotation);
30 }
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38
G3D::PhysicsFrame::PhysicsFrame ( const class Any any)
virtual G3D::PhysicsFrame::~PhysicsFrame ( )
inlinevirtual
74 {}

Member Function Documentation

void G3D::PhysicsFrame::deserialize ( class BinaryInput b)
113  {
116 }
void deserialize(class BinaryInput &b)
Definition: Quat.cpp:258
void deserialize(class BinaryInput &b)
Definition: Vector3.cpp:190
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38

+ Here is the call graph for this function:

PhysicsFrame G3D::PhysicsFrame::lerp ( const PhysicsFrame other,
float  alpha 
) const

Linear interpolation (spherical linear for the rotations).

102  {
103 
104  PhysicsFrame result;
105 
106  result.translation = translation.lerp(other.translation, alpha);
107  result.rotation = rotation.slerp(other.rotation, alpha);
108 
109  return result;
110 }
PhysicsFrame()
Definition: PhysicsFrame.cpp:20
Quat slerp(const Quat &other, float alpha, float threshold, float maxAngle) const
Definition: Quat.cpp:165
Vector3 lerp(const Vector3 &v, float alpha) const
Definition: Vector3.h:357
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38

+ Here is the call graph for this function:

G3D::PhysicsFrame::operator CFrame ( ) const
bool G3D::PhysicsFrame::operator!= ( const PhysicsFrame other) const
inline
118  {
119  return ! ((*this) == other);
120  }
PhysicsFrame G3D::PhysicsFrame::operator* ( const PhysicsFrame other) const

Compose: create the transformation that is other followed by this.

80  {
81  PhysicsFrame result;
82 
83  result.rotation = rotation * other.rotation;
84  result.translation = translation + rotation.toRotationMatrix() * other.translation;
85 
86  return result;
87 }
PhysicsFrame()
Definition: PhysicsFrame.cpp:20
Matrix3 toRotationMatrix() const
Definition: Quat.cpp:148
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38

+ Here is the call graph for this function:

PhysicsFrame G3D::PhysicsFrame::operator* ( float  f) const
inline

Multiplies both pieces by f; note that this will result in a non-unit quaternion that needs to be normalized

99  {
100  return PhysicsFrame(rotation * f, translation * f);
101  }
PhysicsFrame()
Definition: PhysicsFrame.cpp:20
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38

+ Here is the call graph for this function:

PhysicsFrame& G3D::PhysicsFrame::operator*= ( float  f)
inline

Multiplies both pieces by f; note that this will result in a non-unit quaternion that needs to be normalized

91  {
92  rotation *= f;
93  translation *= f;
94  return *this;
95  }
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38
PhysicsFrame G3D::PhysicsFrame::operator+ ( const PhysicsFrame f) const
inline
103  {
104  return PhysicsFrame(rotation + f.rotation, translation + f.translation);
105  }
PhysicsFrame()
Definition: PhysicsFrame.cpp:20
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38

+ Here is the call graph for this function:

PhysicsFrame& G3D::PhysicsFrame::operator+= ( const PhysicsFrame f)
inline
107  {
108  rotation += f.rotation;
109  translation += f.translation;
110  return *this;
111  }
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38
PhysicsFrame& G3D::PhysicsFrame::operator= ( const PhysicsFrame p)
inline
54  {
55  rotation = p.rotation;
56  translation = p.translation;
57 
58  return *this;
59  }
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38
bool G3D::PhysicsFrame::operator== ( const PhysicsFrame other) const
inline
113  {
114  return (translation == other.translation) &&
115  ((rotation == other.rotation) || (rotation == -other.rotation));
116  }
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38
void G3D::PhysicsFrame::serialize ( class BinaryOutput b) const
119  {
121  rotation.serialize(b);
122 }
void serialize(class BinaryOutput &b) const
Definition: Vector3.cpp:219
void serialize(class BinaryOutput &b) const
Definition: Quat.cpp:266
Quat rotation
Definition: PhysicsFrame.h:33
Point3 translation
Definition: PhysicsFrame.h:38

+ Here is the call graph for this function:

Any G3D::PhysicsFrame::toAny ( ) const
33  {
34  // Prefer to serialize as a CFrame, which is easier to read
35  if (false) {
36  Any a(Any::ARRAY, "PFrame");
37  a.append(rotation, translation.toAny("Point3"));
38  return a;
39  } else {
40  return CFrame(*this).toAny();
41  }
42 }
class CoordinateFrame CFrame
Definition: Box2D.h:22
Any toAny(const std::string &name) const
Definition: Vector3.cpp:99
Definition: Any.h:187
Quat rotation
Definition: PhysicsFrame.h:33
Any toAny() const
Definition: CoordinateFrame.cpp:87
Point3 translation
Definition: PhysicsFrame.h:38

+ Here is the call graph for this function:

Member Data Documentation

Quat G3D::PhysicsFrame::rotation
Point3 G3D::PhysicsFrame::translation

Origin of this reference frame in its parent's frame.


The documentation for this class was generated from the following files: