OpenClonk
StdMeshQuaternion Struct Reference

#include <StdMeshMath.h>

Public Member Functions

float LenSqr () const
 
void Normalize ()
 

Static Public Member Functions

static StdMeshQuaternion Zero ()
 
static StdMeshQuaternion AngleAxis (float theta, const StdMeshVector &axis)
 
static StdMeshQuaternion Nlerp (const StdMeshQuaternion &lhs, const StdMeshQuaternion &rhs, float w)
 

Public Attributes

float w
 
float x
 
float y
 
float z
 

Detailed Description

Definition at line 58 of file StdMeshMath.h.

Member Function Documentation

◆ AngleAxis()

StdMeshQuaternion StdMeshQuaternion::AngleAxis ( float  theta,
const StdMeshVector axis 
)
static

Definition at line 72 of file StdMeshMath.cpp.

73 {
75  const float theta2 = theta/2.0f;
76  const float s = sin(theta2);
77  q.w = cos(theta2);
78  q.x = s*axis.x;
79  q.y = s*axis.y;
80  q.z = s*axis.z;
81  return q;
82 }
#define s

References s, w, StdMeshVector::x, x, StdMeshVector::y, y, StdMeshVector::z, and z.

Referenced by StdMeshMatrix::Decompose(), StdMeshSkeletonLoader::LoadSkeletonXml(), and StdMeshTransformation::Rotate().

Here is the caller graph for this function:

◆ LenSqr()

float StdMeshQuaternion::LenSqr ( ) const
inline

Definition at line 66 of file StdMeshMath.h.

66 { return w*w+x*x+y*y+z*z; }

References w, x, y, and z.

Referenced by Normalize().

Here is the caller graph for this function:

◆ Nlerp()

StdMeshQuaternion StdMeshQuaternion::Nlerp ( const StdMeshQuaternion lhs,
const StdMeshQuaternion rhs,
float  w 
)
static

Definition at line 93 of file StdMeshMath.cpp.

94 {
96  float c = lhs.w * rhs.w + lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z;
97  if (c < 0.0f)
98  q = lhs + w * (-rhs - lhs);
99  else
100  q = lhs + w * ( rhs - lhs);
101  q.Normalize();
102  return q;
103 }

References Normalize(), w, x, y, and z.

Referenced by StdMeshTransformation::Nlerp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Normalize()

void StdMeshQuaternion::Normalize ( )

Definition at line 84 of file StdMeshMath.cpp.

85 {
86  float length = sqrt(LenSqr());
87  w /= length;
88  x /= length;
89  y /= length;
90  z /= length;
91 }
float LenSqr() const
Definition: StdMeshMath.h:66

References LenSqr(), w, x, y, and z.

Referenced by Nlerp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Zero()

StdMeshQuaternion StdMeshQuaternion::Zero ( )
static

Definition at line 62 of file StdMeshMath.cpp.

63 {
65  q.w = 0.0f;
66  q.x = 0.0f;
67  q.y = 0.0f;
68  q.z = 0.0f;
69  return q;
70 }

References w, x, y, and z.

Referenced by StdMeshTransformation::Zero().

Here is the caller graph for this function:

Member Data Documentation

◆ w

◆ x

◆ y

◆ z


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