gwnavruntime/math/transform.h Source File

transform.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
11 
12 namespace Kaim
13 {
14 
16 class Transform
17 {
18  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
19 public:
20  // ---------------------------------- Functions ----------------------------------
21  Transform() {}
22  Transform(const Matrix3x3f& rotationMatrix) : R(rotationMatrix) {}
23  Transform(const Vec3f& translation) : T(translation) {}
24  Transform(const Matrix3x3f& rotationMatrix, const Vec3f& translation) : R(rotationMatrix) , T(translation) {}
25 
26  void SetIdentity() { R.SetIdentity(); T = Vec3f::Zero(); }
27 
28  Vec3f Rotate(const Vec3f& to_rotate) const { return R.Transform(to_rotate); }
29  Vec3f Translate(const Vec3f& to_translate) const { return to_translate + T; }
30  Vec3f DoTransform(const Vec3f& to_transform) const { return R.Transform(to_transform) + T; }
31 
32  Matrix3x3f Rotate(const Matrix3x3f& to_rotate) const { return R.Transform(to_rotate); }
33 
34  Transform DoTransform(const Transform& to_transform) const
35  {
36  return Transform(R.Transform(to_transform.R), R.Transform(to_transform.T) + T);
37  }
38 
39  bool operator==(const Transform& other) { return R == other.R && T == other.T; }
40  bool operator!=(const Transform& other) { return !operator==(other); }
41 
42  // ---------------------------------- Data ----------------------------------
43  Matrix3x3f R;
44  Vec3f T;
45 };
46 
47 KY_INLINE void SwapEndianness(Endianness::Target e, Transform& self)
48 {
49  SwapEndianness(e, self.R);
50  SwapEndianness(e, self.T);
51 }
52 
53 template <class OSTREAM>
54 inline OSTREAM& operator<<(OSTREAM& os, const Transform& t)
55 {
56  os << t.R;
57  os << t.T << Endl;
58  return os;
59 }
60 
61 
62 }
63 
64 
Vec3f Transform(const Vec3f &to_transform) const
return transformed Vec3f
Definition: matrix3x3f.h:137
static Vec3f Zero()
Returns {0.0f, 0.0f, 0.0f}.
Definition: vec3f.h:99
Matrix3x3f is defined as 3 Transformed Unit Vectors:
Definition: matrix3x3f.h:24
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Matrix3x3f rotation and Vec3f translation.
Definition: transform.h:16
3d vector using 32bits floating points.
Definition: vec3f.h:16