gwnavruntime/math/transform.h Source File

transform.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 // primary contact: LAPA - secondary contact: NOBODY
9 #ifndef Navigation_Transform_H
10 #define Navigation_Transform_H
11 
12 
14 
15 
16 namespace Kaim
17 {
18 
20 class Transform
21 {
22  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
23 
24 public:
25  // ---------------------------------- Public Member Functions ----------------------------------
26 
27  Transform(const Matrix3x3f& matrix = Matrix3x3f::Identity(), const Vec3f& position = Vec3f::Zero())
28  : m_rotationMatrix(matrix)
29  , m_translation(position)
30  {}
31 
32  void SetIdentity()
33  {
34  m_translation = Vec3f::Zero();
35  m_rotationMatrix.SetIdentity();
36  }
37 
38  bool operator!=(const Transform& other)
39  {
40  return (
41  (m_rotationMatrix != other.m_rotationMatrix) ||
42  (m_translation != other.m_translation)
43  );
44  }
45 
46  bool operator==(const Transform& other)
47  {
48  return !(*this != other);
49  }
50 
53  KY_INLINE Vec3f GetRootVector(const Vec3f& v) const { return m_rotationMatrix * v; }
54 
56  KY_INLINE void GetRootVector(const Vec3f& v, Vec3f& w) const { w = m_rotationMatrix * v; }
57 
60  KY_INLINE Vec3f GetRootCoordinates(const Vec3f& v) const { return m_translation + GetRootVector(v); }
61 
63  KY_INLINE void GetRootCoordinates(const Vec3f& v, Vec3f& w) const { GetRootVector(v, w); w += m_translation; }
64 
65 
66  // ---------------------------------- Public Data Members ----------------------------------
67 
68  Matrix3x3f m_rotationMatrix;
69  Vec3f m_translation;
70 };
71 
74 KY_INLINE void SwapEndianness(Endianness::Target e, Transform& self)
75 {
76  SwapEndianness(e, self.m_rotationMatrix);
77  SwapEndianness(e, self.m_translation);
78 }
79 
80 
81 } // namespace Kaim
82 
83 #endif // Navigation_Transform_H
Vec3f GetRootVector(const Vec3f &v) const
Compute vector coordinates in root coordinate system for the local vector v.
Definition: transform.h:59
static Vec3f Zero()
Returns a vector of zero size: (0,0,0).
Definition: vec3f.h:209
3x3 matrix.
Definition: matrix3x3f.h:21
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
Definition: gamekitcrowddispersion.h:20
Vec3f GetRootCoordinates(const Vec3f &v) const
Compute position coordinates in root coordinate system for the local position v.
Definition: transform.h:67
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
This class represents a three-dimensional 6 freedom degrees unit transform.
Definition: transform.h:20
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23