11 #ifndef CAFU_MATH_PLANE_HPP_INCLUDED
12 #define CAFU_MATH_PLANE_HPP_INCLUDED
14 #include "Vector3.hpp"
15 #include "Templates/Array.hpp"
53 Normal=normalize(cross(C-A, B-A), Epsilon);
62 if (!
Normal.IsValid())
return false;
64 const T len2=
Normal.GetLengthSqr();
66 return len2>0.9*0.9 && len2<1.1*1.1;
129 V.
x=-sin(RotY)*cos(RotZ);
130 V.
y=-sin(RotY)*sin(RotZ);
159 const T cosAngle=dot(
Normal, AB);
200 const T Nenner=dot(cross(A, B), C);
205 dot(cross(A, D), C)/Nenner,
206 dot(cross(A, B), D)/Nenner);
219 template<
class T>
inline std::string convertToString(
const Plane3T<T>& P)
221 const int sigdigits=std::numeric_limits<T>::digits10;
223 std::ostringstream out;
225 out << std::setprecision(sigdigits) << convertToString(P.
Normal) <<
", " << P.
Dist;
231 template<
class T>
inline std::ostream& operator << (std::ostream& os, const Plane3T<T>& P)
This class represents a plane in three-dimensional space.
Definition: Plane3.hpp:26
Vector3T< T > Normal
Normal vector of this plane.
Definition: Plane3.hpp:30
static void ConvexHull(const ArrayT< Vector3T< T > > &Points, ArrayT< Plane3T > &HullPlanes, ArrayT< unsigned long > *HullPlanesPIs, const T Epsilon)
Computes the convex hull of a set of points.
Definition: Plane3.cpp:14
bool operator==(const Plane3T &P) const
Returns whether this plane and plane P are truly (bit-wise) identical.
Definition: Plane3.hpp:169
Plane3T()
The default constructor.
Definition: Plane3.hpp:36
T y
The y-component of this vector.
Definition: Vector3.hpp:41
This class represents a polymorphic 3-dimensional vector.
Definition: Misc.hpp:11
bool IsValid() const
Returns true if the plane is valid, that is, if the normal vector is valid and (roughly) has length 1...
Definition: Plane3.hpp:60
bool operator!=(const Plane3T &P) const
Returns whether this plane and plane P are not equal (bit-wise).
Definition: Plane3.hpp:177
Plane3T(const Vector3T< T > &Normal_, T Dist_)
An explicit constructor.
Definition: Plane3.hpp:39
void GetSpanVectors(Vector3T< T > &U, Vector3T< T > &V) const
Compute two orthogonal span vectors for this plane.
Definition: Plane3.hpp:70
Vector3T< T > GetIntersection(const Vector3T< T > &A, const Vector3T< T > &B, const T cosEpsilon) const
Intersect the line through A and B with this plane.
Definition: Plane3.hpp:154
Plane3T(const Vector3T< T > &A, const Vector3T< T > &B, const Vector3T< T > &C, const T Epsilon)
This constructor creates the plane that contains the points ABC in clockwise order.
Definition: Plane3.hpp:48
T GetDistance(const Vector3T< T > &A) const
Determines the distance from A to this plane.
Definition: Plane3.hpp:141
Plane3T GetMirror() const
Returns the same, but mirrored plane, i.e. the plane with the reversed orientation.
Definition: Plane3.hpp:135
void GetSpanVectorsByRotation(Vector3T< T > &U, Vector3T< T > &V) const
Compute two orthogonal span vectors for this plane, using a different method than GetSpanVectors()...
Definition: Plane3.hpp:107
T z
The z-component of this vector.
Definition: Vector3.hpp:42
T x
The x-component of this vector.
Definition: Vector3.hpp:40
T Dist
Distance to origin (0, 0, 0).
Definition: Plane3.hpp:31
static Vector3T< T > GetIntersection(const Plane3T &P1, const Plane3T &P2, const Plane3T &P3)
Builds the intersection of three planes.
Definition: Plane3.hpp:188
Definition: Renderer.hpp:16
Division by zero error.
Definition: Errors.hpp:24