TORCS
1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
Transform.cpp
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
#ifdef _MSC_VER
28
#pragma warning(disable:4786)
// identifier was truncated to '255'
29
#endif
// _MSC_VER
30
31
#include "
Transform.h
"
32
33
void
Transform::setValue
(
const
float
m[16]) {
34
basis
.setValue(m);
35
origin
.setValue(&m[12]);
36
type
=
AFFINE
;
37
}
38
39
void
Transform::setValue
(
const
double
m[16]) {
40
basis
.setValue(m);
41
origin
.setValue(&m[12]);
42
type
=
AFFINE
;
43
}
44
45
Transform
&
Transform::operator*=
(
const
Transform
& t) {
46
origin
+=
basis
* t.
origin
;
47
basis
*= t.
basis
;
48
type
|= t.
type
;
49
return
*
this
;
50
}
51
52
void
Transform::translate
(
const
Vector
& v) {
53
origin
+=
basis
* v;
54
type
|=
TRANSLATION
;
55
}
56
57
void
Transform::rotate
(
const
Quaternion
&
q
) {
58
basis
*=
Matrix
(
q
);
59
type
|=
ROTATION
;
60
}
61
62
void
Transform::scale
(
Scalar
x,
Scalar
y
,
Scalar
z) {
63
basis
*=
Matrix
(x,
y
, z);
64
type
|=
SCALING
;
65
}
66
67
void
Transform::setIdentity
() {
68
basis
.setIdentity();
69
origin
.setValue(0, 0, 0);
70
type
=
IDENTITY
;
71
}
72
73
void
Transform::invert
(
const
Transform
& t) {
74
basis
= t.
type
&
SCALING
?
inverse
(t.
basis
) :
transpose
(t.
basis
);
75
origin
.setValue(-
dot
(
basis
[
X
], t.
origin
),
76
-
dot
(
basis
[
Y
], t.
origin
),
77
-
dot
(
basis
[
Z
], t.
origin
));
78
type
= t.
type
;
79
}
80
81
void
Transform::mult
(
const
Transform
& t1,
const
Transform
& t2) {
82
basis
= t1.
basis
* t2.
basis
;
83
origin
= t1(t2.
origin
);
84
type
= t1.
type
| t2.
type
;
85
}
86
87
void
Transform::multInverseLeft
(
const
Transform
& t1,
const
Transform
& t2) {
88
Vector
v = t2.
origin
- t1.
origin
;
89
if
(t1.
type
&
SCALING
) {
90
Matrix
inv =
inverse
(t1.
basis
);
91
basis
= inv * t2.
basis
;
92
origin
= inv * v;
93
}
94
else
{
95
basis
=
multTransposeLeft
(t1.
basis
, t2.
basis
);
96
origin
= v * t1.
basis
;
97
}
98
type
= t1.
type
| t2.
type
;
99
}
Y
@ Y
Definition
Basic.h:58
X
@ X
Definition
Basic.h:58
Z
@ Z
Definition
Basic.h:58
Scalar
#define Scalar
Definition
Basic.h:34
q
static Point q[4]
Definition
Convex.cpp:55
y
static Vector y[4]
Definition
Convex.cpp:56
multTransposeLeft
Matrix multTransposeLeft(const Matrix &m1, const Matrix &m2)
Definition
Matrix.h:206
transpose
Matrix transpose(const Matrix &m)
Definition
Matrix.h:221
inverse
Matrix inverse(const Matrix &m)
Definition
Matrix.h:223
dot
Scalar dot(const Quaternion &q1, const Quaternion &q2)
Definition
Quaternion.h:163
Transform.h
Matrix
Definition
Matrix.h:37
Quaternion
Definition
Quaternion.h:33
Transform::type
unsigned int type
Definition
Transform.h:83
Transform::basis
Matrix basis
Definition
Transform.h:81
Transform::operator*=
Transform & operator*=(const Transform &t)
Definition
Transform.cpp:45
Transform::rotate
void rotate(const Quaternion &q)
Definition
Transform.cpp:57
Transform::Transform
Transform()
Definition
Transform.h:43
Transform::invert
void invert(const Transform &t)
Definition
Transform.cpp:73
Transform::mult
void mult(const Transform &t1, const Transform &t2)
Definition
Transform.cpp:81
Transform::translate
void translate(const Vector &v)
Definition
Transform.cpp:52
Transform::setIdentity
void setIdentity()
Definition
Transform.cpp:67
Transform::origin
Point origin
Definition
Transform.h:82
Transform::multInverseLeft
void multInverseLeft(const Transform &t1, const Transform &t2)
Definition
Transform.cpp:87
Transform::scale
void scale(Scalar x, Scalar y, Scalar z)
Definition
Transform.cpp:62
Transform::setValue
void setValue(const float m[16])
Definition
Transform.cpp:33
Transform::SCALING
@ SCALING
Definition
Transform.h:76
Transform::IDENTITY
@ IDENTITY
Definition
Transform.h:73
Transform::AFFINE
@ AFFINE
Definition
Transform.h:78
Transform::TRANSLATION
@ TRANSLATION
Definition
Transform.h:74
Transform::ROTATION
@ ROTATION
Definition
Transform.h:75
Vector
Definition
Vector.h:32
C:
Users
berni
Development
torcs_git
torcs-code
torcs
torcs
src
modules
simu
simuv2
SOLID-2.0
src
Transform.cpp
Generated by
1.14.0