Plane.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Core
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2011, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeCore/Base.h"
16 #include "CeeCore/Vec3d.h"
17 
18 namespace cee {
19 
20 class Ray;
21 
22 //==================================================================================================
23 //
24 // Class defining a plane in space
25 //
26 //==================================================================================================
27 class CEE_CORE_EXPORT Plane
28 {
29 public:
30  Plane();
31  Plane(const Plane& other);
32  Plane(double A, double B, double C, double D);
33  ~Plane();
34 
35  Plane& operator=(const Plane& other);
36 
37  bool operator==(const Plane& rhs) const;
38  bool operator!=(const Plane& rhs) const;
39 
40  double A() const;
41  double B() const;
42  double C() const;
43  double D() const;
44 
45  bool isValid() const;
46  double distance(const Vec3d& point) const;
47  double distanceSquared(const Vec3d& point) const;
48  Vec3d normal() const;
49  Vec3d pointInPlane() const;
50 
51  void set(double A, double B, double C, double D);
52  bool setFromPointAndNormal(const Vec3d& point, const Vec3d& normal);
53  bool setFromPoints(const Vec3d& p1, const Vec3d& p2, const Vec3d& p3);
54 
55  void transform(const Mat4d& matrix);
56 
57  bool rayIntersect(const Ray& ray, Vec3d* intersectionPoint) const;
58  bool rayIntersect(const Ray& ray, double* distance) const;
59 
60  bool projectVector(const Vec3d& vector, Vec3d* projectedVector) const;
61  Vec3d projectPoint(const Vec3d& point) const;
62 
63  static Plane createFromPointAndNormal(const Vec3d& point, const Vec3d& normal);
64  static Plane createFromPoints(const Vec3d& p1, const Vec3d& p2, const Vec3d& p3);
65 
66 private:
67  CEE_PRIVATE_IMPL(Plane);
68 };
69 
70 } // namespace cee
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppAssert.cpp:18
bool operator!=(const PtrRef< T1 > &a, const PtrRef< T2 > &b)
Returns true if the internal pointers of refs a and b are different.
Definition: PtrRef.h:58
A ray that can be used for intersection testing.
Definition: Ray.h:27
bool operator==(const PtrRef< T1 > &a, const PtrRef< T2 > &b)
Returns true if the internal pointers of refs a and b are equal.
Definition: PtrRef.h:57
Class defining a plane in space.
Definition: Plane.h:27
Vector class for a 3D double vector.
Definition: Vec3d.h:26
4 dimensional matrix.
Definition: Mat4d.h:26