2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
7 #ifndef CAFU_MATH_PLUECKER_HPP_INCLUDED
8 #define CAFU_MATH_PLUECKER_HPP_INCLUDED
10 #include "Vector3.hpp"
18 /// This class represents Pluecker coordinates.
19 /// Good introductions about Pluecker coordinates are found in publications by Seth Teller
20 /// (e.g. "Visibility Computations in Densely Occluded Polyhedral Environments" (Ph.D. dissertation, Berkeley, 1992)),
21 /// at Wikipedia (http://en.wikipedia.org/wiki/Pl%C3%BCcker_co-ordinates), and many other internet sites.
22 template<class T
> class PlueckerT
26 /// The default constructor.
29 p
[0]=p
[1]=p
[2]=p
[3]=p
[4]=p
[5]=0;
32 /// Constructor for creating a Pluecker coordinate from individual components.
33 PlueckerT(const T p0
, const T p1
, const T p2
, const T p3
, const T p4
, const T p5
)
43 /// Creates a Pluecker coordinate from the line (segment) that starts at point A and ends at point B.
44 static PlueckerT
CreateFromLine(const Vector3T
<T
>& A
, const Vector3T
<T
>& B
)
46 return PlueckerT(A
.x
*B
.y
- B
.x
*A
.y
,
54 /// Creates a Pluecker coordinate from the ray that starts at (or "passes through") point A into direction Dir.
55 static PlueckerT
CreateFromRay(const Vector3T
<T
>& A
, const Vector3T
<T
>& Dir
)
57 return PlueckerT(A
.x
*Dir
.y
- Dir
.x
*A
.y
,
58 A
.x
*Dir
.z
- Dir
.x
*A
.z
,
60 A
.y
*Dir
.z
- Dir
.y
*A
.z
,
66 /// Returns the i-th component of this Pluecker coordinate.
67 T
& operator [] (unsigned long i
) { assert(i
<6); return p
[i
]; }
69 /// Returns the i-th component of this Pluecker coordinate.
70 const T
& operator [] (unsigned long i
) const { assert(i
<6); return p
[i
]; }
72 /// This operator computes the permuted inner product (as described in Tellers dissertation) of the two Pluecker coordinates.
73 T
operator * (const PlueckerT
& Other
) const
75 return p
[0]*Other
.p
[4] + p
[1]*Other
.p
[5] + p
[2]*Other
.p
[3] + p
[4]*Other
.p
[0] + p
[5]*Other
.p
[1] + p
[3]*Other
.p
[2];
84 /// The six components of the Pluecker coordinate.
89 /// Typedef for an PlueckerT of floats.
90 typedef PlueckerT
<float> PlueckerfT
;
92 /// Typedef for an Pluecker of doubles.
93 typedef PlueckerT
<double> PlueckerdT
;