20 #if !defined(__MITSUBA_CORE_TRANSFORM_H_)
21 #define __MITSUBA_CORE_TRANSFORM_H_
37 m_transform.setIdentity();
38 m_invTransform.setIdentity();
51 : m_transform(trafo) {
52 bool success = m_transform.invert(m_invTransform);
59 : m_transform(trafo), m_invTransform(invTrafo) {
64 return Transform(m_invTransform, m_transform);
72 return m_transform.det3x3();
77 for (
int i=0; i<3; ++i) {
78 for (
int j=i; j<3; ++j) {
80 for (
int k=0; k<3; ++k)
81 sum += m_transform.m[i][k] * m_transform.m[j][k];
83 if (i == j && std::abs(sum-1) > 1e-3f)
85 else if (i != j && std::abs(sum) > 1e-3f)
94 return m_transform.isIdentity();
99 return m_transform.isZero();
109 Float x = m_transform.m[0][0] * p.x + m_transform.m[0][1] * p.y
110 + m_transform.m[0][2] * p.z + m_transform.m[0][3];
111 Float y = m_transform.m[1][0] * p.x + m_transform.m[1][1] * p.y
112 + m_transform.m[1][2] * p.z + m_transform.m[1][3];
113 Float z = m_transform.m[2][0] * p.x + m_transform.m[2][1] * p.y
114 + m_transform.m[2][2] * p.z + m_transform.m[2][3];
115 Float w = m_transform.m[3][0] * p.x + m_transform.m[3][1] * p.y
116 + m_transform.m[3][2] * p.z + m_transform.m[3][3];
119 SLog(
EWarn,
"w==0 in Transform::operator(Point &)");
122 return Point(x, y, z);
124 return Point(x, y, z) / w;
129 Float x = m_transform.m[0][0] * p.x + m_transform.m[0][1] * p.y
130 + m_transform.m[0][2] * p.z + m_transform.m[0][3];
131 Float y = m_transform.m[1][0] * p.x + m_transform.m[1][1] * p.y
132 + m_transform.m[1][2] * p.z + m_transform.m[1][3];
133 Float z = m_transform.m[2][0] * p.x + m_transform.m[2][1] * p.y
134 + m_transform.m[2][2] * p.z + m_transform.m[2][3];
140 dest.x = m_transform.m[0][0] * p.x + m_transform.m[0][1] * p.y
141 + m_transform.m[0][2] * p.z + m_transform.m[0][3];
142 dest.y = m_transform.m[1][0] * p.x + m_transform.m[1][1] * p.y
143 + m_transform.m[1][2] * p.z + m_transform.m[1][3];
144 dest.z = m_transform.m[2][0] * p.x + m_transform.m[2][1] * p.y
145 + m_transform.m[2][2] * p.z + m_transform.m[2][3];
153 dest.x = m_transform.m[0][0] * p.x + m_transform.m[0][1] * p.y
154 + m_transform.m[0][2] * p.z + m_transform.m[0][3];
155 dest.y = m_transform.m[1][0] * p.x + m_transform.m[1][1] * p.y
156 + m_transform.m[1][2] * p.z + m_transform.m[1][3];
157 dest.z = m_transform.m[2][0] * p.x + m_transform.m[2][1] * p.y
158 + m_transform.m[2][2] * p.z + m_transform.m[2][3];
159 Float w = m_transform.m[3][0] * p.x + m_transform.m[3][1] * p.y
160 + m_transform.m[3][2] * p.z + m_transform.m[3][3];
164 SLog(
EWarn,
"w==0 in Transform::operator(Point &, Point &)");
176 Float x = m_transform.m[0][0] * v.x + m_transform.m[0][1] * v.y
177 + m_transform.m[0][2] * v.z;
178 Float y = m_transform.m[1][0] * v.x + m_transform.m[1][1] * v.y
179 + m_transform.m[1][2] * v.z;
180 Float z = m_transform.m[2][0] * v.x + m_transform.m[2][1] * v.y
181 + m_transform.m[2][2] * v.z;
190 dest.x = m_transform.m[0][0] * v.x + m_transform.m[0][1] * v.y
191 + m_transform.m[0][2] * v.z;
192 dest.y = m_transform.m[1][0] * v.x + m_transform.m[1][1] * v.y
193 + m_transform.m[1][2] * v.z;
194 dest.z = m_transform.m[2][0] * v.x + m_transform.m[2][1] * v.y
195 + m_transform.m[2][2] * v.z;
204 Float x = m_invTransform.m[0][0] * v.
x + m_invTransform.m[1][0] * v.
y
205 + m_invTransform.m[2][0] * v.
z;
206 Float y = m_invTransform.m[0][1] * v.
x + m_invTransform.m[1][1] * v.
y
207 + m_invTransform.m[2][1] * v.
z;
208 Float z = m_invTransform.m[0][2] * v.
x + m_invTransform.m[1][2] * v.
y
209 + m_invTransform.m[2][2] * v.
z;
218 dest.
x = m_invTransform.m[0][0] * v.
x + m_invTransform.m[1][0] * v.
y
219 + m_invTransform.m[2][0] * v.
z;
220 dest.
y = m_invTransform.m[0][1] * v.
x + m_invTransform.m[1][1] * v.
y
221 + m_invTransform.m[2][1] * v.
z;
222 dest.
z = m_invTransform.m[0][2] * v.
x + m_invTransform.m[1][2] * v.
y
223 + m_invTransform.m[2][2] * v.
z;
232 Float x = m_transform.m[0][0] * v.x + m_transform.m[0][1] * v.y
233 + m_transform.m[0][2] * v.z + m_transform.m[0][3] * v.w;
234 Float y = m_transform.m[1][0] * v.x + m_transform.m[1][1] * v.y
235 + m_transform.m[1][2] * v.z + m_transform.m[1][3] * v.w;
236 Float z = m_transform.m[2][0] * v.x + m_transform.m[2][1] * v.y
237 + m_transform.m[2][2] * v.z + m_transform.m[2][3] * v.w;
238 Float w = m_transform.m[3][0] * v.x + m_transform.m[3][1] * v.y
239 + m_transform.m[3][2] * v.z + m_transform.m[3][3] * v.w;
248 dest.x = m_transform.m[0][0] * v.x + m_transform.m[0][1] * v.y
249 + m_transform.m[0][2] * v.z + m_transform.m[0][3] * v.w;
250 dest.y = m_transform.m[1][0] * v.x + m_transform.m[1][1] * v.y
251 + m_transform.m[1][2] * v.z + m_transform.m[1][3] * v.w;
252 dest.z = m_transform.m[2][0] * v.x + m_transform.m[2][1] * v.y
253 + m_transform.m[2][2] * v.z + m_transform.m[2][3] * v.w;
254 dest.w = m_transform.m[3][0] * v.x + m_transform.m[3][1] * v.y
255 + m_transform.m[3][2] * v.z + m_transform.m[3][3] * v.w;
265 operator()(a.o, b.o);
266 operator()(a.d, b.d);
271 b.dRcp.x = 1.0f / b.d.x;
272 b.dRcp.y = 1.0f / b.d.y;
273 b.dRcp.z = 1.0f / b.d.z;
287 operator()(ray, result);
295 transformAffine(a.o, b.o);
296 operator()(a.d, b.d);
301 b.dRcp.x = 1.0f / b.d.x;
302 b.dRcp.y = 1.0f / b.d.y;
303 b.dRcp.z = 1.0f / b.d.z;
312 transformAffine(ray, result);
392 m_transform.serialize(stream);
393 m_invTransform.serialize(stream);
398 return m_transform == trafo.m_transform;
403 return m_transform != trafo.m_transform;
407 std::string toString()
const;
std::string toString() const
Return a string representation.
Definition: matrix.h:426
Three-dimensional normal data structure.
Definition: normal.h:39
Matrix< M1, N2, T > operator*(const Matrix< M1, N1, T > &mat1, const Matrix< M2, N2, T > &mat2)
Matrix multiplication (creates a temporary)
Definition: matrix.h:745
Stores a three-dimensional orthonormal coordinate frame.
Definition: frame.h:37
MTS_EXPORT_CORE void restoreFPExceptions(bool state)
Restore floating point exceptions to the specified state.
T y
Definition: vector.h:455
TVector3< Float > Vector
Definition: fwd.h:113
#define MTS_EXPORT_CORE
Definition: getopt.h:29
#define SLog(level, fmt,...)
Write a Log message to the console (static version - to be used outside of classes that derive from O...
Definition: logger.h:49
TPoint3< Float > Point
Definition: fwd.h:136
T z
Definition: vector.h:455
TVector4< Float > Vector4
Definition: fwd.h:122
Abstract seekable stream class.
Definition: stream.h:58
Warning message.
Definition: formatter.h:32
T x
Definition: vector.h:455
Error message, causes an exception to be thrown.
Definition: formatter.h:33
Basic 4x4 matrix data type.
Definition: matrix.h:656
MTS_EXPORT_CORE bool disableFPExceptions()
Disable floating point exceptions.