mt
 All Classes Files Functions Enumerations Groups Pages
transform_utility.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006 by Adolfo Rodriguez *
3  * adolfo.rodriguez@upc.edu *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program 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 *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
22 
23 // HEADER GUARD
24 #ifndef MT_TRANSFORM_UTILITY_H
25 #define MT_TRANSFORM_UTILITY_H
26 
27 
28 // MT LIBRARY HEADERS
29 #include <mt/empty.h>
30 #include <mt/circle3.h>
31 #include <mt/cylinder3.h>
32 #include <mt/ellipse3.h>
33 #include <mt/line3.h>
34 #include <mt/plane3.h>
35 #include <mt/point3.h>
36 #include <mt/scalar.h>
37 #include <mt/sphere3.h>
38 #include <mt/unit3.h>
39 #include <mt/vector3.h>
40 
41 
43 
44 namespace mt
45 {
46 
48 
53 
55 Empty apply(const Transform& t,
56  const Empty& e);
57 
59 Vector3 apply(const Transform& t,
60  const Vector3& v);
61 
64 Unit3 apply(const Transform& t,
65  const Unit3& u);
66 
68 Point3 apply(const Transform& t,
69  const Point3& p);
70 
72 Line3 apply(const Transform& t,
73  const Line3& L);
74 
76 Plane3 apply(const Transform& t,
77  const Plane3& P);
78 
80 Sphere3 apply(const Transform& t,
81  const Sphere3& s);
82 
84 Cylinder3 apply(const Transform& t,
85  const Cylinder3& c);
86 
88 Circle3 apply(const Transform& t,
89  const Circle3& c);
90 
92 Ellipse3 apply(const Transform& t,
93  const Ellipse3& e);
94 
95 
97 
98 
99 inline Empty apply(const Transform& t,
100  const Empty& e)
101 {
102  return e;
103 }
104 
105 
106 inline Vector3 apply(const Transform& t,
107  const Vector3& v)
108 {
109  return t(v);
110 }
111 
112 
113 inline Unit3 apply(const Transform& t,
114  const Unit3& u)
115 {
116  const Rotation rotation(t.getRotation());
117 
118  return Unit3 (rotation(u));
119 }
120 
121 
122 inline Point3 apply(const Transform& t,
123  const Point3& p)
124 {
125  return t(p);
126 }
127 
128 
129 inline Line3 apply(const Transform& t,
130  const Line3& L)
131 {
132  const Unit3 dir(apply(t, L.getDirection()));
133  const Point3 sup(apply(t, L.getSupport()));
134 
135  return Line3(dir, sup, L.getDirectionType());
136 }
137 
138 
139 inline Plane3 apply(const Transform& t,
140  const Plane3& P)
141 {
142  const Unit3 nor(apply(t, P.getNormal()));
143  const Point3 sup(apply(t, P.getSupport()));
144 
145  return Plane3(nor, sup, P.getDirectionType());
146 }
147 
148 
149 inline Sphere3 apply(const Transform& t,
150  const Sphere3& s)
151 {
152  const Point3 center(apply(t, s.getCenter()));
153 
154  return Sphere3(center, s.getRadius());
155 }
156 
157 
158 inline Cylinder3 apply(const Transform& t,
159  const Cylinder3& c)
160 {
161  const Line3 axis(apply(t, c.getAxis()));
162 
163  return Cylinder3(axis, c.getRadius());
164 }
165 
166 
167 inline Circle3 apply(const Transform& t,
168  const Circle3& c)
169 {
170  const Point3 center(apply(t, c.getCenter()));
171  const Unit3 normal(apply(t, c.getNormal()));
172 
173  return Circle3(center, c.getRadius(), normal);
174 }
175 
176 
177 inline Ellipse3 apply(const Transform& t,
178  const Ellipse3& e)
179 {
180  const Rotation rotation(t.getRotation());
181  const Point3 center(apply(t, e.getCenter()));
182  const Vector3 axis1(rotation(e.getAxis(1)));
183  const Vector3 axis2(rotation(e.getAxis(2)));
184 
185  return Ellipse3(center, axis1, axis2);
186 }
187 
188 
189 } // mt
190 
191 
192 #endif // MT_TRANSFORM_UTILITY_H