20 #if !defined(__MITSUBA_CORE_POINT_H_)
21 #define __MITSUBA_CORE_POINT_H_
40 const static int dim = 1;
51 #if !defined(MTS_DEBUG_UNINITIALIZED)
54 TPoint1() { x = std::numeric_limits<T>::quiet_NaN(); }
131 SLog(
EWarn,
"Point1: Division by zero!");
140 SLog(
EWarn,
"Point1: Division by zero!");
181 std::ostringstream oss;
182 oss <<
"[" << x <<
"]";
192 return std::abs(p2.
x-p2.
x);
196 return (p1-p2).lengthSquared();
202 SLog(
EWarn,
"Point1i: Division by zero!");
210 SLog(
EWarn,
"Point1i: Division by zero!");
229 const static int dim = 2;
240 #if !defined(MTS_DEBUG_UNINITIALIZED)
243 TPoint2() { x = y = std::numeric_limits<T>::quiet_NaN(); }
251 : x((T) p.x), y((T) p.y) { }
255 : x((T) v.x), y((T) v.y) { }
324 SLog(
EWarn,
"Point2: Division by zero!");
327 return TPoint2(x * recip, y * recip);
334 SLog(
EWarn,
"Point2: Division by zero!");
337 x *= recip; y *= recip;
353 return x == 0 && y == 0;
358 return (v.
x == x && v.
y == y);
363 return v.
x != x || v.
y != y;
374 std::ostringstream oss;
375 oss <<
"[" << x <<
", " << y <<
"]";
385 return (p1-p2).length();
389 return (p1-p2).lengthSquared();
395 SLog(
EWarn,
"Point2i: Division by zero!");
403 SLog(
EWarn,
"Point2i: Division by zero!");
422 const static int dim = 3;
433 #if !defined(MTS_DEBUG_UNINITIALIZED)
436 TPoint3() { x = y = z = std::numeric_limits<T>::quiet_NaN(); }
444 : x((T) p.x), y((T) p.y), z((T) p.z) { }
448 : x((T) v.x), y((T) v.y), z((T) v.z) { }
451 explicit TPoint3(T val) : x(val), y(val), z(val) { }
472 x += v.
x; y += v.
y; z += v.
z;
478 x += p.
x; y += p.
y; z += p.
z;
494 x -= v.
x; y -= v.
y; z -= v.
z;
500 return TPoint3(x * f, y * f, z * f);
505 x *= f; y *= f; z *= f;
518 SLog(
EWarn,
"Point3: Division by zero!");
521 return TPoint3(x * recip, y * recip, z * recip);
528 SLog(
EWarn,
"Point3: Division by zero!");
531 x *= recip; y *= recip; z *= recip;
547 return x == 0 && y == 0 && z == 0;
552 return (v.
x == x && v.
y == y && v.
z == z);
557 return v.
x != x || v.
y != y || v.
z != z;
570 std::ostringstream oss;
571 oss <<
"[" << x <<
", " << y <<
", " << z <<
"]";
581 return (p1-p2).length();
585 return (p1-p2).lengthSquared();
591 SLog(
EWarn,
"Point3i: Division by zero!");
599 SLog(
EWarn,
"Point3i: Division by zero!");
619 const static int dim = 4;
630 #if !defined(MTS_DEBUG_UNINITIALIZED)
633 TPoint4() { x = y = z = w = std::numeric_limits<T>::quiet_NaN(); }
637 TPoint4(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) { }
641 : x((T) p.x), y((T) p.y), z((T) p.z), w((T) p.w) { }
645 : x((T) v.x), y((T) v.y), z((T) v.z), w((T) v.w) { }
648 explicit TPoint4(T val) : x(val), y(val), z(val), w(val) { }
660 return TPoint4(x + v.
x, y + v.
y, z + v.
z, w + v.
w);
665 return TPoint4(x + p.
x, y + p.
y, z + p.
z, w + p.
w);
670 x += v.
x; y += v.
y; z += v.
z; w += v.
w;
676 x += p.
x; y += p.
y; z += p.
z; w += p.
w;
682 return TPoint4(x - v.
x, y - v.
y, z - v.
z, w - v.
w);
692 x -= v.
x; y -= v.
y; z -= v.
z; w -= v.
w;
698 return TPoint4(x * f, y * f, z * f, w * f);
703 x *= f; y *= f; z *= f; w *= f;
709 return TPoint4(-x, -y, -z, -w);
716 SLog(
EWarn,
"Point4: Division by zero!");
719 return TPoint4(x * recip, y * recip, z * recip, w * recip);
726 SLog(
EWarn,
"Point4: Division by zero!");
729 x *= recip; y *= recip; z *= recip; w *= recip;
745 return x == 0 && y == 0 && z == 0 && w == 0;
750 return (v.
x == x && v.
y == y && v.
z == z && v.
w == w);
755 return v.
x != x || v.
y != y || v.
z != z || v.
w != w;
768 std::ostringstream oss;
769 oss <<
"[" << x <<
", " << y <<
", " << z <<
", " << w <<
"]";
779 return (p1-p2).length();
783 return (p1-p2).lengthSquared();
789 SLog(
EWarn,
"Point4i: Division by zero!");
791 return TPoint4(x/s, y/s, z/s, w/s);
797 SLog(
EWarn,
"Point4i: Division by zero!");
TPoint2 & operator+=(const TVector2< T > &v)
Add a vector to this one (e.g. to compute a weighted position)
Definition: point.h:277
TPoint1 & operator/=(T f)
Divide the point's coordinates by the given scalar.
Definition: point.h:137
T operator[](int i) const
Index into the point's components (const version)
Definition: point.h:739
TPoint4 operator+(const TPoint4 &p) const
Add two points and return the result (e.g. to compute a weighted position)
Definition: point.h:664
TPoint3 operator+(const TPoint3 &p) const
Add two points and return the result (e.g. to compute a weighted position)
Definition: point.h:466
TPoint1(const TPoint1< T1 > &p)
Initialize the point with the components of another point.
Definition: point.h:61
T x
Definition: point.h:37
TPoint3(Stream *stream)
Unserialize a point from a binary data stream.
Definition: point.h:454
TPoint4 operator*(T f) const
Scale the point's coordinates by the given scalar and return the result.
Definition: point.h:697
TPoint2 & operator/=(T f)
Divide the point's coordinates by the given scalar.
Definition: point.h:331
TPoint4 operator-(const TVector4< T > &v) const
Subtract a vector from this point.
Definition: point.h:681
TPoint4 operator+(const TVector4< T > &v) const
Add a vector to a point and return the result.
Definition: point.h:659
TPoint4(const TVector4< T2 > &v)
Initialize the point with the components of a vector data structure.
Definition: point.h:644
std::string toString() const
Return a readable string representation of this point.
Definition: point.h:373
T readElement()
Read an element from the stream (uses partial template specialization to select a method appropriate ...
Definition: stream.h:508
TPoint2(Stream *stream)
Unserialize a point from a binary data stream.
Definition: point.h:261
T y
Definition: point.h:419
TPoint2< int > operator/(int s) const
Definition: point.h:392
TPoint1(const TVector1< T1 > &v)
Initialize the point with the components of a vector data structure.
Definition: point.h:65
TVector3< T > operator-(const TPoint3 &p) const
Subtract two points from each other and return the difference as a vector.
Definition: point.h:488
TPoint2(T val)
Initialize all components of the the point with the specified value.
Definition: point.h:258
T operator[](int i) const
Index into the point's components (const version)
Definition: point.h:152
T x
Definition: point.h:419
bool operator==(const TPoint2 &v) const
Equality test.
Definition: point.h:357
TPoint4 & operator/=(T f)
Divide the point's coordinates by the given scalar.
Definition: point.h:723
TPoint2()
Construct a new point without initializing it.
Definition: point.h:241
T & operator[](int i)
Index into the point's components.
Definition: point.h:342
TPoint2 operator+(const TVector2< T > &v) const
Add a vector to a point and return the result.
Definition: point.h:267
TPoint1()
Construct a new point without initializing it.
Definition: point.h:52
bool isZero() const
Return whether or not this point is identically zero.
Definition: point.h:352
T Scalar
Definition: point.h:613
T y
Definition: vector.h:455
T x
Definition: vector.h:667
TVector4< T > VectorType
Definition: point.h:614
TPoint1 & operator+=(const TVector1< T > &v)
Add a vector to this one (e.g. to compute a weighted position)
Definition: point.h:84
TPoint2 operator*(T f) const
Scale the point's coordinates by the given scalar and return the result.
Definition: point.h:305
TPoint4 & operator*=(T f)
Scale the point's coordinates by the given scalar.
Definition: point.h:702
T & operator[](int i)
Index into the point's components.
Definition: point.h:536
TPoint4< int > & operator/=(int s)
Definition: point.h:794
Parameterizable one-dimensional point data structure.
Definition: point.h:33
bool isZero() const
Return whether or not this point is identically zero.
Definition: point.h:546
TPoint2 & operator*=(T f)
Scale the point's coordinates by the given scalar.
Definition: point.h:310
TPoint4< int > operator/(int s) const
Definition: point.h:786
TPoint3< int > operator/(int s) const
Definition: point.h:588
TPoint3 operator/(T f) const
Divide the point's coordinates by the given scalar and return the result.
Definition: point.h:515
std::string toString() const
Return a readable string representation of this point.
Definition: point.h:767
TPoint3 & operator+=(const TPoint3 &p)
Add a point to this one (e.g. to compute a weighted position)
Definition: point.h:477
#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
TPoint2< int > & operator/=(int s)
Definition: point.h:400
T z
Definition: vector.h:667
bool operator!=(const TPoint3 &v) const
Inequality test.
Definition: point.h:556
TPoint2 & operator-=(const TVector2< T > &v)
Subtract a vector from this point.
Definition: point.h:299
bool operator==(const TPoint3 &v) const
Equality test.
Definition: point.h:551
T & operator[](int i)
Index into the point's components.
Definition: point.h:147
TPoint4 operator-() const
Return a version of the point, which has been flipped along the origin.
Definition: point.h:708
TVector2< T > VectorType
Definition: point.h:224
TPoint1 & operator-=(const TVector1< T > &v)
Subtract a vector from this point.
Definition: point.h:106
TVector1< T > operator-(const TPoint1 &p) const
Subtract two points from each other and return the difference as a vector.
Definition: point.h:101
bool operator!=(const TPoint4 &v) const
Inequality test.
Definition: point.h:754
TPoint4(Stream *stream)
Unserialize a point from a binary data stream.
Definition: point.h:651
TPoint4()
Construct a new point without initializing it.
Definition: point.h:631
TPoint2 operator/(T f) const
Divide the point's coordinates by the given scalar and return the result.
Definition: point.h:321
T w
Definition: point.h:616
bool operator!=(const TPoint2 &v) const
Inequality test.
Definition: point.h:362
TPoint1 operator+(const TPoint1 &p) const
Add two points and return the result (e.g. to compute a weighted position)
Definition: point.h:79
T x
Definition: vector.h:251
TVector2< T > operator-(const TPoint2 &p) const
Subtract two points from each other and return the difference as a vector.
Definition: point.h:294
T x
Definition: point.h:226
T x
Definition: vector.h:35
Parameterizable two-dimensional point data structure.
Definition: point.h:222
TPoint4(T val)
Initialize all components of the the point with the specified value.
Definition: point.h:648
TPoint1 operator*(T f) const
Scale the point's coordinates by the given scalar and return the result.
Definition: point.h:112
TPoint4 operator/(T f) const
Divide the point's coordinates by the given scalar and return the result.
Definition: point.h:713
T z
Definition: vector.h:455
TPoint4< T > operator*(T f, const TPoint4< T > &v)
Definition: point.h:774
Parameterizable one-dimensional vector data structure.
Definition: vector.h:31
T operator[](int i) const
Index into the point's components (const version)
Definition: point.h:347
TPoint3 operator-(const TVector3< T > &v) const
Subtract a vector from this point.
Definition: point.h:483
TPoint3(const TVector3< T2 > &v)
Initialize the point with the components of a vector data structure.
Definition: point.h:447
bool operator==(const TPoint4 &v) const
Equality test.
Definition: point.h:749
Parameterizable three-dimensional vector data structure.
Definition: vector.h:450
TVector1< T > VectorType
Definition: point.h:35
TPoint1 & operator*=(T f)
Scale the point's coordinates by the given scalar.
Definition: point.h:117
void writeElement(T value)
Write an element to the stream (uses partial template specialization to select a method appropriate t...
Definition: stream.h:512
TPoint2(const TPoint2< T2 > &p)
Initialize the point with the components of another point.
Definition: point.h:250
TPoint3 & operator+=(const TVector3< T > &v)
Add a vector to this one (e.g. to compute a weighted position)
Definition: point.h:471
T operator[](int i) const
Index into the point's components (const version)
Definition: point.h:541
TPoint2 operator-(const TVector2< T > &v) const
Subtract a vector from this point.
Definition: point.h:289
TPoint3 operator-() const
Return a version of the point, which has been flipped along the origin.
Definition: point.h:510
TPoint1< int > operator/(int s) const
Definition: point.h:199
TPoint3< int > & operator/=(int s)
Definition: point.h:596
T Scalar
Definition: point.h:223
Abstract seekable stream class.
Definition: stream.h:58
Warning message.
Definition: formatter.h:32
T x
Definition: vector.h:455
T x
Definition: point.h:616
TPoint3 operator+(const TVector3< T > &v) const
Add a vector to a point and return the result.
Definition: point.h:461
T Scalar
Definition: point.h:416
void serialize(Stream *stream) const
Serialize this point to a binary data stream.
Definition: point.h:367
bool isZero() const
Return whether or not this point is identically zero.
Definition: point.h:157
TPoint4 & operator+=(const TVector4< T > &v)
Add a vector to this one (e.g. to compute a weighted position)
Definition: point.h:669
T & operator[](int i)
Index into the point's components.
Definition: point.h:734
Parameterizable three-dimensional point data structure.
Definition: point.h:415
T y
Definition: vector.h:251
bool operator==(const TPoint1 &v) const
Equality test.
Definition: point.h:162
void serialize(Stream *stream) const
Serialize this point to a binary data stream.
Definition: point.h:561
TPoint1 operator-() const
Return a version of the point, which has been flipped along the origin.
Definition: point.h:123
TPoint4 & operator+=(const TPoint4 &p)
Add a point to this one (e.g. to compute a weighted position)
Definition: point.h:675
Parameterizable two-dimensional vector data structure.
Definition: vector.h:246
T distance(const TPoint4< T > &p1, const TPoint4< T > &p2)
Definition: point.h:778
TPoint3 & operator/=(T f)
Divide the point's coordinates by the given scalar.
Definition: point.h:525
TPoint2 & operator+=(const TPoint2 &p)
Add a point to this one (e.g. to compute a weighted position)
Definition: point.h:283
Parameterizable four-dimensional vector data structure.
Definition: vector.h:662
TPoint1 operator+(const TVector1< T > &v) const
Add a vector to a point and return the result.
Definition: point.h:74
TVector4< T > operator-(const TPoint4 &p) const
Subtract two points from each other and return the difference as a vector.
Definition: point.h:686
void serialize(Stream *stream) const
Serialize this point to a binary data stream.
Definition: point.h:172
TPoint1 operator-(const TVector1< T > &v) const
Subtract a vector from this point.
Definition: point.h:96
TPoint2 operator-() const
Return a version of the point, which has been flipped along the origin.
Definition: point.h:316
T y
Definition: vector.h:667
T Scalar
Definition: point.h:34
TPoint1(T x)
Initialize the point with the specified value.
Definition: point.h:58
TPoint4 & operator-=(const TVector4< T > &v)
Subtract a vector from this point.
Definition: point.h:691
TPoint2 operator+(const TPoint2 &p) const
Add two points and return the result (e.g. to compute a weighted position)
Definition: point.h:272
TPoint1< int > & operator/=(int s)
Definition: point.h:207
void serialize(Stream *stream) const
Serialize this point to a binary data stream.
Definition: point.h:759
TPoint3(const TPoint3< T2 > &p)
Initialize the point with the components of another point.
Definition: point.h:443
TPoint3(T val)
Initialize all components of the the point with the specified value.
Definition: point.h:451
TPoint3()
Construct a new point without initializing it.
Definition: point.h:434
T z
Definition: point.h:616
T y
Definition: point.h:616
TPoint3(T x, T y, T z)
Initialize the point with the specified X, Y and Z components.
Definition: point.h:440
bool isZero() const
Return whether or not this point is identically zero.
Definition: point.h:744
TPoint1 & operator+=(const TPoint1 &p)
Add a point to this one (e.g. to compute a weighted position)
Definition: point.h:90
TPoint2(const TVector2< T2 > &v)
Initialize the point with the components of a vector data structure.
Definition: point.h:254
Parameterizable four-dimensional point data structure.
Definition: point.h:612
TPoint3 & operator*=(T f)
Scale the point's coordinates by the given scalar.
Definition: point.h:504
TPoint3 operator*(T f) const
Scale the point's coordinates by the given scalar and return the result.
Definition: point.h:499
bool operator!=(const TPoint1 &v) const
Inequality test.
Definition: point.h:167
TPoint3 & operator-=(const TVector3< T > &v)
Subtract a vector from this point.
Definition: point.h:493
T z
Definition: point.h:419
TPoint1(Stream *stream)
Unserialize a point from a binary data stream.
Definition: point.h:69
TPoint2(T x, T y)
Initialize the point with the specified X, Y and Z components.
Definition: point.h:247
std::string toString() const
Return a readable string representation of this point.
Definition: point.h:569
T w
Definition: vector.h:667
TPoint4(T x, T y, T z, T w)
Initialize the point with the specified X, Y and Z components.
Definition: point.h:637
std::string toString() const
Return a readable string representation of this point.
Definition: point.h:180
T distanceSquared(const TPoint4< T > &p1, const TPoint4< T > &p2)
Definition: point.h:782
TPoint4(const TPoint4< T2 > &p)
Initialize the point with the components of another point.
Definition: point.h:640
TVector3< T > VectorType
Definition: point.h:417
TPoint1 operator/(T f) const
Divide the point's coordinates by the given scalar and return the result.
Definition: point.h:128
T y
Definition: point.h:226