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

Coordinate frame expressed in Euler angles. Unlike a G3D::Quat, UprightFrame always keeps the reference frame from rolling about its own z axis. Particularly useful for cameras. More...

#include <UprightFrame.h>

Public Member Functions

 UprightFrame (const Vector3 &t=Vector3::zero(), float p=0, float y=0)
 
 UprightFrame (const CoordinateFrame &cframe)
 
 UprightFrame (const Any &any)
 
Any toAny () const
 
UprightFrameoperator= (const Any &any)
 
 operator CoordinateFrame () const
 
CoordinateFrame toCoordinateFrame () const
 
UprightFrame operator+ (const UprightFrame &other) const
 
UprightFrame operator* (const float k) const
 
void serialize (class BinaryOutput &b) const
 
void deserialize (class BinaryInput &b)
 

Static Public Member Functions

static void unwrapYaw (UprightFrame *a, int N)
 

Public Attributes

Vector3 translation
 
float pitch
 
float yaw
 

Detailed Description

Coordinate frame expressed in Euler angles. Unlike a G3D::Quat, UprightFrame always keeps the reference frame from rolling about its own z axis. Particularly useful for cameras.

See also
G3D::CoordinateFrame, G3D::Matrix4, G3D::PhysicsFrame, G3D::UprightSpline, G3D::UprightSplineManipulator

Constructor & Destructor Documentation

G3D::UprightFrame::UprightFrame ( const Vector3 t = Vector3::zero(),
float  p = 0,
float  y = 0 
)
inline
35  : translation(t), pitch(p), yaw(y) {}
float yaw
Definition: UprightFrame.h:32
float pitch
Definition: UprightFrame.h:29
G3D::int16 y
Definition: Vector2int16.h:38
Vector3 translation
Definition: UprightFrame.h:26

+ Here is the caller graph for this function:

G3D::UprightFrame::UprightFrame ( const CoordinateFrame cframe)
13  {
14  Vector3 look = cframe.lookVector();
15 
16  yaw = (float)(G3D::pi() + atan2(look.x, look.z));
17  pitch = asin(look.y);
18 
19  translation = cframe.translation;
20 }
float yaw
Definition: UprightFrame.h:32
double pi()
Definition: g3dmath.h:147
float pitch
Definition: UprightFrame.h:29
Vector3 translation
Definition: UprightFrame.h:26

+ Here is the call graph for this function:

G3D::UprightFrame::UprightFrame ( const Any any)
explicit

Constructs an UprightFrame from an Any object.

The Any format for UprightFrame is:

pitch = ##, translation = Vector3(), yaw = ##

23  {
24  any.verifyName("UprightFrame");
25  any.verifyType(Any::TABLE);
26 
27  translation = any["translation"];
28  pitch = any["pitch"];
29  yaw = any["yaw"];
30 }
Definition: Any.h:187
float yaw
Definition: UprightFrame.h:32
bool any(float x)
Definition: g3dmath.h:424
float pitch
Definition: UprightFrame.h:29
Vector3 translation
Definition: UprightFrame.h:26

+ Here is the call graph for this function:

Member Function Documentation

void G3D::UprightFrame::deserialize ( class BinaryInput b)
109  {
111  pitch = b.readFloat32();
112  yaw = b.readFloat32();
113 }
float yaw
Definition: UprightFrame.h:32
float pitch
Definition: UprightFrame.h:29
void deserialize(class BinaryInput &b)
Definition: Vector3.cpp:190
Vector3 translation
Definition: UprightFrame.h:26

+ Here is the call graph for this function:

G3D::UprightFrame::operator CoordinateFrame ( ) const
inline

Supports implicit cast to CoordinateFrame

54  {
55  return toCoordinateFrame();
56  }
CoordinateFrame toCoordinateFrame() const
Definition: UprightFrame.cpp:49

+ Here is the call graph for this function:

UprightFrame G3D::UprightFrame::operator* ( const float  k) const

Required for use with spline

67  {
68  return UprightFrame(translation * k, pitch * k, yaw * k);
69 }
float yaw
Definition: UprightFrame.h:32
float pitch
Definition: UprightFrame.h:29
UprightFrame(const Vector3 &t=Vector3::zero(), float p=0, float y=0)
Definition: UprightFrame.h:34
Vector3 translation
Definition: UprightFrame.h:26

+ Here is the call graph for this function:

UprightFrame G3D::UprightFrame::operator+ ( const UprightFrame other) const

Required for use with spline

62  {
63  return UprightFrame(translation + other.translation, pitch + other.pitch, yaw + other.yaw);
64 }
float yaw
Definition: UprightFrame.h:32
float pitch
Definition: UprightFrame.h:29
UprightFrame(const Vector3 &t=Vector3::zero(), float p=0, float y=0)
Definition: UprightFrame.h:34
Vector3 translation
Definition: UprightFrame.h:26

+ Here is the call graph for this function:

UprightFrame & G3D::UprightFrame::operator= ( const Any any)
44  {
45  *this = UprightFrame(any);
46  return *this;
47 }
bool any(float x)
Definition: g3dmath.h:424
UprightFrame(const Vector3 &t=Vector3::zero(), float p=0, float y=0)
Definition: UprightFrame.h:34

+ Here is the call graph for this function:

void G3D::UprightFrame::serialize ( class BinaryOutput b) const
102  {
104  b.writeFloat32(pitch);
105  b.writeFloat32(yaw);
106 }
float yaw
Definition: UprightFrame.h:32
float pitch
Definition: UprightFrame.h:29
void serialize(class BinaryOutput &b) const
Definition: Vector3.cpp:219
Vector3 translation
Definition: UprightFrame.h:26

+ Here is the call graph for this function:

Any G3D::UprightFrame::toAny ( ) const
33  {
34  Any any(Any::TABLE, "UprightFrame");
35 
36  any["translation"] = translation;
37  any["pitch"] = pitch;
38  any["yaw"] = yaw;
39 
40  return any;
41 }
Definition: Any.h:187
float yaw
Definition: UprightFrame.h:32
bool any(float x)
Definition: g3dmath.h:424
float pitch
Definition: UprightFrame.h:29
Vector3 translation
Definition: UprightFrame.h:26

+ Here is the call graph for this function:

CoordinateFrame G3D::UprightFrame::toCoordinateFrame ( ) const
49  {
50  CoordinateFrame cframe;
51 
54 
55  cframe.rotation = Y * P;
56  cframe.translation = translation;
57 
58  return cframe;
59 }
float yaw
Definition: UprightFrame.h:32
static Matrix3 fromAxisAngle(const Vector3 &rkAxis, float fRadians)
Definition: Matrix3.cpp:1346
float pitch
Definition: UprightFrame.h:29
static const Vector3 & unitX()
Definition: Vector3.cpp:121
static const Vector3 & unitY()
Definition: Vector3.cpp:122
Vector3 translation
Definition: UprightFrame.h:26
uint8 const P[]
Definition: AuthenticationPackets.cpp:225
#define Y
Definition: CollisionDetection.cpp:2282

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void G3D::UprightFrame::unwrapYaw ( UprightFrame a,
int  N 
)
static

Unwraps the yaw values in the elements of the array such that they still represent the same angles but strictly increase/decrease without wrapping about zero. For use with Spline<UprightFrame>

72  {
73  // Use the first point to establish the wrapping convention
74  for (int i = 1; i < N; ++i) {
75  const float prev = a[i - 1].yaw;
76  float& cur = a[i].yaw;
77 
78  // No two angles should be more than pi (i.e., 180-degrees) apart.
79  if (abs(cur - prev) > G3D::pi()) {
80  // These angles must have wrapped at zero, causing them
81  // to be interpolated the long way.
82 
83  // Find canonical [0, 2pi] versions of these numbers
84  float p = (float)wrap(prev, twoPi());
85  float c = (float)wrap(cur, twoPi());
86 
87  // Find the difference -pi < diff < pi between the current and previous values
88  float diff = c - p;
89  if (diff < -G3D::pi()) {
90  diff += (float)twoPi();
91  } else if (diff > G3D::pi()) {
92  diff -= (float)twoPi();
93  }
94 
95  // Offset the current from the previous by the difference
96  // between them.
97  cur = prev + diff;
98  }
99  }
100 }
double abs(double fValue)
Definition: g3dmath.h:617
double pi()
Definition: g3dmath.h:147
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
double twoPi()
Definition: g3dmath.h:159
int prev(int i, int n)
Definition: RecastContour.cpp:468

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

float G3D::UprightFrame::pitch

-pi/2 < pitch < pi/2 in radians about the X-axis

Vector3 G3D::UprightFrame::translation
float G3D::UprightFrame::yaw

In radians about the Y-axis


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