TORCS  1.3.9
The Open Racing Car Simulator
Transform.h
Go to the documentation of this file.
1 /*
2  SOLID - Software Library for Interference Detection
3  Copyright (C) 1997-1998 Gino van den Bergen
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public
16  License along with this library; if not, write to the Free
17  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 
19  Please send remarks, questions and bug reports to gino@win.tue.nl,
20  or write to:
21  Gino van den Bergen
22  Department of Mathematics and Computing Science
23  Eindhoven University of Technology
24  P.O. Box 513, 5600 MB Eindhoven, The Netherlands
25 */
26 
27 #ifndef _TRANSFORM_H_
28 #define _TRANSFORM_H_
29 
30 #ifdef _MSC_VER
31 #pragma warning(disable:4786) // identifier was truncated to '255'
32 #endif // _MSC_VER
33 
34 #ifdef _MSC_VER
35 #pragma warning(disable:4786) // identifier was truncated to '255'
36 #endif // _MSC_VER
37 
38 #include <3D/Point.h>
39 #include <3D/Matrix.h>
40 
41 class Transform {
42 public:
43  Transform() {}
44  Transform(const float m[16]) { setValue(m); }
45  Transform(const double m[16]) { setValue(m); }
46 
47  Point operator()(const Point& p) const {
48  return Point(dot(basis[X], p) + origin[X],
49  dot(basis[Y], p) + origin[Y],
50  dot(basis[Z], p) + origin[Z]);
51  }
52 
53  const Matrix& getBasis() const { return basis; }
54  const Point& getOrigin() const { return origin; }
55 
56  void setValue(const float m[16]);
57  void setValue(const double m[16]);
58 
59  void setIdentity();
60 
61  Transform& operator*=(const Transform& t);
62 
63  void translate(const Vector& v);
64  void rotate(const Quaternion& q);
65  void scale(Scalar x, Scalar y, Scalar z);
66 
67  void invert(const Transform& t);
68  void mult(const Transform& t1, const Transform& t2);
69  void multInverseLeft(const Transform& t1, const Transform& t2);
70 
71 private:
72  enum {
73  IDENTITY = 0x00,
74  TRANSLATION = 0x01,
75  ROTATION = 0x02,
76  SCALING = 0x04,
79  };
80 
83  unsigned int type;
84 };
85 
86 #endif
void scale(Scalar x, Scalar y, Scalar z)
Definition: Transform.cpp:62
static Point q[4]
Definition: Convex.cpp:55
Matrix basis
Definition: Transform.h:81
const Matrix & getBasis() const
Definition: Transform.h:53
const Point & getOrigin() const
Definition: Transform.h:54
void multInverseLeft(const Transform &t1, const Transform &t2)
Definition: Transform.cpp:87
Scalar dot(const Quaternion &q1, const Quaternion &q2)
Definition: Quaternion.h:163
void invert(const Transform &t)
Definition: Transform.cpp:73
Definition: Basic.h:58
Point operator()(const Point &p) const
Definition: Transform.h:47
Point origin
Definition: Transform.h:82
void translate(const Vector &v)
Definition: Transform.cpp:52
Definition: Basic.h:58
void setValue(const float m[16])
Definition: Transform.cpp:33
Transform(const double m[16])
Definition: Transform.h:45
Transform()
Definition: Transform.h:43
Transform & operator*=(const Transform &t)
Definition: Transform.cpp:45
static Point p[4]
Definition: Convex.cpp:54
Definition: Basic.h:58
unsigned int type
Definition: Transform.h:83
Transform(const float m[16])
Definition: Transform.h:44
Definition: Matrix.h:37
static Vector y[4]
Definition: Convex.cpp:56
void mult(const Transform &t1, const Transform &t2)
Definition: Transform.cpp:81
void setIdentity()
Definition: Transform.cpp:67
#define Scalar
Definition: Basic.h:34
Definition: Vector.h:32
Definition: Point.h:34
void rotate(const Quaternion &q)
Definition: Transform.cpp:57