TransformMatrix.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef DC_H_TRANSFORM_MATRIX_INCLUDED
34 #define DC_H_TRANSFORM_MATRIX_INCLUDED
35 
36 #include <Dynacoe/Util/Chain.h>
37 #include <Dynacoe/Util/Vector.h>
38 
39 
40 namespace Dynacoe {
41 
45  public:
47  TransformMatrix & operator=(const TransformMatrix &);
48  TransformMatrix(float *);
49  TransformMatrix(); // identity, row major
50 
52  Vector Transform(const Vector & p) const;
53 
56  Dynacoe::Chain Print() const;
57 
60  void Transpose();
61 
64  void Inverse();
65 
68  void ReverseMajority();
69 
72  float * GetData() const;
73 
74 
75 
79 
82  void RotateByAngles(float x, float y, float z);
83 
86  void RotateByVector(const Dynacoe::Vector &);
87 
90  void Translate(float x, float y, float z);
91 
94  void Scale(float x, float y, float z);
95 
96 
99  void SetToIdentity();
100 
101 
102 
103  private:
104  float data[16];
105 };
106 }
107 
108 #endif
A transform representated as a row-major matrix.
Definition: TransformMatrix.h:44
void SetToIdentity()
Sets the matrix to the identity matrix, removing all transformations.
Allows for easy string building and deconstructing.
Definition: Chain.h:52
3D and 2D positional vector.
Definition: Vector.h:55
void Scale(float x, float y, float z)
Expresses a scaling in the x, y, and z directions.
Definition: AssetID.h:37
Dynacoe::Chain Print() const
Returns a string containing info on the transform.
void Translate(float x, float y, float z)
Expresses a translation by x, y, and z.
Vector Transform(const Vector &p) const
Transforms the given point and returns its result;.
void Inverse()
Inverts the matrix.
void RotateByAngles(float x, float y, float z)
Rotates the matrix about the Euler angles psi, theta, and phi.
TransformMatrix operator*(const TransformMatrix &) const
Multiplies 2 matrices.
float * GetData() const
Returns the internal representation of the TransformMatrix.
void Transpose()
Transposes the matrix.
void RotateByVector(const Dynacoe::Vector &)
Rotates about a vector.
void ReverseMajority()
Reverse the majority of the matrix.