#ifndef _Plane3_H__ #define _Plane3_H__ #include "Vector3.h" namespace GtpVisibilityPreprocessor { struct SimpleRay; /** 3D Plane. */ class Plane3 { public: Vector3 mNormal; float mD; Plane3() {} Plane3(const Vector3 &a, const Vector3 &b, const Vector3 &c ); Plane3(const Vector3 &normal, const Vector3 &point ); void ReverseOrientation() { mNormal *= -1; mD *= -1; } float Distance(const Vector3 &v) const { return DotProd(v, mNormal) + mD; } enum {BACK_SIDE = -1, INTERSECTS = 0, FRONT_SIDE = 1}; /** Returns 1 if v is on front side, -1 if on back side, 0 if on plane. */ int Side(const Vector3 &v, const float threshold = 1e-6) const; /** Finds intersection of line segment between points a and b with plane. @param a start point @param b end point @param t if not NULL, returns parameter value of intersections @param coplanar if not NULL, returns true if plane and line segments are coplanar. */ Vector3 FindIntersection(const Vector3 &a, const Vector3 &b, float *t = NULL, bool *coplanar = NULL) const; /** Finds value of intersection parameter t on line segment from a to b. @returns 0 if coplanar, else parameter t */ float FindT(const Vector3 &a, const Vector3 &b) const; float FindT(const SimpleRay &a) const; friend bool PlaneIntersection(const Plane3 &a, const Plane3 &b, const Plane3 &c, Vector3 &result); friend bool PlaneIntersection(const Plane3 &p1, const Plane3 &p2); friend SimpleRay GetPlaneIntersection(const Plane3 &plane1, const Plane3 &plane2); friend ostream &operator<<(ostream &s, const Plane3 &p) { s<